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

assertChecked and assertNotChecked on Symfony ChoiceType #100

Open
Chris53897 opened this issue Aug 19, 2022 · 2 comments
Open

assertChecked and assertNotChecked on Symfony ChoiceType #100

Chris53897 opened this issue Aug 19, 2022 · 2 comments

Comments

@Chris53897
Copy link
Contributor

Chris53897 commented Aug 19, 2022

I have a ChoiceType in Symfony.

->add('assignedRoles', ChoiceType::class, [
                'expanded' => true, 
                'multiple' => true, 
                'choices' => $this->allRoles,
                'choice_label' => function ($item) { return 'system.role.'.str_replace("role_","", strtolower($item)); },
                'choice_value' => function ($item) { return $item; }
 ])

HTML (github has problems with < and >)

<input type="checkbox" id="user_edit_form_assignedRoles_3" name="user_edit_form[assignedRoles][]" class="form-check-input" value="bar" />
<label class="form-check-label" for="user_edit_form_assignedRoles_3">bar</label>

<input type="checkbox" id="user_edit_form_assignedRoles_4" name="user_edit_form[assignedRoles][]" class="form-check-input" value="bar" />
<label class="form-check-label" for="user_edit_form_assignedRoles_4">foo</label>

Check/Uncheck of Checkboxes is working
->checkField('foo')
->uncheckField('foo')

But ->assertChecked('bar') is always true. But it is not checked.
->assertNotChecked('bar') fails too.

Am i doing something wrong?
I tried the assertNotSelected() function as well.
->assertNotSelected('user_edit_form[assignedRoles][]', 'foo')

@kbond
Copy link
Member

kbond commented Aug 19, 2022

Strange. I wonder if it has something to do with the nested nature of your expanded checkbox list (I don't believe the tests cover this specific scenario). Are you using PantherBrowser or KernelBrowser.

(I updated your description to improve readability)

@Chris53897
Copy link
Contributor Author

I am using the PantherBrowser. I will search if Mink (Behat\Mink\WebAssert) has a function for that Use-Case.
Maybe this Repo can add a function to it, if i found a solution.
But that has not a top priority for now for me. I need to write tests for the whole App first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants