Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

Context/SubContext/RadioButtonSubContext.php (1 issue)

Upgrade to new PHP Analysis Engine

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
     * Get Mink session from MinkContext
22
     */
23
    public function getSession($name = null)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

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.

Loading history...
24
    {
25
        return $this->getMainContext()->getSession($name);
26
    }
27
28
    /**
29
     * @param string $radioLabel
30
     *
31
     * @throws ElementNotFoundException
32
     * @Given /^I select the "([^"]*)" radio button$/
33
     */
34
    public function iSelectTheRadioButton($radioLabel)
35
    {
36
        $radioButton = $this->getSession()->getPage()->findField($radioLabel);
37
        if (null === $radioButton) {
38
            throw new ElementNotFoundException($this->getSession(), 'form field', 'id|name|label|value', $radioLabel);
39
        }
40
        $this->getSession()->getDriver()->click($radioButton->getXPath());
41
    }
42
}
43