Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attribute does not contain assertion #1072

Merged
merged 2 commits into from
Dec 5, 2023
Merged

Add attribute does not contain assertion #1072

merged 2 commits into from
Dec 5, 2023

Conversation

ziadoz
Copy link
Contributor

@ziadoz ziadoz commented Dec 5, 2023

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
22 checks passed
@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