Skip to content

Commit 8ddd53a

Browse files
authored
[8.x] Behaviour change on assertAttributeDoesntContain (#1154)
* Update MakesAssertions.php * Update MakesAssertions.php revert changes on wrong place and add correct changes * Update MakesAssertions.php remove whitespace * Update MakesAssertionsTest.php Update test_assert_attribute_does_not_contain to reflect new behaviour. * Update MakesAssertions.php remove whitespace
1 parent 204151b commit 8ddd53a

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/Concerns/MakesAssertions.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -827,14 +827,11 @@ public function assertAttributeContains($selector, $attribute, $value)
827827
*/
828828
public function assertAttributeDoesntContain($selector, $attribute, $value)
829829
{
830-
$fullSelector = $this->resolver->format($selector);
831-
832830
$actual = $this->resolver->findOrFail($selector)->getAttribute($attribute);
833831

834-
PHPUnit::assertNotNull(
835-
$actual,
836-
"Did not see expected attribute [{$attribute}] within element [{$fullSelector}]."
837-
);
832+
if (is_null($actual)) {
833+
return $this;
834+
}
838835

839836
PHPUnit::assertStringNotContainsString(
840837
$value,

tests/Unit/MakesAssertionsTest.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,7 @@ public function test_assert_attribute_does_not_contain()
683683

684684
$browser->assertAttributeDoesntContain('foo', 'bar', 'class-c');
685685

686-
try {
687-
$browser->assertAttributeDoesntContain('foo', 'bar', 'class-c');
688-
$this->fail();
689-
} catch (ExpectationFailedException $e) {
690-
$this->assertStringContainsString(
691-
'Did not see expected attribute [bar] within element [Foo].',
692-
$e->getMessage()
693-
);
694-
}
686+
$browser->assertAttributeDoesntContain('foo', 'bar', 'class-c');
695687

696688
try {
697689
$browser->assertAttributeDoesntContain('foo', 'bar', 'class-1');

0 commit comments

Comments
 (0)