Skip to content

Commit 04c27d5

Browse files
Merge branch '5.4' into 6.2
* 5.4: [FrameworkBundle] Improve error message in MicroKernelTrait when using deprecated configureRoutes(RouteCollectionBuilder) with symfony/routing >= 6.0 Add warning about Symfony 5.2 changing pcntl_async_signals [Tests] Fix static calls and Mock var annotation [FrameworkBundle] Fix checkboxes check assertions [Notifier][WebProfilerBundle] Ignore messages whose `getNotification` returns `null` [HttpClient] Fix over-encoding of URL parts to match browser's behavior Fix Psalm job [HttpClient] Fix data collector [Tests] Migrate tests to static data providers [Semaphore] Fix test Fix: Split and clean up tests Remove unused data provider add Sender to the list of bypassed headers
2 parents 1fc7526 + 3265f88 commit 04c27d5

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

Test/DomCrawlerAssertionsTrait.php

Lines changed: 2 additions & 9 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,18 +86,12 @@ 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
{
98-
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
99-
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
100-
new LogicalNot(new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked'))
101-
), $message);
94+
self::assertThat(self::getCrawler(), new LogicalNot(new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked")), $message);
10295
}
10396

10497
public static function assertFormValue(string $formSelector, string $fieldName, string $value, string $message = ''): void

Tests/Test/WebTestCaseTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,18 @@ public function testAssertInputValueNotSame()
233233
public function testAssertCheckboxChecked()
234234
{
235235
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe');
236+
$this->getCrawlerTester(new Crawler('<!DOCTYPE html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe');
236237
$this->expectException(AssertionFailedError::class);
237-
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and has a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".');
238+
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]:checked".');
238239
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxChecked('rememberMe');
239240
}
240241

241242
public function testAssertCheckboxNotChecked()
242243
{
243244
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe');
245+
$this->getCrawlerTester(new Crawler('<!DOCTYPE html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe');
244246
$this->expectException(AssertionFailedError::class);
245-
$this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and does not have a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".');
247+
$this->expectExceptionMessage('does not match selector "input[name="rememberMe"]:checked".');
246248
$this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxNotChecked('rememberMe');
247249
}
248250

0 commit comments

Comments
 (0)