|  | 
| 7 | 7 | use Codeception\Lib\Framework; | 
| 8 | 8 | use Codeception\Test\Unit; | 
| 9 | 9 | use PHPUnit\Framework\AssertionFailedError; | 
|  | 10 | +use PHPUnit\Framework\ExpectationFailedException; | 
| 10 | 11 | 
 | 
| 11 | 12 | /** | 
| 12 | 13 |  * Author: davert | 
| @@ -480,22 +481,36 @@ public function testFileFieldByLabel() | 
| 480 | 481 |         $this->assertNotEmpty(data::get('files')); | 
| 481 | 482 |     } | 
| 482 | 483 | 
 | 
| 483 |  | -    public function testSeeCheckboxIsNotChecked() | 
| 484 |  | -    { | 
| 485 |  | -        $this->module->amOnPage('/form/checkbox'); | 
| 486 |  | -        $this->module->dontSeeCheckboxIsChecked('#checkin'); | 
| 487 |  | -        $this->module->dontSeeCheckboxIsChecked(['css' => '#checkin']); | 
| 488 |  | -        $this->module->dontSeeCheckboxIsChecked('I Agree'); | 
|  | 484 | +    public function checkBoxes(): iterable { | 
|  | 485 | +        yield ['/form/checkbox_checked', ['css' => "#checkedbox1"], true]; | 
|  | 486 | +        yield ['/form/checkbox_checked', ['css' => "#checkedbox2"], true]; | 
|  | 487 | +        yield ['/form/checkbox', '#checkin', false]; | 
|  | 488 | +        yield ['/form/checkbox', ['css' => '#checkin'], false]; | 
|  | 489 | +        yield ['/form/checkbox', 'I Agree', false]; | 
|  | 490 | +        yield ['/info', 'input[type=checkbox]', true]; | 
|  | 491 | +        yield ['/info', ['css' => 'input[type=checkbox]'], true]; | 
|  | 492 | +        yield ['/info', 'Checked', true]; | 
| 489 | 493 |     } | 
| 490 | 494 | 
 | 
| 491 |  | -    public function testSeeCheckboxChecked() | 
|  | 495 | +    #[\Codeception\Attribute\DataProvider('checkBoxes')] | 
|  | 496 | +    public function testSeeCheckboxIsNotChecked(string $page, string|array $selector, bool $checked): void | 
| 492 | 497 |     { | 
| 493 |  | -        $this->module->amOnPage('/info'); | 
| 494 |  | -        $this->module->seeCheckboxIsChecked('input[type=checkbox]'); | 
| 495 |  | -        $this->module->seeCheckboxIsChecked(['css' => 'input[type=checkbox]']); | 
| 496 |  | -        $this->module->seeCheckboxIsChecked('Checked'); | 
|  | 498 | +        $this->module->amOnPage($page); | 
|  | 499 | +        if ($checked) { | 
|  | 500 | +            $this->expectException(ExpectationFailedException::class); | 
|  | 501 | +        } | 
|  | 502 | +        $this->module->dontSeeCheckboxIsChecked($selector); | 
| 497 | 503 |     } | 
| 498 | 504 | 
 | 
|  | 505 | +    #[\Codeception\Attribute\DataProvider('checkBoxes')] | 
|  | 506 | +    public function testSeeCheckboxIsChecked(string $page, string|array $selector, bool $checked): void | 
|  | 507 | +    { | 
|  | 508 | +        $this->module->amOnPage($page); | 
|  | 509 | +        if (!$checked) { | 
|  | 510 | +            $this->expectException(ExpectationFailedException::class); | 
|  | 511 | +        } | 
|  | 512 | +        $this->module->seeCheckboxIsChecked($selector); | 
|  | 513 | +    } | 
| 499 | 514 |     public function testSeeWithNonLatin() | 
| 500 | 515 |     { | 
| 501 | 516 |         $this->module->amOnPage('/info'); | 
|  | 
0 commit comments