Skip to content

Commit 573cead

Browse files
authored
Merge pull request #138 from devinfd/patch-1
Add assertions for radio selection
2 parents 59a8f8f + 57054ae commit 573cead

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/Concerns/MakesAssertions.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,44 @@ public function assertNotChecked($field, $value = null)
351351

352352
return $this;
353353
}
354+
355+
/**
356+
* Assert that the given radio field is selected.
357+
*
358+
* @param string $field
359+
* @param string $value
360+
* @return $this
361+
*/
362+
function assertRadioSelected($field, $value)
363+
{
364+
$element = $this->resolver->resolveForRadioSelection($field, $value);
365+
366+
PHPUnit::assertTrue(
367+
$element->isSelected(),
368+
"Expected radio [{$field}] to be selected, but it wasn't."
369+
);
370+
371+
return $this;
372+
}
373+
374+
/**
375+
* Assert that the given radio field is not selected.
376+
*
377+
* @param string $field
378+
* @param string $value
379+
* @return $this
380+
*/
381+
public function assertRadioNotSelected($field, $value = null)
382+
{
383+
$element = $this->resolver->resolveForRadioSelection($field, $value);
384+
385+
PHPUnit::assertFalse(
386+
$element->isSelected(),
387+
"Radio [{$field}] was unexpectedly selected."
388+
);
389+
390+
return $this;
391+
}
354392

355393
/**
356394
* Assert that the given select field has the given value selected.

0 commit comments

Comments
 (0)