From 47434eaaa0cd809e33579ca4a45a727b8ab5b48d Mon Sep 17 00:00:00 2001 From: Jacco Broeren Date: Mon, 6 Jan 2025 10:19:50 +0100 Subject: [PATCH 1/5] Update MakesAssertions.php --- src/Concerns/MakesAssertions.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Concerns/MakesAssertions.php b/src/Concerns/MakesAssertions.php index 9d348586d..6c420bdb7 100644 --- a/src/Concerns/MakesAssertions.php +++ b/src/Concerns/MakesAssertions.php @@ -799,14 +799,11 @@ public function assertAttributeMissing($selector, $attribute) */ public function assertAttributeContains($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::assertStringContainsString( $value, @@ -831,11 +828,6 @@ public function assertAttributeDoesntContain($selector, $attribute, $value) $actual = $this->resolver->findOrFail($selector)->getAttribute($attribute); - PHPUnit::assertNotNull( - $actual, - "Did not see expected attribute [{$attribute}] within element [{$fullSelector}]." - ); - PHPUnit::assertStringNotContainsString( $value, $actual, From 3f5ac9025f1dc4330f6a049804341b9e9de6a17b Mon Sep 17 00:00:00 2001 From: Jacco Broeren Date: Mon, 6 Jan 2025 10:32:16 +0100 Subject: [PATCH 2/5] Update MakesAssertions.php revert changes on wrong place and add correct changes --- src/Concerns/MakesAssertions.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Concerns/MakesAssertions.php b/src/Concerns/MakesAssertions.php index 6c420bdb7..801710c44 100644 --- a/src/Concerns/MakesAssertions.php +++ b/src/Concerns/MakesAssertions.php @@ -799,11 +799,14 @@ public function assertAttributeMissing($selector, $attribute) */ public function assertAttributeContains($selector, $attribute, $value) { + $fullSelector = $this->resolver->format($selector); + $actual = $this->resolver->findOrFail($selector)->getAttribute($attribute); - if (is_null($actual)) { - return $this; - } + PHPUnit::assertNotNull( + $actual, + "Did not see expected attribute [{$attribute}] within element [{$fullSelector}]." + ); PHPUnit::assertStringContainsString( $value, @@ -824,10 +827,12 @@ public function assertAttributeContains($selector, $attribute, $value) */ public function assertAttributeDoesntContain($selector, $attribute, $value) { - $fullSelector = $this->resolver->format($selector); - $actual = $this->resolver->findOrFail($selector)->getAttribute($attribute); + if (is_null($actual)) { + return $this; + } + PHPUnit::assertStringNotContainsString( $value, $actual, From 94e1517963c9bb5d453625a7861c7299886fd59c Mon Sep 17 00:00:00 2001 From: Jacco Broeren Date: Mon, 6 Jan 2025 10:33:03 +0100 Subject: [PATCH 3/5] Update MakesAssertions.php remove whitespace --- src/Concerns/MakesAssertions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Concerns/MakesAssertions.php b/src/Concerns/MakesAssertions.php index 801710c44..58ed51bf6 100644 --- a/src/Concerns/MakesAssertions.php +++ b/src/Concerns/MakesAssertions.php @@ -800,7 +800,7 @@ public function assertAttributeMissing($selector, $attribute) public function assertAttributeContains($selector, $attribute, $value) { $fullSelector = $this->resolver->format($selector); - + $actual = $this->resolver->findOrFail($selector)->getAttribute($attribute); PHPUnit::assertNotNull( From e7cc02e1ca7e290229c3f58c70b22a68f64979fe Mon Sep 17 00:00:00 2001 From: Jacco Broeren Date: Mon, 6 Jan 2025 10:43:34 +0100 Subject: [PATCH 4/5] Update MakesAssertionsTest.php Update test_assert_attribute_does_not_contain to reflect new behaviour. --- tests/Unit/MakesAssertionsTest.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/Unit/MakesAssertionsTest.php b/tests/Unit/MakesAssertionsTest.php index 3160ffd43..ebea4026a 100644 --- a/tests/Unit/MakesAssertionsTest.php +++ b/tests/Unit/MakesAssertionsTest.php @@ -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'); From 5e96a568193d5ee49b04b786847458ea51b35045 Mon Sep 17 00:00:00 2001 From: Jacco Broeren Date: Mon, 6 Jan 2025 12:48:57 +0100 Subject: [PATCH 5/5] Update MakesAssertions.php remove whitespace --- src/Concerns/MakesAssertions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Concerns/MakesAssertions.php b/src/Concerns/MakesAssertions.php index 58ed51bf6..0ca2ff633 100644 --- a/src/Concerns/MakesAssertions.php +++ b/src/Concerns/MakesAssertions.php @@ -832,7 +832,7 @@ public function assertAttributeDoesntContain($selector, $attribute, $value) if (is_null($actual)) { return $this; } - + PHPUnit::assertStringNotContainsString( $value, $actual,