Last active
August 29, 2015 14:23
-
-
Save HelenaEksler/ad829f4e49ee2f33f861 to your computer and use it in GitHub Desktop.
Steps for new behat version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FeatureContext extends DrupalContext implements SnippetAcceptingContext { | |
public function iCheckTheRadioButton($labelText) { | |
$page = $this->getSession()->getPage(); | |
foreach ($page->findAll('css', 'label') as $label) { | |
if ( $labelText === $label->getText() ) { | |
$radioButton = $page->find('css', '#'.$label->getAttribute('for')); | |
$value = $radioButton->getAttribute('value'); | |
$radioButton->selectOption($value, FALSE); | |
return; | |
} | |
} | |
throw new \Exception("Radio button with label {$labelText} not found"); | |
} | |
/** | |
* @Then I should see :value option in the repositories list | |
*/ | |
public function iShouldSeeOptionInTheRepositoriesList($value) { | |
$selectElement = $this->getSession()->getPage()->find('named', array('select', 'og_repo[und][0][default]')); | |
$options = $selectElement->findAll('css', 'option'); | |
foreach ($options as $option) { | |
if ($option->getText() == $value) { | |
return; | |
} | |
} | |
throw new \Exception("{$value} was not found in the repositories list"); | |
} | |
/** | |
* @Then I should not see :value option in the repositories list | |
*/ | |
public function iShouldNotSeeOptionInTheRepositoriesList($value) { | |
$selectElement = $this->getSession()->getPage()->find('named', array('select', 'og_repo[und][0][default]')); | |
$options = $selectElement->findAll('css', 'option'); | |
foreach ($options as $option) { | |
if ($option->getText() == $value) { | |
throw new \Exception("{$value} was not found in the repositories list"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment