GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#26)
by Vincent
02:12
created

FeatureContext::transformGorilla()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
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 Behat\Behat\Hook\Scope\AfterScenarioScope;
13
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
14
use Gorghoa\ScenarioStateBehatExtension\Annotation\ScenarioStateArgument;
15
use Gorghoa\ScenarioStateBehatExtension\Context\ScenarioStateAwareContext;
16
use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface;
17
use Gorghoa\ScenarioStateBehatExtension\TestApp\Gorilla;
18
19
/**
20
 * @author Rodrigue Villetard <[email protected]>
21
 */
22
class FeatureContext implements ScenarioStateAwareContext
23
{
24
    /**
25
     * @BeforeSuite
26
     */
27
    public static function setUpSuite()
28
    {
29
        require_once __DIR__.'/../../autoload.php';
30
    }
31
32
    /**
33
     * @var ScenarioStateInterface
34
     */
35
    private $scenarioState;
36
37
    /**
38
     * @param ScenarioStateInterface $scenarioState
39
     */
40
    public function setScenarioState(ScenarioStateInterface $scenarioState)
41
    {
42
        $this->scenarioState = $scenarioState;
43
    }
44
45
    /**
46
     * @BeforeScenario
47
     */
48
    public function initBananas()
49
    {
50
        $this->scenarioState->provideStateFragment('bananas', ['foo', 'bar']);
51
        $this->scenarioState->provideStateFragment('gorillaIsMale', true);
52
    }
53
54
    /**
55
     * @BeforeScenario
56
     *
57
     * @ScenarioStateArgument("bananas")
58
     *
59
     * @param array $bananas
60
     */
61
    public function saveBananasWithoutScopeBeforeScenario(array $bananas)
62
    {
63
        \PHPUnit_Framework_Assert::assertEquals(['foo', 'bar'], $bananas);
64
    }
65
66
    /**
67
     * @BeforeScenario
68
     *
69
     * @ScenarioStateArgument("bananas")
70
     *
71
     * @param BeforeScenarioScope $scope
72
     * @param array               $bananas
73
     */
74
    public function saveBananasWithScopeBeforeScenario(BeforeScenarioScope $scope, array $bananas)
75
    {
76
        \PHPUnit_Framework_Assert::assertNotNull($scope);
77
        \PHPUnit_Framework_Assert::assertEquals(['foo', 'bar'], $bananas);
78
    }
79
80
    /**
81
     * @BeforeScenario
82
     *
83
     * @param BeforeScenarioScope $scope
84
     */
85
    public function initApplesBeforeScenario(BeforeScenarioScope $scope)
86
    {
87
        \PHPUnit_Framework_Assert::assertNotNull($scope);
88
    }
89
90
    /**
91
     * @AfterScenario
92
     *
93
     * @ScenarioStateArgument("bananas")
94
     *
95
     * @param array $bananas
96
     */
97
    public function saveBananasWithoutScopeAfterScenario(array $bananas)
98
    {
99
        \PHPUnit_Framework_Assert::assertEquals(['foo', 'bar'], $bananas);
100
    }
101
102
    /**
103
     * @AfterScenario
104
     *
105
     * @ScenarioStateArgument("bananas")
106
     *
107
     * @param array              $bananas
108
     * @param AfterScenarioScope $scope
109
     */
110
    public function saveBananasWithScopeAfterScenario(array $bananas, AfterScenarioScope $scope)
111
    {
112
        \PHPUnit_Framework_Assert::assertNotNull($scope);
113
        \PHPUnit_Framework_Assert::assertEquals(['foo', 'bar'], $bananas);
114
    }
115
116
    /**
117
     * @AfterScenario
118
     *
119
     * @param AfterScenarioScope $scope
120
     */
121
    public function initApplesAfterScenario(AfterScenarioScope $scope)
122
    {
123
        \PHPUnit_Framework_Assert::assertNotNull($scope);
124
    }
125
126
    /**
127
     * @When the bonobo takes a banana
128
     */
129
    public function takeBanana()
130
    {
131
        $this->scenarioState->provideStateFragment('scenarioBanana', 'Yammy Banana');
132
    }
133
134
    /**
135
     * @Transform :gorilla
136
     *
137
     * @ScenarioStateArgument(name="gorillaIsMale", argument="isMale")
138
     *
139
     * @param string $gorilla
140
     * @param bool   $isMale
141
     *
142
     * @return Gorilla
143
     */
144
    public function transformGorilla($gorilla, $isMale)
145
    {
146
        $monkey = new Gorilla();
147
        $monkey->setName($gorilla);
148
        $monkey->setMale($isMale);
149
150
        return $monkey;
151
    }
152
153
    /**
154
     * @When gives this banana to :gorilla
155
     *
156
     * @ScenarioStateArgument("scenarioBanana")
157
     *
158
     * @param string  $scenarioBanana
159
     * @param Gorilla $gorilla
160
     */
161
    public function giveBananaToGorilla($scenarioBanana, Gorilla $gorilla)
162
    {
163
        \PHPUnit_Framework_Assert::assertEquals('Yammy Banana', $scenarioBanana);
164
        $gorilla->setBanana($scenarioBanana);
165
        $this->scenarioState->provideStateFragment('scenarioGorilla', $gorilla);
166
    }
167
168
    /**
169
     * @Then the gorilla has the banana
170
     *
171
     * @ScenarioStateArgument("scenarioBanana")
172
     * @ScenarioStateArgument(name="scenarioGorilla", argument="gorilla")
173
     *
174
     * @param string  $scenarioBanana
175
     * @param Gorilla $gorilla
176
     */
177
    public function gorillaHasBanana($scenarioBanana, Gorilla $gorilla)
178
    {
179
        \PHPUnit_Framework_Assert::assertEquals('Yammy Banana', $scenarioBanana);
180
        \PHPUnit_Framework_Assert::assertEquals('Yammy Banana', $gorilla->getBanana());
181
    }
182
}
183