1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ScenarioStateBehatExtension project. |
5
|
|
|
* |
6
|
|
|
* (c) Rodrigue Villetard <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Gorghoa\ScenarioStateBehatExtension\Annotation\ScenarioStateArgument; |
13
|
|
|
use Gorghoa\ScenarioStateBehatExtension\Context\ScenarioStateAwareContext; |
14
|
|
|
use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface; |
15
|
|
|
use Gorghoa\ScenarioStateBehatExtension\TestApp\Gorilla; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Rodrigue Villetard <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class FeatureContext implements ScenarioStateAwareContext |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @beforeSuite |
24
|
|
|
*/ |
25
|
|
|
public static function setUpSuite() |
26
|
|
|
{ |
27
|
|
|
require_once __DIR__.'/../../autoload.php'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var ScenarioStateInterface |
32
|
|
|
*/ |
33
|
|
|
private $scenarioState; |
34
|
|
|
|
35
|
|
|
public function setScenarioState(ScenarioStateInterface $scenarioState) |
36
|
|
|
{ |
37
|
|
|
$this->scenarioState = $scenarioState; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @When the bonobo takes a banana |
42
|
|
|
*/ |
43
|
|
|
public function takeBanana() |
44
|
|
|
{ |
45
|
|
|
$this->scenarioState->provideStateFragment('scenarioBanana', 'Yammy Banana'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @When gives this banana to gorilla |
50
|
|
|
* |
51
|
|
|
* @ScenarioStateArgument("scenarioBanana") |
52
|
|
|
* |
53
|
|
|
* @param string $scenarioBanana |
54
|
|
|
*/ |
55
|
|
|
public function giveBananaToGorilla($scenarioBanana) |
56
|
|
|
{ |
57
|
|
|
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, 'Yammy Banana'); |
58
|
|
|
$gorilla = new Gorilla(); |
59
|
|
|
$gorilla->setBanana($scenarioBanana); |
60
|
|
|
$this->scenarioState->provideStateFragment('scenarioGorilla', $gorilla); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @Then the gorilla has the banana |
65
|
|
|
* |
66
|
|
|
* @ScenarioStateArgument("scenarioBanana") |
67
|
|
|
* @ScenarioStateArgument(name="scenarioGorilla", argument="gorilla") |
68
|
|
|
* |
69
|
|
|
* @param string $scenarioBanana |
70
|
|
|
* @param Gorilla $gorilla |
71
|
|
|
*/ |
72
|
|
|
public function gorillaHasBanana($scenarioBanana, Gorilla $gorilla) |
73
|
|
|
{ |
74
|
|
|
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, 'Yammy Banana'); |
75
|
|
|
\PHPUnit_Framework_Assert::assertEquals($gorilla->getBanana(), 'Yammy Banana'); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|