1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Behat\Sf2DemoBundle\Features\Context; |
4
|
|
|
|
5
|
|
|
use Behat\MinkExtension\Context\MinkContext; |
6
|
|
|
use Behat\Sf2DemoBundle\Service\NameService; |
7
|
|
|
use Behat\Symfony2Extension\Context\KernelAwareContext; |
8
|
|
|
use PHPUnit\Framework\Assert; |
9
|
|
|
use Symfony\Component\HttpFoundation\Session\Session; |
10
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
11
|
|
|
|
12
|
|
|
class WebContext extends MinkContext implements KernelAwareContext |
13
|
|
|
{ |
14
|
|
|
private $kernel; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var NameService |
18
|
|
|
*/ |
19
|
|
|
private $nameService; |
20
|
|
|
|
21
|
|
|
public function __construct(Session $session, $simpleParameter, $simpleArg, array $services, array $params, NameService $nameService) |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
$this->nameService = $nameService; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Sets HttpKernel instance. |
28
|
|
|
* This method will be automatically called by Symfony2Extension ContextInitializer. |
29
|
|
|
* |
30
|
|
|
* @param KernelInterface $kernel |
31
|
|
|
*/ |
32
|
|
|
public function setKernel(KernelInterface $kernel) |
33
|
|
|
{ |
34
|
|
|
$this->kernel = $kernel; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @Given I have a service set to :name |
39
|
|
|
*/ |
40
|
|
|
public function iHaveANameService($name) |
41
|
|
|
{ |
42
|
|
|
$this->nameService->setName($name); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @When make a request setting name to :name |
47
|
|
|
*/ |
48
|
|
|
public function makeARequestSettingNameTo($name) |
49
|
|
|
{ |
50
|
|
|
$this->visit('set-name/'.$name); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Then the service value should have remained :name |
55
|
|
|
* @Then the service value should have changed to :name |
56
|
|
|
*/ |
57
|
|
|
public function theServiceValueShouldRemain($name) |
58
|
|
|
{ |
59
|
|
|
Assert::assertEquals($name, $this->nameService->getName()); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.