Skip to content

Commit

Permalink
Add assertIndeterminate assertion for checkbox. (#986)
Browse files Browse the repository at this point in the history
* Add `assertIndeterminate` assertion for checkbox.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Update MakesAssertions.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
crynobone and taylorotwell authored Jul 11, 2022
1 parent f8ef634 commit b4632b7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Concerns/MakesAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,26 @@ public function assertNotChecked($field, $value = null)
return $this;
}

/**
* Assert that the given checkbox is in an indeterminate state.
*
* @param string $field
* @param string|null $value
* @return $this
*/
public function assertIndeterminate($field, $value = null)
{
$this->assertNotChecked($field, $value);

PHPUnit::assertSame(
'true',
$this->resolver->findOrFail($field)->getAttribute('indeterminate'),
"Checkbox [{$field}] was not in indeterminate state."
);

return $this;
}

/**
* Assert that the given radio field is selected.
*
Expand Down

0 comments on commit b4632b7

Please sign in to comment.