From 6146df04fc84a5b1f9e21df7dda2a6161319ec2c Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Sat, 14 May 2022 21:32:24 +0300 Subject: [PATCH 01/15] Make constraints compatible with PHPUnit 10 --- src/Codeception/Constraint/Crawler.php | 2 +- src/Codeception/Constraint/CrawlerNot.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Codeception/Constraint/Crawler.php b/src/Codeception/Constraint/Crawler.php index 52b0823..9da0d42 100644 --- a/src/Codeception/Constraint/Crawler.php +++ b/src/Codeception/Constraint/Crawler.php @@ -42,7 +42,7 @@ protected function matches($nodes): bool * @param string $selector * @param ComparisonFailure|null $comparisonFailure */ - protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): void + protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never { if (!$nodes->count()) { throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath'); diff --git a/src/Codeception/Constraint/CrawlerNot.php b/src/Codeception/Constraint/CrawlerNot.php index dba1ef4..0333f52 100644 --- a/src/Codeception/Constraint/CrawlerNot.php +++ b/src/Codeception/Constraint/CrawlerNot.php @@ -24,7 +24,7 @@ protected function matches($nodes): bool * @param string $selector * @param ComparisonFailure|null $comparisonFailure */ - protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): void + protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never { if (!$this->string) { throw new ExpectationFailedException( From 32e9a19a39bbb5165cdb845dc3618b412a17e6da Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Fri, 3 Feb 2023 21:31:45 +0200 Subject: [PATCH 02/15] This version requires PHPUnit 10 --- .github/workflows/main.yml | 4 ++-- composer.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c30679d..7013219 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,11 +11,11 @@ jobs: strategy: matrix: - php: [8.0, 8.1] + php: [8.1, 8.2] steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/composer.json b/composer.json index 3702621..ad6a87c 100644 --- a/composer.json +++ b/composer.json @@ -18,18 +18,18 @@ ], "homepage": "https://codeception.com/", "require": { - "php": "^8.0", + "php": "^8.1", "ext-dom": "*", "ext-json": "*", "ext-mbstring": "*", - "codeception/codeception": "^5.0", + "codeception/codeception": "^5.0.8", "codeception/lib-web": "^1.0.1", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^10.0", "symfony/browser-kit": "^4.4.24 || ^5.4 || ^6.0", "symfony/dom-crawler": "^4.4.30 || ^5.4 || ^6.0" }, "require-dev": { - "codeception/util-universalframework": "dev-master" + "codeception/util-universalframework": "^1.0" }, "minimum-stability": "RC", "autoload": { From 043e5ab5bdc3db2665f9a551bbebf167f885387f Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Thu, 9 Feb 2023 08:34:12 +0200 Subject: [PATCH 03/15] Delete .scrutinizer.yml Because Scrutinizer is not working --- .scrutinizer.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 8849d54..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,11 +0,0 @@ -tools: - external_code_coverage: true -build: - nodes: - analysis: - tests: - override: - - php-scrutinizer-run -filter: - excluded_paths: - - "tests/_support/_generated" \ No newline at end of file From 41d535c988f29da579757052f7276c174aa1fa26 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 16 Nov 2023 17:20:45 +0100 Subject: [PATCH 04/15] Use FQN in @throws annotation --- src/Codeception/Lib/InnerBrowser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index 7d80e37..a006f21 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -1569,7 +1569,7 @@ public function grabCookie(string $cookie, array $params = []): mixed /** * Grabs current page source code. * - * @throws ModuleException if no page was opened. + * @throws \Codeception\Exception\ModuleException if no page was opened. * @return string Current page source code. */ public function grabPageSource(): string From ee5d25ee93444845d34dc78a73973016695df421 Mon Sep 17 00:00:00 2001 From: Jan Fejtek Date: Thu, 16 Nov 2023 17:24:33 +0100 Subject: [PATCH 05/15] Fix [TypeError] strlen(): Argument #1 ($string) must be of type string, int given (#64) --- src/Codeception/Lib/InnerBrowser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index a006f21..f124345 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -1906,7 +1906,7 @@ protected function getFormPhpValues(array $requestParams): array } parse_str($qs, $expandedValue); - $varName = substr($name, 0, strlen(key($expandedValue))); + $varName = substr($name, 0, strlen((string)key($expandedValue))); $requestParams = array_replace_recursive($requestParams, [$varName => current($expandedValue)]); } } From bd2d1934572c4291e99725eb2762f8fc077cab78 Mon Sep 17 00:00:00 2001 From: Patrik Fuhrmann Date: Fri, 1 Dec 2023 11:57:05 +0100 Subject: [PATCH 06/15] Support Symfony 7.x --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ad6a87c..ad5e49f 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "codeception/codeception": "^5.0.8", "codeception/lib-web": "^1.0.1", "phpunit/phpunit": "^10.0", - "symfony/browser-kit": "^4.4.24 || ^5.4 || ^6.0", - "symfony/dom-crawler": "^4.4.30 || ^5.4 || ^6.0" + "symfony/browser-kit": "^4.4.24 || ^5.4 || ^6.0 || ^7.0", + "symfony/dom-crawler": "^4.4.30 || ^5.4 || ^6.0 || ^7.0" }, "require-dev": { "codeception/util-universalframework": "^1.0" From ea00f6358d2b28332214f6844522a2f3f35b8613 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Fri, 2 Feb 2024 21:33:45 +0200 Subject: [PATCH 07/15] Support PHPUnit 11 --- .github/workflows/main.yml | 4 ++-- composer.json | 2 +- tests/data/app/data.php | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7013219..5b70c6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,11 +7,11 @@ jobs: runs-on: ubuntu-latest env: - COMPOSER_ROOT_VERSION: 3.99.99 + COMPOSER_ROOT_VERSION: 4.99.99 strategy: matrix: - php: [8.1, 8.2] + php: [8.1, 8.2, 8.3] steps: - name: Checkout code diff --git a/composer.json b/composer.json index ad5e49f..9a9492c 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "ext-mbstring": "*", "codeception/codeception": "^5.0.8", "codeception/lib-web": "^1.0.1", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.0 || ^11.0", "symfony/browser-kit": "^4.4.24 || ^5.4 || ^6.0 || ^7.0", "symfony/dom-crawler": "^4.4.30 || ^5.4 || ^6.0 || ^7.0" }, diff --git a/tests/data/app/data.php b/tests/data/app/data.php index 18288ae..fcea590 100755 --- a/tests/data/app/data.php +++ b/tests/data/app/data.php @@ -30,8 +30,10 @@ public static function clean() protected static function load() { $data = file_get_contents(__DIR__.self::$filename); - $data = $data ? unserialize($data) : $data = array(); - if (!is_array($data)) $data = array(); + $data = $data ? unserialize(trim($data)) : []; + if (!is_array($data)) { + $data = []; + } return $data; } From 12dadcf658a5c33797798efe0b8123b20a8307de Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Mon, 29 Jul 2024 06:22:00 +0200 Subject: [PATCH 08/15] Declare nullable parameter types explicitly for PHP 8.4 compatibility (#70) --- src/Codeception/Constraint/Crawler.php | 4 ++-- src/Codeception/Constraint/CrawlerNot.php | 2 +- src/Codeception/Lib/InnerBrowser.php | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Codeception/Constraint/Crawler.php b/src/Codeception/Constraint/Crawler.php index 9da0d42..0b7c0fa 100644 --- a/src/Codeception/Constraint/Crawler.php +++ b/src/Codeception/Constraint/Crawler.php @@ -42,7 +42,7 @@ protected function matches($nodes): bool * @param string $selector * @param ComparisonFailure|null $comparisonFailure */ - protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never + protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never { if (!$nodes->count()) { throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath'); @@ -77,7 +77,7 @@ protected function failureDescription($other): string return $description; } - protected function nodesList(SymfonyDomCrawler $domCrawler, string $contains = null): string + protected function nodesList(SymfonyDomCrawler $domCrawler, ?string $contains = null): string { $output = ''; foreach ($domCrawler as $node) { diff --git a/src/Codeception/Constraint/CrawlerNot.php b/src/Codeception/Constraint/CrawlerNot.php index 0333f52..37e5765 100644 --- a/src/Codeception/Constraint/CrawlerNot.php +++ b/src/Codeception/Constraint/CrawlerNot.php @@ -24,7 +24,7 @@ protected function matches($nodes): bool * @param string $selector * @param ComparisonFailure|null $comparisonFailure */ - protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never + protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never { if (!$this->string) { throw new ExpectationFailedException( diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index f124345..25cc57e 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -156,7 +156,7 @@ public function _request( array $parameters = [], array $files = [], array $server = [], - string $content = null + ?string $content = null ): ?string { $this->clientRequest($method, $uri, $parameters, $files, $server, $content); return $this->_getResponseContent(); @@ -189,7 +189,7 @@ protected function clientRequest( array $parameters = [], array $files = [], array $server = [], - string $content = null, + ?string $content = null, bool $changeHistory = true ): SymfonyCrawler { $this->debugSection("Request Headers", $this->headers); @@ -280,7 +280,7 @@ public function _loadPage( array $parameters = [], array $files = [], array $server = [], - string $content = null + ?string $content = null ): void { $this->crawler = $this->clientRequest($method, $uri, $parameters, $files, $server, $content); $this->baseUrl = $this->retrieveBaseUrl(); @@ -562,7 +562,7 @@ public function dontSeeInSource(string $raw): void $this->assertPageSourceNotContains($raw); } - public function seeLink(string $text, string $url = null): void + public function seeLink(string $text, ?string $url = null): void { $crawler = $this->getCrawler()->selectLink($text); if ($crawler->count() === 0) { @@ -633,7 +633,7 @@ public function dontSeeCurrentUrlMatches(string $uri): void $this->assertNotRegExp($uri, $this->_getCurrentUri()); } - public function grabFromCurrentUrl(string $uri = null): mixed + public function grabFromCurrentUrl(?string $uri = null): mixed { if (!$uri) { return $this->_getCurrentUri(); @@ -892,7 +892,7 @@ protected function setCheckboxBoolValues(Crawler $form, array $params): array * form * @param string|null $button the name of a submit button in the form */ - protected function proceedSubmitForm(Crawler $frmCrawl, array $params, string $button = null): void + protected function proceedSubmitForm(Crawler $frmCrawl, array $params, ?string $button = null): void { $url = null; $form = $this->getFormFor($frmCrawl); @@ -939,7 +939,7 @@ protected function proceedSubmitForm(Crawler $frmCrawl, array $params, string $b $this->forms = []; } - public function submitForm($selector, array $params, string $button = null): void + public function submitForm($selector, array $params, ?string $button = null): void { $form = $this->match($selector)->first(); if (count($form) === 0) { @@ -1374,7 +1374,7 @@ protected function debugResponse($url): void $this->debugSection('Response Headers', $this->getRunningClient()->getInternalResponse()->getHeaders()); } - public function makeHtmlSnapshot(string $name = null): void + public function makeHtmlSnapshot(?string $name = null): void { if (empty($name)) { $name = uniqid(date("Y-m-d_H-i-s_"), true); @@ -1487,7 +1487,7 @@ public function grabAttributeFrom($cssOrXpath, string $attribute): mixed return $nodes->first()->attr($attribute); } - public function grabMultiple($cssOrXpath, string $attribute = null): array + public function grabMultiple($cssOrXpath, ?string $attribute = null): array { $result = []; $nodes = $this->match($cssOrXpath); From 66f06c9c627b00193f58de97d02cb7e1f83f91ae Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 29 Jul 2024 06:24:03 +0200 Subject: [PATCH 09/15] Update InnerBrowser.php: Deprecate `deleteHeader` in favor of `unsetHeader` (#69) --- src/Codeception/Lib/InnerBrowser.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index 25cc57e..b07ed72 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -365,8 +365,8 @@ public function haveHttpHeader(string $name, string $value): void } /** - * Deletes the header with the passed name. Subsequent requests - * will not have the deleted header in its request. + * Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), + * so that subsequent requests will not send it anymore. * * Example: * ```php @@ -374,18 +374,26 @@ public function haveHttpHeader(string $name, string $value): void * $I->haveHttpHeader('X-Requested-With', 'Codeception'); * $I->amOnPage('test-headers.php'); * // ... - * $I->deleteHeader('X-Requested-With'); + * $I->unsetHeader('X-Requested-With'); * $I->amOnPage('some-other-page.php'); * ``` * - * @param string $name the name of the header to delete. + * @param string $name the name of the header to unset. */ - public function deleteHeader(string $name): void + public function unsetHeader(string $name): void { $name = implode('-', array_map('ucfirst', explode('-', strtolower(str_replace('_', '-', $name))))); unset($this->headers[$name]); } + /** + * @deprecated Use [unsetHttpHeader](#unsetHttpHeader) instead + */ + public function deleteHeader(string $name): void + { + $this->unsetHttpHeader($name); + } + public function amOnPage(string $page): void { $this->_loadPage('GET', $page); From 726acf63aa612710464a7f3b5188cdc3b981b462 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis <395992+Naktibalda@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:09:07 +0300 Subject: [PATCH 10/15] Fix name of unsetHttpHeader method The method below was calling unsetHttpHeader and failing --- src/Codeception/Lib/InnerBrowser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index b07ed72..20cd4f9 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -380,7 +380,7 @@ public function haveHttpHeader(string $name, string $value): void * * @param string $name the name of the header to unset. */ - public function unsetHeader(string $name): void + public function unsetHttpHeader(string $name): void { $name = implode('-', array_map('ucfirst', explode('-', strtolower(str_replace('_', '-', $name))))); unset($this->headers[$name]); From 112e44f6c2bbcc74a7f04f47151e1fac8cb24501 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 11 Nov 2024 07:57:07 +0100 Subject: [PATCH 11/15] Test against PHP 8.4 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b70c6c..4312041 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: [8.1, 8.2, 8.3] + php: [8.1, 8.2, 8.3, 8.4] steps: - name: Checkout code From 9243aed5c9e415c2783b00de68d7006d9932b022 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 11 Nov 2024 07:57:20 +0100 Subject: [PATCH 12/15] Bump actions/checkout dependency --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4312041..f19b0fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 From 2d9a35f9131a7642ee9474427250b256fa362b89 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 11 Nov 2024 07:58:10 +0100 Subject: [PATCH 13/15] PHP 8.4: Do not use deprecated constant E_STRICT --- tests/unit.suite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml index 5399cf4..1c448f5 100644 --- a/tests/unit.suite.yml +++ b/tests/unit.suite.yml @@ -1,5 +1,5 @@ # Codeception Test Suite Configuration # suite for unit (internal) tests. -error_level: "E_ALL | E_STRICT" +error_level: "E_ALL" class_name: UnitTester From ecfff3a75c604b9bb2b29c530affd63891127506 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sun, 9 Feb 2025 19:04:16 +0100 Subject: [PATCH 14/15] Support PHPUnit 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9a9492c..b4955aa 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "ext-mbstring": "*", "codeception/codeception": "^5.0.8", "codeception/lib-web": "^1.0.1", - "phpunit/phpunit": "^10.0 || ^11.0", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", "symfony/browser-kit": "^4.4.24 || ^5.4 || ^6.0 || ^7.0", "symfony/dom-crawler": "^4.4.30 || ^5.4 || ^6.0 || ^7.0" }, From cf2ddaae5e07eb3cceb504d93bd95f4a2d892dab Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Thu, 23 Oct 2025 07:52:19 +0200 Subject: [PATCH 15/15] Chore: allow codeception/lib-web v2 (#80) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b4955aa..9593f13 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ext-json": "*", "ext-mbstring": "*", "codeception/codeception": "^5.0.8", - "codeception/lib-web": "^1.0.1", + "codeception/lib-web": "^1.0.1 || ^2", "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", "symfony/browser-kit": "^4.4.24 || ^5.4 || ^6.0 || ^7.0", "symfony/dom-crawler": "^4.4.30 || ^5.4 || ^6.0 || ^7.0"