These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\BehatBundle\Features\Context\SubContext; |
||
4 | |||
5 | use Behat\Behat\Context\BehatContext; |
||
6 | use Behat\Mink\Exception\ElementNotFoundException; |
||
7 | |||
8 | class RadioButtonSubContext extends BehatContext |
||
9 | { |
||
10 | /** |
||
11 | * Initializes context. |
||
12 | * Every scenario gets it's own context object. |
||
13 | * |
||
14 | * @param array $parameters context parameters |
||
15 | */ |
||
16 | public function __construct(array $parameters) |
||
17 | { |
||
18 | |||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Get Mink session from MinkContext |
||
23 | */ |
||
24 | public function getSession($name = null) |
||
0 ignored issues
–
show
|
|||
25 | { |
||
26 | return $this->getMainContext()->getSession($name); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $radioLabel |
||
31 | * |
||
32 | * @throws ElementNotFoundException |
||
33 | * @return void |
||
34 | * @Given /^I select the "([^"]*)" radio button$/ |
||
35 | */ |
||
36 | public function iSelectTheRadioButton($radioLabel) |
||
37 | { |
||
38 | $radioButton = $this->getSession()->getPage()->findField($radioLabel); |
||
39 | if (null === $radioButton) { |
||
40 | throw new ElementNotFoundException($this->getSession(), 'form field', 'id|name|label|value', $radioLabel); |
||
41 | } |
||
42 | $this->getSession()->getDriver()->click($radioButton->getXPath()); |
||
43 | } |
||
44 | } |
||
45 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.