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.
Completed
Push — master ( d30b96...ac351b )
by Rodrigue
04:22
created

testOrganiseArguments()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 37
rs 8.8571
cc 1
eloc 32
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;
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 Prophecy\Prophecy\ObjectProphecy;
19
20
/**
21
 * @author Vincent Chalamon <[email protected]>
22
 */
23
class ScenarioStateArgumentOrganiserTest extends \PHPUnit_Framework_TestCase
24
{
25
    /**
26
     * @var ScenarioStateArgumentOrganiser
27
     */
28
    private $organiser;
29
30
    /**
31
     * @var ObjectProphecy|ArgumentOrganiser
32
     */
33
    private $organiserMock;
34
35
    /**
36
     * @var ObjectProphecy|ScenarioStateInitializer
37
     */
38
    private $initializerMock;
39
40
    /**
41
     * @var ObjectProphecy|ScenarioStateInterface
42
     */
43
    private $storeMock;
44
45
    /**
46
     * @var ObjectProphecy|\ReflectionMethod
47
     */
48
    private $functionMock;
49
50
    /**
51
     * @var ObjectProphecy|Reader
52
     */
53
    private $readerMock;
54
55
    /**
56
     * @var ObjectProphecy|ScenarioStateArgument
57
     */
58
    private $annotationMock;
59
60
    protected function setUp()
61
    {
62
        $this->organiserMock = $this->prophesize(ArgumentOrganiser::class);
63
        $this->initializerMock = $this->prophesize(ScenarioStateInitializer::class);
64
        $this->storeMock = $this->prophesize(ScenarioStateInterface::class);
65
        $this->functionMock = $this->prophesize(\ReflectionMethod::class);
66
        $this->readerMock = $this->prophesize(Reader::class);
67
        $this->annotationMock = $this->prophesize(ScenarioStateArgument::class);
68
69
        $this->organiser = new ScenarioStateArgumentOrganiser(
70
            $this->organiserMock->reveal(),
71
            $this->initializerMock->reveal(),
72
            $this->readerMock->reveal()
73
        );
74
    }
75
76
    public function testOrganiseArguments()
77
    {
78
        $this->functionMock->getParameters()->willReturn([
1 ignored issue
show
Bug introduced by
The method getParameters does only exist in ReflectionMethod, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
79
            (object)['name' => 'scenarioBanana'],
80
            (object)['name' => 'gorilla'],
81
            (object)['name' => 'foo'],
82
        ])->shouldBeCalledTimes(1);
83
84
        $this->initializerMock->getStore()->willReturn($this->storeMock->reveal())->shouldBeCalledTimes(1);
2 ignored issues
show
Bug introduced by
The method getStore does only exist in Gorghoa\ScenarioStateBeh...cenarioStateInitializer, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Gorghoa\ScenarioStateBeh...\ScenarioStateInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
85
        $this->readerMock->getMethodAnnotations($this->functionMock->reveal())->willReturn([
2 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in ReflectionMethod.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
Bug introduced by
The method getMethodAnnotations does only exist in Doctrine\Common\Annotations\Reader, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
86
            $this->annotationMock->reveal(),
1 ignored issue
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Gorghoa\ScenarioStateBeh...n\ScenarioStateArgument.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
87
            $this->annotationMock->reveal(),
88
        ])->shouldBeCalledTimes(1);
89
        $this->annotationMock->getArgument()
1 ignored issue
show
Bug introduced by
The method getArgument does only exist in Gorghoa\ScenarioStateBeh...n\ScenarioStateArgument, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
90
            ->willReturn('scenarioBanana', 'scenarioBanana', 'gorilla', 'gorilla')
91
            ->shouldBeCalled();
92
        $this->annotationMock->getName()
1 ignored issue
show
Bug introduced by
The method getName does only exist in Gorghoa\ScenarioStateBeh...n\ScenarioStateArgument, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
93
            ->willReturn('scenarioBanana', 'scenarioBanana', 'scenarioBanana', 'scenarioGorilla', 'scenarioGorilla', 'scenarioGorilla')
94
            ->shouldBeCalled();
95
        $this->storeMock->hasStateFragment('scenarioBanana')->willReturn(true)->shouldBeCalledTimes(1);
1 ignored issue
show
Bug introduced by
The method hasStateFragment does only exist in Gorghoa\ScenarioStateBeh...\ScenarioStateInterface, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
96
        $this->storeMock->hasStateFragment('scenarioGorilla')->willReturn(true)->shouldBeCalledTimes(1);
97
        $this->storeMock->hasStateFragment('foo')->shouldNotBeCalled();
98
        $this->storeMock->getStateFragment('scenarioBanana')->willReturn('Yummy banana!')->shouldBeCalledTimes(2);
1 ignored issue
show
Bug introduced by
The method getStateFragment does only exist in Gorghoa\ScenarioStateBeh...\ScenarioStateInterface, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
99
        $this->storeMock->getStateFragment('scenarioGorilla')->willReturn('Bonobo')->shouldBeCalledTimes(2);
100
        $this->storeMock->getStateFragment('foo')->shouldNotBeCalled();
101
102
        $this->organiserMock->organiseArguments($this->functionMock->reveal(), [
1 ignored issue
show
Bug introduced by
The method organiseArguments does only exist in Behat\Testwork\Argument\ArgumentOrganiser, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
103
            0 => 'scenarioBanana',
104
            1 => 'gorilla',
105
            'scenarioBanana' => 'Yummy banana!',
106
            2 => 'Yummy banana!',
107
            'gorilla' => 'Bonobo',
108
            3 => 'Bonobo',
109
        ])->shouldBeCalledTimes(1);
110
111
        $this->organiser->organiseArguments($this->functionMock->reveal(), ['scenarioBanana', 'gorilla']);
112
    }
113
}
114