Skip to content

Add attribute does not contain assertion#1072

Merged
taylorotwell merged 2 commits into
laravel:7.xfrom
ziadoz:assert-attr-negative
Dec 5, 2023
Merged

Add attribute does not contain assertion#1072
taylorotwell merged 2 commits into
laravel:7.xfrom
ziadoz:assert-attr-negative

Conversation

@ziadoz

@ziadoz ziadoz commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

I've found I sometimes need the opposite of assertAttributeContains() in tests.

For example, I've often got elements where Bootstrap classes are being toggled in JS:

<ul class="list-inline">
    <li class="list-inline-item main d-none">Foo</li>
    <li class="list-inline-item sub">Bar</li>
</ul>

Currently I have to assert all the classes on the second <li>, even though I'm only interested in d-none:

$browser->assertAttributeContains('li:nth-child(1)', 'class', 'd-none');
$browser->assertAttribute('li:nth-child(2)', 'class', 'list-inline-item sub');

After this PR its clearer what's being tested:

$browser->assertAttributeContains('li:nth-child(1)', 'class', 'd-none');
$browser->assertAttributeDoesNotContain('li:nth-child(2)', 'class', 'd-none');

@ziadoz ziadoz marked this pull request as ready for review December 5, 2023 09:55
@taylorotwell taylorotwell merged commit 94534fa into laravel:7.x Dec 5, 2023
@ziadoz ziadoz deleted the assert-attr-negative branch December 5, 2023 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants