public function TestSubContext::assertSeeRadioById in Panopoly 8.2
Same name and namespace in other branches
- 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::assertSeeRadioById()
Asserts the radio button option.
@Then I should see the radio button :field with the id :id @Then I should see the radio button :field
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 923 - Provide Behat step-definitions for generic Panopoly tests.
Class
- TestSubContext
- Behat sub-context for Panopoly.
Code
public function assertSeeRadioById($field, $id = FALSE) {
$escaper = new Escaper();
$element = $this
->getSession()
->getPage();
$radiobutton = $id ? $element
->findById($id) : $element
->find('named', [
'radio',
$escaper
->escapeLiteral($field),
]);
if ($radiobutton === NULL) {
throw new \Exception(sprintf('The radio button with "%s" was not found on the page %s', $id ? $id : $field, $this
->getSession()
->getCurrentUrl()));
}
if ($id) {
$value = $radiobutton
->getAttribute('value');
$labelonpage = $radiobutton
->getParent()
->getText();
if ($field != $labelonpage) {
throw new \Exception(sprintf("Button with id '%s' has label '%s' instead of '%s' on the page %s", $id, $labelonpage, $field, $this
->getSession()
->getCurrentUrl()));
}
}
}