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 (#24)
by Vincent
02:48
created

ScenarioStateArgumentOrganiserTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
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
namespace Gorghoa\ScenarioStateBehatExtension\Argument;
13
14
use Behat\Testwork\Argument\ArgumentOrganiser;
15
use Doctrine\Common\Annotations\Reader;
16
use Gorghoa\ScenarioStateBehatExtension\Annotation\ScenarioStateArgument;
17
use Gorghoa\ScenarioStateBehatExtension\Context\Initializer\ScenarioStateInitializer;
18
use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface;
19
use Prophecy\Prophecy\ObjectProphecy;
20
21
/**
22
 * @author Vincent Chalamon <[email protected]>
23
 */
24
class ScenarioStateArgumentOrganiserTest extends \PHPUnit_Framework_TestCase
25
{
26
    /**
27
     * @var ScenarioStateArgumentOrganiser
28
     */
29
    private $organiser;
30
31
    /**
32
     * @var ObjectProphecy|ArgumentOrganiser
33
     */
34
    private $organiserMock;
35
36
    /**
37
     * @var ObjectProphecy|ScenarioStateInitializer
38
     */
39
    private $initializerMock;
40
41
    /**
42
     * @var ObjectProphecy|ScenarioStateInterface
43
     */
44
    private $storeMock;
45
46
    /**
47
     * @var ObjectProphecy|\ReflectionMethod
48
     */
49
    private $functionMock;
50
51
    /**
52
     * @var ObjectProphecy|Reader
53
     */
54
    private $readerMock;
55
56
    /**
57
     * @var ObjectProphecy|ScenarioStateArgument
58
     */
59
    private $annotationMock;
60
61
    protected function setUp()
62
    {
63
        $this->organiserMock = $this->prophesize(ArgumentOrganiser::class);
64
        $this->initializerMock = $this->prophesize(ScenarioStateInitializer::class);
65
        $this->storeMock = $this->prophesize(ScenarioStateInterface::class);
66
        $this->functionMock = $this->prophesize(\ReflectionMethod::class);
67
        $this->readerMock = $this->prophesize(Reader::class);
68
        $this->annotationMock = $this->prophesize(ScenarioStateArgument::class);
69
70
        $this->organiser = new ScenarioStateArgumentOrganiser(
71
            $this->organiserMock->reveal(),
72
            $this->initializerMock->reveal(),
73
            $this->readerMock->reveal()
74
        );
75
    }
76
77
    public function testOrganiseArguments()
78
    {
79
        $this->functionMock->getParameters()->willReturn([
80
            (object) ['name' => 'scenarioBanana'],
81
            (object) ['name' => 'gorilla'],
82
            (object) ['name' => 'foo'],
83
        ])->shouldBeCalledTimes(1);
84
85
        $this->initializerMock->getStore()->willReturn($this->storeMock->reveal())->shouldBeCalledTimes(1);
86
        $this->readerMock->getMethodAnnotations($this->functionMock->reveal())->willReturn([
87
            $this->annotationMock->reveal(),
88
            $this->annotationMock->reveal(),
89
        ])->shouldBeCalledTimes(1);
90
        $this->annotationMock->getArgument()
91
            ->willReturn('scenarioBanana', 'scenarioBanana', 'gorilla', 'gorilla')
92
            ->shouldBeCalled();
93
        $this->annotationMock->getName()
94
            ->willReturn('scenarioBanana', 'scenarioBanana', 'scenarioBanana', 'scenarioGorilla', 'scenarioGorilla', 'scenarioGorilla')
95
            ->shouldBeCalled();
96
        $this->storeMock->hasStateFragment('scenarioBanana')->willReturn(true)->shouldBeCalledTimes(1);
97
        $this->storeMock->hasStateFragment('scenarioGorilla')->willReturn(true)->shouldBeCalledTimes(1);
98
        $this->storeMock->hasStateFragment('foo')->shouldNotBeCalled();
99
        $this->storeMock->getStateFragment('scenarioBanana')->willReturn('Yummy banana!')->shouldBeCalledTimes(2);
100
        $this->storeMock->getStateFragment('scenarioGorilla')->willReturn('Bonobo')->shouldBeCalledTimes(2);
101
        $this->storeMock->getStateFragment('foo')->shouldNotBeCalled();
102
103
        $this->organiserMock->organiseArguments($this->functionMock->reveal(), [
104
            0 => 'scenarioBanana',
105
            1 => 'gorilla',
106
            'scenarioBanana' => 'Yummy banana!',
107
            2 => 'Yummy banana!',
108
            'gorilla' => 'Bonobo',
109
            3 => 'Bonobo',
110
        ])->shouldBeCalledTimes(1);
111
112
        $this->organiser->organiseArguments($this->functionMock->reveal(), ['scenarioBanana', 'gorilla']);
113
    }
114
}
115