diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3be8e8..c30679d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,9 @@ jobs: tests: runs-on: ubuntu-latest + env: + COMPOSER_ROOT_VERSION: 3.99.99 + strategy: matrix: php: [8.0, 8.1] diff --git a/composer.json b/composer.json index ab85e96..3702621 100644 --- a/composer.json +++ b/composer.json @@ -22,18 +22,16 @@ "ext-dom": "*", "ext-json": "*", "ext-mbstring": "*", - "codeception/codeception": "*@dev", + "codeception/codeception": "^5.0", "codeception/lib-web": "^1.0.1", + "phpunit/phpunit": "^9.5", "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" }, - "conflict": { - "codeception/codeception": "<5.0.0-alpha3" - }, - "minimum-stability": "dev", + "minimum-stability": "RC", "autoload": { "classmap": [ "src/" diff --git a/readme.md b/readme.md index 81474bd..7154eed 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ Parent library for all Codeception framework modules and PhpBrowser. ## Requirements -* `PHP 7.4` or higher. +* `PHP 8.0` or higher. ## Installation diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index 71e008b..7d80e37 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -655,13 +655,13 @@ public function grabFromCurrentUrl(string $uri = null): mixed public function seeCheckboxIsChecked($checkbox): void { $checkboxes = $this->getFieldsByLabelOrCss($checkbox); - $this->assertDomContains($checkboxes->filter('input[checked=checked]'), 'checkbox'); + $this->assertGreaterThan(0, $checkboxes->filter('input[checked]')->count()); } public function dontSeeCheckboxIsChecked($checkbox): void { $checkboxes = $this->getFieldsByLabelOrCss($checkbox); - $this->assertSame(0, $checkboxes->filter('input[checked=checked]')->count()); + $this->assertSame(0, $checkboxes->filter('input[checked]')->count()); } public function seeInField($field, $value): void diff --git a/tests/data/app/view/form/checkbox_checked.php b/tests/data/app/view/form/checkbox_checked.php new file mode 100755 index 0000000..082a567 --- /dev/null +++ b/tests/data/app/view/form/checkbox_checked.php @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/unit/Codeception/Module/FrameworksTest.php b/tests/unit/Codeception/Module/FrameworksTest.php index d00c01d..a1e0ec1 100644 --- a/tests/unit/Codeception/Module/FrameworksTest.php +++ b/tests/unit/Codeception/Module/FrameworksTest.php @@ -94,13 +94,13 @@ public function testCreateSnapshotOnFail() $container = Stub::make(ModuleContainer::class); $module = Stub::construct($this->module::class, [$container], [ '_savePageSource' => Stub\Expected::once(function ($filename) { - $this->assertSame(codecept_log_dir('Codeception.Module.UniversalFramework.looks.like..test.fail.html'), $filename); + $this->assertSame(codecept_log_dir('Codeception.Module.UniversalFramework.useUniversalFramework.fail.html'), $filename); }), ]); $module->_initialize(); $module->amOnPage('/'); - $cest = new \Codeception\Test\Cest($this->module, 'looks:like::test', 'demo1Cest.php'); + $cest = new \Codeception\Test\Cest($this->module, 'useUniversalFramework', 'demo1Cest.php'); $module->_failed($cest, new \PHPUnit\Framework\AssertionFailedError()); } } diff --git a/tests/unit/Codeception/Module/TestsForWeb.php b/tests/unit/Codeception/Module/TestsForWeb.php index 0bab4ad..10a3868 100644 --- a/tests/unit/Codeception/Module/TestsForWeb.php +++ b/tests/unit/Codeception/Module/TestsForWeb.php @@ -7,6 +7,7 @@ use Codeception\Lib\Framework; use Codeception\Test\Unit; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\ExpectationFailedException; /** * Author: davert @@ -480,22 +481,36 @@ public function testFileFieldByLabel() $this->assertNotEmpty(data::get('files')); } - public function testSeeCheckboxIsNotChecked() - { - $this->module->amOnPage('/form/checkbox'); - $this->module->dontSeeCheckboxIsChecked('#checkin'); - $this->module->dontSeeCheckboxIsChecked(['css' => '#checkin']); - $this->module->dontSeeCheckboxIsChecked('I Agree'); + public function checkBoxes(): iterable { + yield ['/form/checkbox_checked', ['css' => "#checkedbox1"], true]; + yield ['/form/checkbox_checked', ['css' => "#checkedbox2"], true]; + yield ['/form/checkbox', '#checkin', false]; + yield ['/form/checkbox', ['css' => '#checkin'], false]; + yield ['/form/checkbox', 'I Agree', false]; + yield ['/info', 'input[type=checkbox]', true]; + yield ['/info', ['css' => 'input[type=checkbox]'], true]; + yield ['/info', 'Checked', true]; } - public function testSeeCheckboxChecked() + #[\Codeception\Attribute\DataProvider('checkBoxes')] + public function testSeeCheckboxIsNotChecked(string $page, string|array $selector, bool $checked): void { - $this->module->amOnPage('/info'); - $this->module->seeCheckboxIsChecked('input[type=checkbox]'); - $this->module->seeCheckboxIsChecked(['css' => 'input[type=checkbox]']); - $this->module->seeCheckboxIsChecked('Checked'); + $this->module->amOnPage($page); + if ($checked) { + $this->expectException(ExpectationFailedException::class); + } + $this->module->dontSeeCheckboxIsChecked($selector); } + #[\Codeception\Attribute\DataProvider('checkBoxes')] + public function testSeeCheckboxIsChecked(string $page, string|array $selector, bool $checked): void + { + $this->module->amOnPage($page); + if (!$checked) { + $this->expectException(ExpectationFailedException::class); + } + $this->module->seeCheckboxIsChecked($selector); + } public function testSeeWithNonLatin() { $this->module->amOnPage('/info');