Skip to content

Commit

Permalink
[8.x] Behaviour change on assertAttributeDoesntContain (#1154)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
F2210 authored Jan 6, 2025
1 parent 204151b commit 8ddd53a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
9 changes: 3 additions & 6 deletions src/Concerns/MakesAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,11 @@ public function assertAttributeContains($selector, $attribute, $value)
*/
public function assertAttributeDoesntContain($selector, $attribute, $value)
{
$fullSelector = $this->resolver->format($selector);

$actual = $this->resolver->findOrFail($selector)->getAttribute($attribute);

PHPUnit::assertNotNull(
$actual,
"Did not see expected attribute [{$attribute}] within element [{$fullSelector}]."
);
if (is_null($actual)) {
return $this;
}

PHPUnit::assertStringNotContainsString(
$value,
Expand Down
10 changes: 1 addition & 9 deletions tests/Unit/MakesAssertionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,7 @@ public function test_assert_attribute_does_not_contain()

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

try {
$browser->assertAttributeDoesntContain('foo', 'bar', 'class-c');
$this->fail();
} catch (ExpectationFailedException $e) {
$this->assertStringContainsString(
'Did not see expected attribute [bar] within element [Foo].',
$e->getMessage()
);
}
$browser->assertAttributeDoesntContain('foo', 'bar', 'class-c');

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

0 comments on commit 8ddd53a

Please sign in to comment.