8000 [DomCrawler] Don't pass null to trim() · symfony/symfony@51eda09 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51eda09

Browse files
committed
[DomCrawler] Don't pass null to trim()
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 2ab40fd commit 51eda09

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorAttributeValueSame.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function matches($crawler): bool
4747
return false;
4848
}
4949

50-
return $this->expectedText === trim($crawler->attr($this->attribute));
50+
return $this->expectedText === trim($crawler->attr($this->attribute) ?? '');
5151
}
5252

5353
/**

src/Symfony/Component/DomCrawler/Tests/Test/Constraint/CrawlerSelectorAttributeValueSameTest.php

Lines changed: 1 addition & 0 deletions
5043
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function testConstraint()
2323
{
2424
$constraint = new CrawlerSelectorAttributeValueSame('input[name="username"]', 'value', 'Fabien');
2525
$this->assertTrue($constraint->evaluate(new Crawler('<html><body><form><input type="text" name="username" value="Fabien">'), '', true));
26+
$this->assertFalse($constraint->evaluate(new Crawler('<html><body><form><input type="text" name="username">'), '', true));
2627
$this->assertFalse($constraint->evaluate(new Crawler('<html><head><title>Bar'), '', true));
2728

2829
try {

0 commit comments

Comments
 (0)
0