-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add file conversion integration tests
Signed-off-by: skjnldsv <[email protected]>
- Loading branch information
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SPDX-FileCopyrightText: 2019 CHUTTERSNAP <https://unsplash.com/@chuttersnap> <https://unsplash.com/photos/blue-clouds-under-white-sky-9AqIdzEc9pY>" | ||
SPDX-License-Identifier: LicenseRef-Unsplash |
52 changes: 52 additions & 0 deletions
52
build/integration/features/bootstrap/ConversionsContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc. | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Behat\Context\SnippetAcceptingContext; | ||
use Behat\Gherkin\Node\TableNode; | ||
use GuzzleHttp\Client; | ||
|
||
class ConversionsContext implements Context, SnippetAcceptingContext { | ||
use WebDav; | ||
|
||
public function __construct(string $baseUrl) { | ||
$this->baseUrl = $baseUrl; | ||
|
||
// in case of ci deployment we take the server url from the environment | ||
$testServerUrl = getenv('TEST_SERVER_URL'); | ||
if ($testServerUrl !== false) { | ||
$this->baseUrl = substr($testServerUrl, 0, -5); | ||
} | ||
} | ||
|
||
/** @BeforeScenario */ | ||
public function setUpScenario() { | ||
$this->client = new Client(); | ||
} | ||
|
||
/** @AfterScenario */ | ||
public function tearDownScenario() { | ||
} | ||
|
||
/** | ||
* @When /^user "([^"]*)" converts file "([^"]*)" to "([^"]*)"$/ | ||
*/ | ||
public function userConvertsTheSavedFileId(string $user, string $path, string $mime) { | ||
$this->userConvertsTheSavedFileIdTo($user, $path, $mime, null); | ||
|
||
} | ||
|
||
/** | ||
* @When /^user "([^"]*)" converts file "([^"]*)" to "([^"]*)" as "([^"]*)"$/ | ||
*/ | ||
public function userConvertsTheSavedFileIdTo(string $user, string $path, string $mime, ?string $destination) { | ||
$fileId = $this->getFileIdForPath($user, $path); | ||
$body = new TableNode([['fileId', $fileId], ['mime', $mime], ['destination', $destination]]); | ||
$this->sendingToWith('post', "/ocs/v2.php/apps/files/api/v1/convert", $body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
# SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
Feature: conversions | ||
Background: | ||
Given using api version "1" | ||
Given using new dav path | ||
Given user "user0" exists | ||
|
||
Scenario: Converting a file works | ||
Given user "user0" uploads file "data/clouds.jpg" to "/clouds.jpg" | ||
Then as "user0" the file "/clouds.jpg" exists | ||
When user "user0" converts file "/clouds.jpg" to "image/png" | ||
Then the HTTP status code should be "200" | ||
Then the OCS status code should be "200" | ||
Then as "user0" the file "/clouds.png" exists |