Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c852207

Browse filesBrowse files
committed
Fix checkboxes check assertions
1 parent 7616c8d commit c852207
Copy full SHA for c852207

File tree

2 files changed

+4
-8
lines changed
Filter options

2 files changed

+4
-8
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Test/DomCrawlerAssertionsTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Test/DomCrawlerAssertionsTrait.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPUnit\Framework\Constraint\LogicalNot;
1616
use Symfony\Component\DomCrawler\Crawler;
1717
use Symfony\Component\DomCrawler\Test\Constraint as DomCrawlerConstraint;
18-
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorAttributeValueSame;
1918
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorExists;
2019

2120
/**
@@ -87,17 +86,14 @@ public static function assertInputValueNotSame(string $fieldName, string $expect
8786

8887
public static function assertCheckboxChecked(string $fieldName, string $message = ''): void
8988
{
90-
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
91-
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
92-
new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked')
93-
), $message);
89+
self::assertThat(self::getCrawler(), new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked"), $message);
9490
}
9591

9692
public static function assertCheckboxNotChecked(string $fieldName, string $message = ''): void
9793
{
9894
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
9995
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
100-
new LogicalNot(new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked'))
96+
new LogicalNot(new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked"))
10197
), $message);
10298
}
10399

‎src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ public function testAssertCheckboxChecked()
239239
{
240240
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe');
241241
$this->expectException(AssertionFailedError::class);
242-
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and has a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".');
242+
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]:checked".');
243243
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxChecked('rememberMe');
244244
}
245245

246246
public function testAssertCheckboxNotChecked()
247247
{
248248
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe');
249249
$this->expectException(AssertionFailedError::class);
250-
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and does not have a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".');
250+
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and does not match selector "input[name="rememberMe"]:checked".');
251251
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxNotChecked('rememberMe');
252252
}
253253

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.