diff --git a/tests/integration/features/bootstrap/CommandLineTrait.php b/tests/integration/Contexts/CommandLineTrait.php similarity index 98% rename from tests/integration/features/bootstrap/CommandLineTrait.php rename to tests/integration/Contexts/CommandLineTrait.php index 723043f1a31..bca2dc5ff04 100644 --- a/tests/integration/features/bootstrap/CommandLineTrait.php +++ b/tests/integration/Contexts/CommandLineTrait.php @@ -7,11 +7,14 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +namespace OCA\Talk\Tests\Integration\Contexts; + use Behat\Step\Given; use Behat\Step\Then; +use GuzzleHttp; use PHPUnit\Framework\Assert; -require __DIR__ . '/../../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; // The following attributes are expected to be available in the class that uses // this trait: diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/Contexts/FeatureContext.php similarity index 99% rename from tests/integration/features/bootstrap/FeatureContext.php rename to tests/integration/Contexts/FeatureContext.php index 07eee85a019..ab94173bdc7 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/Contexts/FeatureContext.php @@ -7,10 +7,12 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-or-later */ -require __DIR__ . '/../../vendor/autoload.php'; + +namespace OCA\Talk\Tests\Integration\Contexts; + +require __DIR__ . '/../vendor/autoload.php'; use Behat\Behat\Context\Context; -use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\Gherkin\Node\TableNode; use Behat\Hook\AfterScenario; @@ -19,16 +21,20 @@ use Behat\Step\Given; use Behat\Step\Then; use Behat\Step\When; +use DateTime; +use Exception; +use GuzzleHttp; use GuzzleHttp\Client; use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Exception\ClientException; +use JsonException; use PHPUnit\Framework\Assert; use Psr\Http\Message\ResponseInterface; /** * Defines application features from the specific context. */ -class FeatureContext implements Context, SnippetAcceptingContext { +class FeatureContext implements Context { public const TEST_PASSWORD = '123456'; /** @var array */ @@ -213,8 +219,8 @@ public function getAttendeeId(string $type, string $id, string $room, ?string $u */ public function __construct() { $this->cookieJars = []; - $this->localServerUrl = getenv('TEST_SERVER_URL'); - $this->remoteServerUrl = getenv('TEST_REMOTE_URL'); + $this->localServerUrl = getenv('TEST_SERVER_URL') ?: ''; + $this->remoteServerUrl = getenv('TEST_REMOTE_URL') ?: ''; foreach (['LOCAL', 'REMOTE'] as $server) { $this->changedConfigs[$server] = []; @@ -275,7 +281,7 @@ public function setUp(BeforeScenarioScope $scope): void { public function getOtherRequiredSiblingContexts(BeforeScenarioScope $scope): void { $environment = $scope->getEnvironment(); - $this->sharingContext = $environment->getContext('SharingContext'); + $this->sharingContext = $environment->getContext(SharingContext::class); } #[AfterScenario] @@ -4796,7 +4802,7 @@ public function userSendTheFileAsAvatarOfRoom(string $user, string $file, string 'multipart' => [ [ 'name' => 'file', - 'contents' => $file !== 'invalid' ? fopen(__DIR__ . '/../../../..' . $file, 'r') : '', + 'contents' => $file !== 'invalid' ? fopen(__DIR__ . '/../../..' . $file, 'r') : '', ], ], ]; @@ -4943,7 +4949,7 @@ public function userStoreRecordingFileInRoom(string $user, string $file, string // Upload a file $options['multipart'][] = [ 'name' => 'file', - 'contents' => fopen(__DIR__ . '/../../../..' . $file, 'r'), + 'contents' => fopen(__DIR__ . '/../../..' . $file, 'r'), ]; } $this->sendRequest( @@ -5020,7 +5026,7 @@ public function recordingServerUploadsRecordingFileToRequestedShare(string $file if ($file === 'empty') { $options['body'] = ''; } else { - $options['body'] = fopen(__DIR__ . '/../../../..' . $file, 'r'); + $options['body'] = fopen(__DIR__ . '/../../..' . $file, 'r'); } $client = new Client(); diff --git a/tests/integration/features/bootstrap/RecordingTrait.php b/tests/integration/Contexts/RecordingTrait.php similarity index 99% rename from tests/integration/features/bootstrap/RecordingTrait.php rename to tests/integration/Contexts/RecordingTrait.php index 5300f926460..4e996de951d 100644 --- a/tests/integration/features/bootstrap/RecordingTrait.php +++ b/tests/integration/Contexts/RecordingTrait.php @@ -7,6 +7,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +namespace OCA\Talk\Tests\Integration\Contexts; + use Behat\Gherkin\Node\TableNode; use Behat\Hook\AfterScenario; use Behat\Step\Given; @@ -165,8 +167,8 @@ private function startMockServer(string $path) { $descriptorSpec = [ 0 => $stdin, - 1 => [ 'file', $stdoutf, 'a' ], - 2 => [ 'file', $stderrf, 'a' ], + 1 => ['file', $stdoutf, 'a'], + 2 => ['file', $stderrf, 'a'], ]; $process = proc_open($fullCmd, $descriptorSpec, $pipes, $cwd, $env, [ diff --git a/tests/integration/features/bootstrap/SharingContext.php b/tests/integration/Contexts/SharingContext.php similarity index 98% rename from tests/integration/features/bootstrap/SharingContext.php rename to tests/integration/Contexts/SharingContext.php index 38747a4ccb6..a2c40519408 100644 --- a/tests/integration/features/bootstrap/SharingContext.php +++ b/tests/integration/Contexts/SharingContext.php @@ -7,11 +7,14 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +namespace OCA\Talk\Tests\Integration\Contexts; + use Behat\Behat\Context\Context; use Behat\Gherkin\Node\TableNode; use Behat\Step\Given; use Behat\Step\Then; use Behat\Step\When; +use GuzzleHttp; use GuzzleHttp\Client; use GuzzleHttp\Cookie\CookieJar; use Psr\Http\Message\ResponseInterface; @@ -477,10 +480,10 @@ public function userGetsTheShareTypeDavPropertyFor(string $user, string $path): $headers = null; $body = '' - . ' ' - . ' ' - . ' ' - . ''; + . ' ' + . ' ' + . ' ' + . ''; $this->sendingToDav('PROPFIND', $url, $headers, $body); @@ -610,17 +613,17 @@ public function shareXIsReturnedWith(int $number, TableNode $body): void { $expectedFields = array_merge($defaultExpectedFields, $fields); if (!array_key_exists('uid_file_owner', $expectedFields) - && array_key_exists('uid_owner', $expectedFields)) { + && array_key_exists('uid_owner', $expectedFields)) { $expectedFields['uid_file_owner'] = $expectedFields['uid_owner']; } if (!array_key_exists('displayname_file_owner', $expectedFields) - && array_key_exists('displayname_owner', $expectedFields)) { + && array_key_exists('displayname_owner', $expectedFields)) { $expectedFields['displayname_file_owner'] = $expectedFields['displayname_owner']; } if (array_key_exists('share_type', $expectedFields) - && $expectedFields['share_type'] == 10 /* IShare::TYPE_ROOM */ - && array_key_exists('share_with', $expectedFields)) { + && $expectedFields['share_type'] == 10 /* IShare::TYPE_ROOM */ + && array_key_exists('share_with', $expectedFields)) { if ($expectedFields['share_with'] === 'private_conversation') { $expectedFields['share_with'] = 'REGEXP /^private_conversation_[0-9a-f]{6}$/'; $expectedFields['share_with_link'] = ''; @@ -738,7 +741,7 @@ public function theResponseContainsAShareTypesFilesPropertyForWith(string $path, $response = json_decode($this->responseBody); $fileForPath = array_filter($response->files, function ($file) use ($path) { - $filePath = $file->path . (substr($file->path, -1) === '/'? '': '/'); + $filePath = $file->path . (substr($file->path, -1) === '/' ? '' : '/'); return ($filePath . $file->name) === $path; }); diff --git a/tests/integration/behat.php b/tests/integration/behat.php new file mode 100644 index 00000000000..486312403e3 --- /dev/null +++ b/tests/integration/behat.php @@ -0,0 +1,47 @@ +withProfile((new Profile('default', [ + 'autoload' => [ + '' => '%paths.base%/features/bootstrap', + ], + ])) + ->withFormatter((new JUnitFormatter()) + ->withOutputPath('%paths.base%/output')) + ->withFormatter((new PrettyFormatter()) + ->withOutputStyles([ + 'comment' => [ + 'bright-blue', + ], + ])) + ->withExtension(new Extension(GithubActionsExtension::class)) + ->withSuite((new Suite('default')) + ->addContext(FeatureContext::class) + ->addContext( + SharingContext::class, + [ + 'baseUrl' => 'http://localhost:8080/', + 'admin' => [ + 'admin', + 'admin', + ], + 'regularUserPassword' => 123456, + ] + ) + ->withPaths('%paths.base%/features'))); diff --git a/tests/integration/composer.json b/tests/integration/composer.json index 82d4c63c784..8b476b3dccc 100644 --- a/tests/integration/composer.json +++ b/tests/integration/composer.json @@ -7,11 +7,12 @@ }, "autoload": { "psr-4": { - "OCA\\Talk\\Tests\\Integration\\Behat\\GithubActions\\": "github-actions-formatter/" + "OCA\\Talk\\Tests\\Integration\\Behat\\GithubActions\\": "github-actions-formatter/", + "OCA\\Talk\\Tests\\Integration\\Contexts\\": "Contexts/" } }, "require-dev": { - "behat/behat": "^3.32.0", + "behat/behat": "^4.0.0-alpha1@alpha", "guzzlehttp/guzzle": "^8.1.0", "phpunit/phpunit": "^12.5" } diff --git a/tests/integration/composer.lock b/tests/integration/composer.lock index 596c28d4d9e..c3e340a8ac9 100644 --- a/tests/integration/composer.lock +++ b/tests/integration/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "40d8916396b23c38254e3c26a1223484", + "content-hash": "08fad33e64cf0f0032bfe6dd433990b7", "packages": [], "packages-dev": [ { "name": "behat/behat", - "version": "v3.32.0", + "version": "v4.0.0-alpha1", "source": { "type": "git", "url": "https://github.com/Behat/Behat.git", - "reference": "b9b89cf7a3b24c04d6e2d2865ed51bc5e1700de9" + "reference": "82fbe243d1c1b66f9709f11f039616347d7f2192" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Behat/zipball/b9b89cf7a3b24c04d6e2d2865ed51bc5e1700de9", - "reference": "b9b89cf7a3b24c04d6e2d2865ed51bc5e1700de9", + "url": "https://api.github.com/repos/Behat/Behat/zipball/82fbe243d1c1b66f9709f11f039616347d7f2192", + "reference": "82fbe243d1c1b66f9709f11f039616347d7f2192", "shasum": "" }, "require": { @@ -26,15 +26,14 @@ "composer-runtime-api": "^2.2", "composer/xdebug-handler": "^1.4 || ^2.0 || ^3.0", "ext-mbstring": "*", - "nikic/php-parser": "^4.19.2 || ^5.2", "php": ">=8.2 <8.6", "psr/container": "^1.0 || ^2.0", - "symfony/config": "^5.4 || ^6.4 || ^7.0", - "symfony/console": "^5.4.9 || ^6.4 || ^7.0", - "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0", - "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0", - "symfony/translation": "^5.4 || ^6.4 || ^7.0", - "symfony/yaml": "^5.4 || ^6.4 || ^7.0" + "symfony/config": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/console": "^5.4.9 || ^6.4 || ^7.0 || ^8.0", + "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/translation": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/yaml": "^5.4 || ^6.4 || ^7.0 || ^8.0" }, "require-dev": { "opis/json-schema": "^2.5", @@ -43,9 +42,9 @@ "phpunit/phpunit": "^9.6", "rector/rector": "2.3.9", "sebastian/diff": "^4.0", - "symfony/filesystem": "^5.4 || ^6.4 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.4 || ^7.0 || ^8.0", "symfony/polyfill-php84": "^1.31", - "symfony/process": "^5.4 || ^6.4 || ^7.0" + "symfony/process": "^5.4 || ^6.4 || ^7.0 || ^8.0" }, "suggest": { "ext-dom": "Needed to output test results in JUnit format." @@ -93,7 +92,7 @@ ], "support": { "issues": "https://github.com/Behat/Behat/issues", - "source": "https://github.com/Behat/Behat/tree/v3.32.0" + "source": "https://github.com/Behat/Behat/tree/v4.0.0-alpha1" }, "funding": [ { @@ -109,7 +108,7 @@ "type": "github" } ], - "time": "2026-06-20T08:34:52+00:00" + "time": "2026-06-22T21:13:12+00:00" }, { "name": "behat/gherkin", @@ -4245,7 +4244,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "behat/behat": 15 + }, "prefer-stable": false, "prefer-lowest": false, "platform": {}, diff --git a/tests/integration/config/behat.yml b/tests/integration/config/behat.yml deleted file mode 100644 index 9332b830c93..00000000000 --- a/tests/integration/config/behat.yml +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later - -default: - extensions: - OCA\Talk\Tests\Integration\Behat\GithubActions\GithubActionsExtension: ~ - formatters: - junit: - output_path: '%paths.base%/../output' - pretty: - output_styles: - comment: [ 'bright-blue' ] - autoload: - '': '%paths.base%/../features/bootstrap' - suites: - default: - paths: - - '%paths.base%/../features' - contexts: - - FeatureContext - - SharingContext: - baseUrl: http://localhost:8080/ - admin: - - admin - - admin - regularUserPassword: 123456 diff --git a/tests/integration/github-actions-formatter/GithubActionsFormatter.php b/tests/integration/github-actions-formatter/GithubActionsFormatter.php index 5991b917d6e..242ac1d94c1 100644 --- a/tests/integration/github-actions-formatter/GithubActionsFormatter.php +++ b/tests/integration/github-actions-formatter/GithubActionsFormatter.php @@ -85,7 +85,7 @@ public function getOutputPrinter(): OutputPrinter { return $this->printer; } - public function setParameter($name, $value): void { + public function setParameter(string $name, $value): void { $this->parameters[$name] = $value; if ($name === 'base_path' && is_string($value) && $value !== '') { @@ -93,7 +93,7 @@ public function setParameter($name, $value): void { } } - public function getParameter($name) { + public function getParameter(string $name): mixed { return $this->parameters[$name] ?? null; }