testResolveSerializerGroupsDefault()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 15
Ratio 83.33 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 15
loc 18
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Bundle\ResourceBundle\Tests\Routing;
13
14
use Lug\Bundle\ResourceBundle\Routing\ParameterResolver;
15
use Lug\Component\Resource\Model\ResourceInterface;
16
use Symfony\Component\HttpFoundation\ParameterBag;
17
use Symfony\Component\HttpFoundation\Request;
18
use Symfony\Component\HttpFoundation\RequestStack;
19
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
20
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24
class ParameterResolverTest extends \PHPUnit_Framework_TestCase
25
{
26
    /**
27
     * @var ParameterResolver
28
     */
29
    private $parameterResolver;
30
31
    /**
32
     * @var \PHPUnit_Framework_MockObject_MockObject|RequestStack
33
     */
34
    private $requestStack;
35
36
    /**
37
     * @var \PHPUnit_Framework_MockObject_MockObject|PropertyAccessorInterface
38
     */
39
    private $propertyAccessor;
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    protected function setUp()
45
    {
46
        $this->requestStack = $this->createRequestStackMock();
47
        $this->propertyAccessor = $this->createPropertyAccessorMock();
48
49
        $this->parameterResolver = new ParameterResolver($this->requestStack, $this->propertyAccessor);
50
    }
51
52
    public function testResolveApiWithoutRequest()
53
    {
54
        $this->assertTrue($this->parameterResolver->resolveApi());
55
    }
56
57 View Code Duplication
    public function testResolveApiWihApiRequest()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
60
            ->expects($this->exactly(2))
61
            ->method('getMasterRequest')
62
            ->will($this->returnValue($request = $this->createRequestMock()));
63
64
        $request->attributes
65
            ->expects($this->once())
66
            ->method('get')
67
            ->with($this->identicalTo('_lug_api'), $this->identicalTo(false))
68
            ->will($this->returnValue(true));
69
70
        $this->assertTrue($this->parameterResolver->resolveApi());
71
    }
72
73 View Code Duplication
    public function testResolveApiWithHtmlRequest()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
    {
75
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
76
            ->expects($this->exactly(2))
77
            ->method('getMasterRequest')
78
            ->will($this->returnValue($request = $this->createRequestMock()));
79
80
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
81
            ->expects($this->once())
82
            ->method('getRequestFormat')
83
            ->will($this->returnValue('html'));
84
85
        $this->assertFalse($this->parameterResolver->resolveApi());
86
    }
87
88 View Code Duplication
    public function testResolveApiWithCustomRequest()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
    {
90
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
91
            ->expects($this->exactly(2))
92
            ->method('getMasterRequest')
93
            ->will($this->returnValue($request = $this->createRequestMock()));
94
95
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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
            ->expects($this->once())
97
            ->method('getRequestFormat')
98
            ->will($this->returnValue('json'));
99
100
        $this->assertTrue($this->parameterResolver->resolveApi());
101
    }
102
103
    public function testResolveCriteriaWithoutRequest()
104
    {
105
        $this->assertEmpty($this->parameterResolver->resolveCriteria());
106
    }
107
108 View Code Duplication
    public function testResolveCriteriaWithDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
    {
110
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
111
            ->expects($this->exactly(2))
112
            ->method('getMasterRequest')
113
            ->will($this->returnValue($request = $this->createRequestMock()));
114
115
        $request->attributes
116
            ->expects($this->once())
117
            ->method('get')
118
            ->with($this->identicalTo('_lug_criteria'), $this->identicalTo([$identifier = 'id']))
119
            ->will($this->returnValue([$identifier]));
120
121
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
122
            ->expects($this->once())
123
            ->method('get')
124
            ->with($this->identicalTo($identifier), $this->isNull())
125
            ->will($this->returnValue($value = 'value'));
126
127
        $this->assertSame([$identifier => $value], $this->parameterResolver->resolveCriteria());
128
    }
129
130 View Code Duplication
    public function testResolveCriteriaWithExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
131
    {
132
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
133
            ->expects($this->exactly(2))
134
            ->method('getMasterRequest')
135
            ->will($this->returnValue($request = $this->createRequestMock()));
136
137
        $request->attributes
138
            ->expects($this->once())
139
            ->method('get')
140
            ->with($this->identicalTo('_lug_criteria'), $this->identicalTo(['id']))
141
            ->will($this->returnValue([$identifier = 'code']));
142
143
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
144
            ->expects($this->once())
145
            ->method('get')
146
            ->with($this->identicalTo($identifier), $this->isNull())
147
            ->will($this->returnValue($value = 'value'));
148
149
        $this->assertSame([$identifier => $value], $this->parameterResolver->resolveCriteria());
150
    }
151
152
    /**
153
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
154
     * @expectedExceptionMessage The request could not be found.
155
     */
156
    public function testResolveCriteriaMandatoryWithoutRequest()
157
    {
158
        $this->parameterResolver->resolveCriteria(true);
159
    }
160
161
    /**
162
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
163
     * @expectedExceptionMessage The criteria could not be found for the route "route".
164
     */
165 View Code Duplication
    public function testResolveCriteriaMandatoryWithoutCriteria()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
166
    {
167
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
168
            ->expects($this->exactly(2))
169
            ->method('getMasterRequest')
170
            ->will($this->returnValue($request = $this->createRequestMock()));
171
172
        $request->attributes
173
            ->expects($this->at(0))
174
            ->method('get')
175
            ->with($this->identicalTo('_lug_criteria'), $this->identicalTo(['id']))
176
            ->will($this->returnValue([]));
177
178
        $request->attributes
179
            ->expects($this->at(1))
180
            ->method('get')
181
            ->with($this->identicalTo('_route'), $this->isNull())
182
            ->will($this->returnValue('route'));
183
184
        $this->parameterResolver->resolveCriteria(true);
185
    }
186
187
    /**
188
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
189
     * @expectedExceptionMessage The criteria "id" could not be found for the route "route".
190
     */
191
    public function testResolveCriteriaMandatoryWithoutRequestCriteria()
192
    {
193
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
194
            ->expects($this->exactly(2))
195
            ->method('getMasterRequest')
196
            ->will($this->returnValue($request = $this->createRequestMock()));
197
198
        $request->attributes
199
            ->expects($this->at(0))
200
            ->method('get')
201
            ->with($this->identicalTo('_lug_criteria'), $this->identicalTo([$identifier = 'id']))
202
            ->will($this->returnValue([$identifier]));
203
204
        $request->attributes
205
            ->expects($this->at(1))
206
            ->method('get')
207
            ->with($this->identicalTo('_route'), $this->isNull())
208
            ->will($this->returnValue('route'));
209
210
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
211
            ->expects($this->once())
212
            ->method('get')
213
            ->with($this->identicalTo($identifier), $this->isNull())
214
            ->will($this->returnValue(null));
215
216
        $this->parameterResolver->resolveCriteria(true);
217
    }
218
219
    public function testResolveCurrentPageWithoutRequest()
220
    {
221
        $this->assertSame(1, $this->parameterResolver->resolveCurrentPage());
222
    }
223
224 View Code Duplication
    public function testResolveCurrentPageDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
225
    {
226
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
227
            ->expects($this->once())
228
            ->method('getMasterRequest')
229
            ->will($this->returnValue($request = $this->createRequestMock()));
230
231
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
232
            ->expects($this->once())
233
            ->method('get')
234
            ->with($this->identicalTo('page'), $this->identicalTo($page = 1))
235
            ->will($this->returnValue($page));
236
237
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
238
    }
239
240 View Code Duplication
    public function testResolveCurrentPageExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
241
    {
242
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
243
            ->expects($this->once())
244
            ->method('getMasterRequest')
245
            ->will($this->returnValue($request = $this->createRequestMock()));
246
247
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
248
            ->expects($this->once())
249
            ->method('get')
250
            ->with($this->identicalTo('page'), $this->identicalTo(1))
251
            ->will($this->returnValue($page = 2));
252
253
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
254
    }
255
256
    public function testResolveFormWithoutRequest()
257
    {
258
        $resource = $this->createResourceMock();
259
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

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...
260
            ->expects($this->once())
261
            ->method('getForm')
262
            ->will($this->returnValue($form = 'form'));
263
264
        $this->assertSame($form, $this->parameterResolver->resolveForm($resource));
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 258 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveForm() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
265
    }
266
267
    public function testResolveFormDefault()
268
    {
269
        $resource = $this->createResourceMock();
270
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

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...
271
            ->expects($this->once())
272
            ->method('getForm')
273
            ->will($this->returnValue($form = 'form'));
274
275
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
276
            ->expects($this->once())
277
            ->method('getMasterRequest')
278
            ->will($this->returnValue($request = $this->createRequestMock()));
279
280
        $request->attributes
281
            ->expects($this->once())
282
            ->method('get')
283
            ->with($this->identicalTo('_lug_form'), $this->identicalTo($form))
284
            ->will($this->returnValue($form));
285
286
        $this->assertSame($form, $this->parameterResolver->resolveForm($resource));
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 269 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveForm() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
287
    }
288
289
    public function testResolveFormExplicit()
290
    {
291
        $resource = $this->createResourceMock();
292
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

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...
293
            ->expects($this->once())
294
            ->method('getForm')
295
            ->will($this->returnValue($form = 'form'));
296
297
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
298
            ->expects($this->once())
299
            ->method('getMasterRequest')
300
            ->will($this->returnValue($request = $this->createRequestMock()));
301
302
        $request->attributes
303
            ->expects($this->once())
304
            ->method('get')
305
            ->with($this->identicalTo('_lug_form'), $this->identicalTo($form))
306
            ->will($this->returnValue($explicitForm = 'explicit_form'));
307
308
        $this->assertSame($explicitForm, $this->parameterResolver->resolveForm($resource));
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 291 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveForm() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
309
    }
310
311
    public function testResolveGrid()
312
    {
313
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
314
            ->expects($this->exactly(2))
315
            ->method('getMasterRequest')
316
            ->will($this->returnValue($request = $this->createRequestMock()));
317
318
        $request->attributes
319
            ->expects($this->once())
320
            ->method('get')
321
            ->with($this->identicalTo('_lug_grid'), $this->identicalTo([]))
322
            ->will($this->returnValue($grid = ['foo' => 'bar']));
323
324
        $this->assertSame(
325
            array_merge(['resource' => $resource = $this->createResourceMock()], $grid),
326
            $this->parameterResolver->resolveGrid($resource)
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 325 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveGrid() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
327
        );
328
    }
329
330
    /**
331
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
332
     * @expectedExceptionMessage The request could not be found.
333
     */
334
    public function testResolveGridWithoutRequest()
335
    {
336
        $this->parameterResolver->resolveGrid($this->createResourceMock());
0 ignored issues
show
Bug introduced by
It seems like $this->createResourceMock() targeting Lug\Bundle\ResourceBundl...t::createResourceMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveGrid() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
337
    }
338
339
    public function testResolveHateoasWithoutRequest()
340
    {
341
        $this->assertFalse($this->parameterResolver->resolveHateoas());
342
    }
343
344
    public function testResolveHateoasDefault()
345
    {
346
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
347
            ->expects($this->once())
348
            ->method('getMasterRequest')
349
            ->will($this->returnValue($request = $this->createRequestMock()));
350
351
        $request->attributes
352
            ->expects($this->once())
353
            ->method('get')
354
            ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo($hateaos = false))
355
            ->will($this->returnValue($hateaos));
356
357
        $this->assertFalse($this->parameterResolver->resolveHateoas());
358
    }
359
360 View Code Duplication
    public function testResolveHateoasExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
361
    {
362
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
363
            ->expects($this->once())
364
            ->method('getMasterRequest')
365
            ->will($this->returnValue($request = $this->createRequestMock()));
366
367
        $request->attributes
368
            ->expects($this->once())
369
            ->method('get')
370
            ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo(false))
371
            ->will($this->returnValue(true));
372
373
        $this->assertTrue($this->parameterResolver->resolveHateoas());
374
    }
375
376
    public function testResolveLocationRoute()
377
    {
378
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
379
            ->expects($this->exactly(2))
380
            ->method('getMasterRequest')
381
            ->will($this->returnValue($request = $this->createRequestMock()));
382
383
        $request->attributes
384
            ->expects($this->once())
385
            ->method('get')
386
            ->with($this->identicalTo('_lug_location_route'), $this->isNull())
387
            ->will($this->returnValue($route = 'route'));
388
389
        $this->assertSame($route, $this->parameterResolver->resolveLocationRoute());
390
    }
391
392
    /**
393
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
394
     * @expectedExceptionMessage The request could not be found.
395
     */
396
    public function testResolveLocationRouteWithoutRequest()
397
    {
398
        $this->parameterResolver->resolveLocationRoute();
399
    }
400
401
    /**
402
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
403
     * @expectedExceptionMessage The location route could not be found for the route "route".
404
     */
405 View Code Duplication
    public function testResolveLocationRouteMissing()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
406
    {
407
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
408
            ->expects($this->exactly(2))
409
            ->method('getMasterRequest')
410
            ->will($this->returnValue($request = $this->createRequestMock()));
411
412
        $request->attributes
413
            ->expects($this->at(0))
414
            ->method('get')
415
            ->with($this->identicalTo('_lug_location_route'), $this->isNull())
416
            ->will($this->returnValue(null));
417
418
        $request->attributes
419
            ->expects($this->at(1))
420
            ->method('get')
421
            ->with($this->identicalTo('_route'), $this->isNull())
422
            ->will($this->returnValue('route'));
423
424
        $this->parameterResolver->resolveLocationRoute();
425
    }
426
427
    public function testResolveLocationRouteParametersWithoutRequest()
428
    {
429
        $this->assertEmpty($this->parameterResolver->resolveLocationRouteParameters(new \stdClass()));
430
    }
431
432
    public function testResolveLocationRouteParametersDefault()
433
    {
434
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
435
            ->expects($this->once())
436
            ->method('getMasterRequest')
437
            ->will($this->returnValue($request = $this->createRequestMock()));
438
439
        $request->attributes
440
            ->expects($this->once())
441
            ->method('get')
442
            ->with($this->identicalTo('_lug_location_route_parameters'), $this->identicalTo($parameters = []))
443
            ->will($this->returnValue($parameters));
444
445
        $this->assertEmpty($this->parameterResolver->resolveLocationRouteParameters(new \stdClass()));
446
    }
447
448 View Code Duplication
    public function testResolveLocationRouteParametersExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
449
    {
450
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
451
            ->expects($this->once())
452
            ->method('getMasterRequest')
453
            ->will($this->returnValue($request = $this->createRequestMock()));
454
455
        $request->attributes
456
            ->expects($this->once())
457
            ->method('get')
458
            ->with($this->identicalTo('_lug_location_route_parameters'), $this->identicalTo([]))
459
            ->will($this->returnValue([$parameter = 'id']));
460
461
        $object = new \stdClass();
462
        $object->{$parameter} = $value = 1;
463
464
        $this->propertyAccessor
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Proper...opertyAccessorInterface.

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...
465
            ->expects($this->once())
466
            ->method('getValue')
467
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
468
            ->will($this->returnValue($value));
469
470
        $this->assertSame([$parameter => $value], $this->parameterResolver->resolveLocationRouteParameters($object));
471
    }
472
473
    public function testResolveMaxPerPageWithoutRequest()
474
    {
475
        $this->assertSame(10, $this->parameterResolver->resolveMaxPerPage());
476
    }
477
478 View Code Duplication
    public function testResolveMaxPerPageDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
479
    {
480
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
481
            ->expects($this->exactly(2))
482
            ->method('getMasterRequest')
483
            ->will($this->returnValue($request = $this->createRequestMock()));
484
485
        $request->attributes
486
            ->expects($this->once())
487
            ->method('get')
488
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo($maxPerPage = 10))
489
            ->will($this->returnValue($maxPerPage));
490
491
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
492
            ->expects($this->once())
493
            ->method('get')
494
            ->with($this->identicalTo('limit'), $this->identicalTo($maxPerPage))
495
            ->will($this->returnValue($maxPerPage));
496
497
        $this->assertSame($maxPerPage, $this->parameterResolver->resolveMaxPerPage());
498
    }
499
500 View Code Duplication
    public function testResolveMaxPerPageExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
501
    {
502
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
503
            ->expects($this->exactly(2))
504
            ->method('getMasterRequest')
505
            ->will($this->returnValue($request = $this->createRequestMock()));
506
507
        $request->attributes
508
            ->expects($this->once())
509
            ->method('get')
510
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo(10))
511
            ->will($this->returnValue($maxPerPage = 5));
512
513
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
514
            ->expects($this->once())
515
            ->method('get')
516
            ->with($this->identicalTo('limit'), $this->identicalTo($maxPerPage))
517
            ->will($this->returnValue($maxPerPage));
518
519
        $this->assertSame($maxPerPage, $this->parameterResolver->resolveMaxPerPage());
520
    }
521
522 View Code Duplication
    public function testResolveMaxPerPageDynamic()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
523
    {
524
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
525
            ->expects($this->exactly(2))
526
            ->method('getMasterRequest')
527
            ->will($this->returnValue($request = $this->createRequestMock()));
528
529
        $request->attributes
530
            ->expects($this->once())
531
            ->method('get')
532
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo(10))
533
            ->will($this->returnValue(10));
534
535
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
536
            ->expects($this->once())
537
            ->method('get')
538
            ->with($this->identicalTo('limit'), $this->identicalTo(10))
539
            ->will($this->returnValue($maxPerPage = 20));
540
541
        $this->assertSame($maxPerPage, $this->parameterResolver->resolveMaxPerPage());
542
    }
543
544 View Code Duplication
    public function testResolveMaxPerPageLowerThan0()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
545
    {
546
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
547
            ->expects($this->exactly(2))
548
            ->method('getMasterRequest')
549
            ->will($this->returnValue($request = $this->createRequestMock()));
550
551
        $request->attributes
552
            ->expects($this->once())
553
            ->method('get')
554
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo($default = 10))
555
            ->will($this->returnValue($default));
556
557
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
558
            ->expects($this->once())
559
            ->method('get')
560
            ->with($this->identicalTo('limit'), $this->identicalTo($default))
561
            ->will($this->returnValue(0));
562
563
        $this->assertSame($default, $this->parameterResolver->resolveMaxPerPage());
564
    }
565
566 View Code Duplication
    public function testResolveMaxPerPageUpperThan100()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
567
    {
568
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
569
            ->expects($this->exactly(2))
570
            ->method('getMasterRequest')
571
            ->will($this->returnValue($request = $this->createRequestMock()));
572
573
        $request->attributes
574
            ->expects($this->once())
575
            ->method('get')
576
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo(10))
577
            ->will($this->returnValue(10));
578
579
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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...
580
            ->expects($this->once())
581
            ->method('get')
582
            ->with($this->identicalTo('limit'), $this->identicalTo(10))
583
            ->will($this->returnValue(101));
584
585
        $this->assertSame(100, $this->parameterResolver->resolveMaxPerPage());
586
    }
587
588
    public function testResolveRedirectRoute()
589
    {
590
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
591
            ->expects($this->exactly(2))
592
            ->method('getMasterRequest')
593
            ->will($this->returnValue($request = $this->createRequestMock()));
594
595
        $request->attributes
596
            ->expects($this->once())
597
            ->method('get')
598
            ->with($this->identicalTo('_lug_redirect_route'), $this->isNull())
599
            ->will($this->returnValue($route = 'route'));
600
601
        $this->assertSame($route, $this->parameterResolver->resolveRedirectRoute());
602
    }
603
604
    /**
605
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
606
     * @expectedExceptionMessage The request could not be found.
607
     */
608
    public function testResolveRedirectRouteWithoutRequest()
609
    {
610
        $this->parameterResolver->resolveRedirectRoute();
611
    }
612
613
    /**
614
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
615
     * @expectedExceptionMessage The redirect route could not be found for the route "route".
616
     */
617 View Code Duplication
    public function testResolveRedirectRouteMissing()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
618
    {
619
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
620
            ->expects($this->exactly(2))
621
            ->method('getMasterRequest')
622
            ->will($this->returnValue($request = $this->createRequestMock()));
623
624
        $request->attributes
625
            ->expects($this->at(0))
626
            ->method('get')
627
            ->with($this->identicalTo('_lug_redirect_route'), $this->isNull())
628
            ->will($this->returnValue(null));
629
630
        $request->attributes
631
            ->expects($this->at(1))
632
            ->method('get')
633
            ->with($this->identicalTo('_route'), $this->isNull())
634
            ->will($this->returnValue('route'));
635
636
        $this->parameterResolver->resolveRedirectRoute();
637
    }
638
639
    public function testResolveRedirectRouteParametersWithoutRequest()
640
    {
641
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters(new \stdClass()));
642
    }
643
644
    public function testResolveRedirectRouteParametersDefault()
645
    {
646
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
647
            ->expects($this->once())
648
            ->method('getMasterRequest')
649
            ->will($this->returnValue($request = $this->createRequestMock()));
650
651
        $request->attributes
652
            ->expects($this->once())
653
            ->method('get')
654
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo($parameters = []))
655
            ->will($this->returnValue($parameters));
656
657
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters(new \stdClass()));
658
    }
659
660 View Code Duplication
    public function testResolveRedirectRouteParametersExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
661
    {
662
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
663
            ->expects($this->once())
664
            ->method('getMasterRequest')
665
            ->will($this->returnValue($request = $this->createRequestMock()));
666
667
        $request->attributes
668
            ->expects($this->once())
669
            ->method('get')
670
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
671
            ->will($this->returnValue([$parameter = 'id']));
672
673
        $object = new \stdClass();
674
        $object->{$parameter} = $value = 1;
675
676
        $this->propertyAccessor
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Proper...opertyAccessorInterface.

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...
677
            ->expects($this->once())
678
            ->method('getValue')
679
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
680
            ->will($this->returnValue($value));
681
682
        $this->assertSame([$parameter => $value], $this->parameterResolver->resolveRedirectRouteParameters($object));
683
    }
684
685
    public function testResolveRedirectRouteParametersForwardParameters()
686
    {
687
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
688
            ->expects($this->exactly(2))
689
            ->method('getMasterRequest')
690
            ->will($this->returnValue($request = $this->createRequestMock()));
691
692
        $request->attributes
693
            ->expects($this->once())
694
            ->method('get')
695
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
696
            ->will($this->returnValue([$parameter = 'id']));
697
698
        $request->query = $this->createParameterBagMock();
699
        $request->query
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\ParameterBag.

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...
700
            ->expects($this->once())
701
            ->method('all')
702
            ->will($this->returnValue($query = ['foo' => 'bar']));
703
704
        $object = new \stdClass();
705
        $object->{$parameter} = $value = 1;
706
707
        $this->propertyAccessor
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Proper...opertyAccessorInterface.

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...
708
            ->expects($this->once())
709
            ->method('getValue')
710
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
711
            ->will($this->returnValue($value));
712
713
        $this->assertSame(
714
            array_merge($query, [$parameter => $value]),
715
            $this->parameterResolver->resolveRedirectRouteParameters($object, true)
716
        );
717
    }
718
719 View Code Duplication
    public function testResolveRedirectRouteParametersWithoutObject()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
720
    {
721
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
722
            ->expects($this->once())
723
            ->method('getMasterRequest')
724
            ->will($this->returnValue($request = $this->createRequestMock()));
725
726
        $request->attributes
727
            ->expects($this->once())
728
            ->method('get')
729
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
730
            ->will($this->returnValue([]));
731
732
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
733
    }
734
735
    /**
736
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
737
     * @expectedExceptionMessage The route parameters could not be found for the route "redirect_route_parameters".
738
     */
739 View Code Duplication
    public function testResolveRedirectRouteParametersWithObjectMissing()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
740
    {
741
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
742
            ->expects($this->once())
743
            ->method('getMasterRequest')
744
            ->will($this->returnValue($request = $this->createRequestMock()));
745
746
        $request->attributes
747
            ->expects($this->once())
748
            ->method('get')
749
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
750
            ->will($this->returnValue(['id']));
751
752
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
753
    }
754
755
    public function testResolveRedirectRouteParametersForwardWithoutRequest()
756
    {
757
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
758
    }
759
760
    public function testResolveRedirectRouteParametersForwardDefault()
761
    {
762
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
763
            ->expects($this->once())
764
            ->method('getMasterRequest')
765
            ->will($this->returnValue($request = $this->createRequestMock()));
766
767
        $request->attributes
768
            ->expects($this->once())
769
            ->method('get')
770
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo($forward = false))
771
            ->will($this->returnValue($forward));
772
773
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
774
    }
775
776 View Code Duplication
    public function testResolveRedirectRouteParametersForwardExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
777
    {
778
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
779
            ->expects($this->once())
780
            ->method('getMasterRequest')
781
            ->will($this->returnValue($request = $this->createRequestMock()));
782
783
        $request->attributes
784
            ->expects($this->once())
785
            ->method('get')
786
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false))
787
            ->will($this->returnValue(true));
788
789
        $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward());
790
    }
791
792
    public function testResolveRepositoryMethodWithoutRequest()
793
    {
794
        $this->assertSame('findForTest', $this->parameterResolver->resolveRepositoryMethod('test'));
795
    }
796
797
    public function testResolveRepositoryMethodDefault()
798
    {
799
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
800
            ->expects($this->once())
801
            ->method('getMasterRequest')
802
            ->will($this->returnValue($request = $this->createRequestMock()));
803
804
        $request->attributes
805
            ->expects($this->once())
806
            ->method('get')
807
            ->with($this->identicalTo('_lug_repository_method'), $this->identicalTo($repositoryMethod = 'findForTest'))
808
            ->will($this->returnValue($repositoryMethod));
809
810
        $this->assertSame($repositoryMethod, $this->parameterResolver->resolveRepositoryMethod('test'));
811
    }
812
813
    public function testResolveRepositoryMethodExplicit()
814
    {
815
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
816
            ->expects($this->once())
817
            ->method('getMasterRequest')
818
            ->will($this->returnValue($request = $this->createRequestMock()));
819
820
        $request->attributes
821
            ->expects($this->once())
822
            ->method('get')
823
            ->with($this->identicalTo('_lug_repository_method'), $this->identicalTo('findForTest'))
824
            ->will($this->returnValue($repositoryMethod = 'findForAction'));
825
826
        $this->assertSame($repositoryMethod, $this->parameterResolver->resolveRepositoryMethod('test'));
827
    }
828
829
    public function testResolveSerializerGroupsWithoutRequest()
830
    {
831
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
832
    }
833
834 View Code Duplication
    public function testResolveSerializerGroupsDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
835
    {
836
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
837
            ->expects($this->once())
838
            ->method('getMasterRequest')
839
            ->will($this->returnValue($request = $this->createRequestMock()));
840
841
        $request->attributes
842
            ->expects($this->once())
843
            ->method('get')
844
            ->with(
845
                $this->identicalTo('_lug_serializer_groups'),
846
                $this->identicalTo($groups = [])
847
            )
848
            ->will($this->returnValue($groups));
849
850
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
851
    }
852
853
    public function testResolveSerializerGroupsExplicit()
854
    {
855
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
856
            ->expects($this->once())
857
            ->method('getMasterRequest')
858
            ->will($this->returnValue($request = $this->createRequestMock()));
859
860
        $request->attributes
861
            ->expects($this->once())
862
            ->method('get')
863
            ->with(
864
                $this->identicalTo('_lug_serializer_groups'),
865
                $this->identicalTo([])
866
            )
867
            ->will($this->returnValue($groups = ['group']));
868
869
        $this->assertSame($groups, $this->parameterResolver->resolveSerializerGroups());
870
    }
871
872
    public function testResolveSerializerNullWithoutRequest()
873
    {
874
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
875
    }
876
877 View Code Duplication
    public function testResolveSerializerNullDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
878
    {
879
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
880
            ->expects($this->once())
881
            ->method('getMasterRequest')
882
            ->will($this->returnValue($request = $this->createRequestMock()));
883
884
        $request->attributes
885
            ->expects($this->once())
886
            ->method('get')
887
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true))
888
            ->will($this->returnValue($null));
889
890
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
891
    }
892
893
    public function testResolveSerializerNullExplicit()
894
    {
895
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
896
            ->expects($this->once())
897
            ->method('getMasterRequest')
898
            ->will($this->returnValue($request = $this->createRequestMock()));
899
900
        $request->attributes
901
            ->expects($this->once())
902
            ->method('get')
903
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo(true))
904
            ->will($this->returnValue(false));
905
906
        $this->assertFalse($this->parameterResolver->resolveSerializerNull());
907
    }
908
909
    public function testResolveSortingWithoutRequest()
910
    {
911
        $this->assertEmpty($this->parameterResolver->resolveSorting());
912
    }
913
914 View Code Duplication
    public function testResolveSortingDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
915
    {
916
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
917
            ->expects($this->once())
918
            ->method('getMasterRequest')
919
            ->will($this->returnValue($request = $this->createRequestMock()));
920
921
        $request->attributes
922
            ->expects($this->once())
923
            ->method('get')
924
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo($sorting = []))
925
            ->will($this->returnValue($sorting));
926
927
        $this->assertEmpty($this->parameterResolver->resolveSorting());
928
    }
929
930 View Code Duplication
    public function testResolveSortingExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
931
    {
932
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
933
            ->expects($this->once())
934
            ->method('getMasterRequest')
935
            ->will($this->returnValue($request = $this->createRequestMock()));
936
937
        $request->attributes
938
            ->expects($this->once())
939
            ->method('get')
940
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo([]))
941
            ->will($this->returnValue($sorting = ['foo' => 'ASC']));
942
943
        $this->assertSame($sorting, $this->parameterResolver->resolveSorting());
944
    }
945
946
    public function testResolveStatusCodeWithoutRequest()
947
    {
948
        $this->assertSame($statusCode = 200, $this->parameterResolver->resolveStatusCode($statusCode));
949
    }
950
951 View Code Duplication
    public function testResolveStatusCodeDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
952
    {
953
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
954
            ->expects($this->once())
955
            ->method('getMasterRequest')
956
            ->will($this->returnValue($request = $this->createRequestMock()));
957
958
        $request->attributes
959
            ->expects($this->once())
960
            ->method('get')
961
            ->with($this->identicalTo('_lug_status_code'), $this->identicalTo($statusCode = 200))
962
            ->will($this->returnValue($statusCode));
963
964
        $this->assertSame($statusCode, $this->parameterResolver->resolveStatusCode($statusCode));
965
    }
966
967
    public function testResolveStatusCodeExplicit()
968
    {
969
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
970
            ->expects($this->once())
971
            ->method('getMasterRequest')
972
            ->will($this->returnValue($request = $this->createRequestMock()));
973
974
        $request->attributes
975
            ->expects($this->once())
976
            ->method('get')
977
            ->with($this->identicalTo('_lug_status_code'), $this->identicalTo($defaultStatusCode = 200))
978
            ->will($this->returnValue($statusCode = 201));
979
980
        $this->assertSame($statusCode, $this->parameterResolver->resolveStatusCode($defaultStatusCode));
981
    }
982
983
    public function testResolveTemplate()
984
    {
985
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
986
            ->expects($this->exactly(2))
987
            ->method('getMasterRequest')
988
            ->will($this->returnValue($request = $this->createRequestMock()));
989
990
        $request->attributes
991
            ->expects($this->once())
992
            ->method('get')
993
            ->with($this->identicalTo('_lug_template'), $this->isNull())
994
            ->will($this->returnValue($template = 'template'));
995
996
        $this->assertSame($template, $this->parameterResolver->resolveTemplate());
997
    }
998
999
    /**
1000
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
1001
     * @expectedExceptionMessage The request could not be found.
1002
     */
1003
    public function testResolveTemplateWithoutRequest()
1004
    {
1005
        $this->parameterResolver->resolveTemplate();
1006
    }
1007
1008
    /**
1009
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
1010
     * @expectedExceptionMessage The template could not be found for the route "route".
1011
     */
1012 View Code Duplication
    public function testResolveTemplateMissing()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1013
    {
1014
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1015
            ->expects($this->exactly(2))
1016
            ->method('getMasterRequest')
1017
            ->will($this->returnValue($request = $this->createRequestMock()));
1018
1019
        $request->attributes
1020
            ->expects($this->at(0))
1021
            ->method('get')
1022
            ->with($this->identicalTo('_lug_template'), $this->isNull())
1023
            ->will($this->returnValue(null));
1024
1025
        $request->attributes
1026
            ->expects($this->at(1))
1027
            ->method('get')
1028
            ->with($this->identicalTo('_route'), $this->isNull())
1029
            ->will($this->returnValue('route'));
1030
1031
        $this->parameterResolver->resolveTemplate();
1032
    }
1033
1034
    public function testResolveThemesWithoutRequest()
1035
    {
1036
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1037
    }
1038
1039 View Code Duplication
    public function testResolveThemesDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1040
    {
1041
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1042
            ->expects($this->once())
1043
            ->method('getMasterRequest')
1044
            ->will($this->returnValue($request = $this->createRequestMock()));
1045
1046
        $request->attributes
1047
            ->expects($this->once())
1048
            ->method('get')
1049
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo($themes = []))
1050
            ->will($this->returnValue($themes));
1051
1052
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1053
    }
1054
1055 View Code Duplication
    public function testResolveThemesExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1056
    {
1057
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1058
            ->expects($this->once())
1059
            ->method('getMasterRequest')
1060
            ->will($this->returnValue($request = $this->createRequestMock()));
1061
1062
        $request->attributes
1063
            ->expects($this->once())
1064
            ->method('get')
1065
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo([]))
1066
            ->will($this->returnValue($themes = ['theme']));
1067
1068
        $this->assertSame($themes, $this->parameterResolver->resolveThemes());
1069
    }
1070
1071
    public function testResolveTranslationDomainWithoutRequest()
1072
    {
1073
        $this->assertSame('forms', $this->parameterResolver->resolveTranslationDomain());
1074
    }
1075
1076 View Code Duplication
    public function testResolveTranslationDomainDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1077
    {
1078
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1079
            ->expects($this->exactly(2))
1080
            ->method('getMasterRequest')
1081
            ->will($this->returnValue($request = $this->createRequestMock()));
1082
1083
        $request->attributes
1084
            ->expects($this->at(0))
1085
            ->method('get')
1086
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1087
            ->will($this->returnValue(null));
1088
1089
        $request->attributes
1090
            ->expects($this->at(1))
1091
            ->method('get')
1092
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo($translationDomain = 'forms'))
1093
            ->will($this->returnValue($translationDomain));
1094
1095
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1096
    }
1097
1098 View Code Duplication
    public function testResolveTranslationDomainExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1099
    {
1100
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1101
            ->expects($this->exactly(2))
1102
            ->method('getMasterRequest')
1103
            ->will($this->returnValue($request = $this->createRequestMock()));
1104
1105
        $request->attributes
1106
            ->expects($this->at(0))
1107
            ->method('get')
1108
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1109
            ->will($this->returnValue(null));
1110
1111
        $request->attributes
1112
            ->expects($this->at(1))
1113
            ->method('get')
1114
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo('forms'))
1115
            ->will($this->returnValue($translationDomain = 'translation_domain'));
1116
1117
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1118
    }
1119
1120 View Code Duplication
    public function testResolveTranslationDomainWithGrid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1121
    {
1122
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1123
            ->expects($this->exactly(2))
1124
            ->method('getMasterRequest')
1125
            ->will($this->returnValue($request = $this->createRequestMock()));
1126
1127
        $request->attributes
1128
            ->expects($this->at(0))
1129
            ->method('get')
1130
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1131
            ->will($this->returnValue(['grid']));
1132
1133
        $request->attributes
1134
            ->expects($this->at(1))
1135
            ->method('get')
1136
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo($translationDomain = 'grids'))
1137
            ->will($this->returnValue($translationDomain));
1138
1139
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1140
    }
1141
1142 View Code Duplication
    public function testResolveTranslationDomainExplicitWithGrid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1143
    {
1144
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1145
            ->expects($this->exactly(2))
1146
            ->method('getMasterRequest')
1147
            ->will($this->returnValue($request = $this->createRequestMock()));
1148
1149
        $request->attributes
1150
            ->expects($this->at(0))
1151
            ->method('get')
1152
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1153
            ->will($this->returnValue(['grid']));
1154
1155
        $request->attributes
1156
            ->expects($this->at(1))
1157
            ->method('get')
1158
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo('grids'))
1159
            ->will($this->returnValue($translationDomain = 'translation_domain'));
1160
1161
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1162
    }
1163
1164
    public function testResolveValidationGroupsWithoutRequest()
1165
    {
1166
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1167
    }
1168
1169 View Code Duplication
    public function testResolveValidationGroupsDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1170
    {
1171
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1172
            ->expects($this->once())
1173
            ->method('getMasterRequest')
1174
            ->will($this->returnValue($request = $this->createRequestMock()));
1175
1176
        $request->attributes
1177
            ->expects($this->once())
1178
            ->method('get')
1179
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo($groups = []))
1180
            ->will($this->returnValue($groups));
1181
1182
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1183
    }
1184
1185 View Code Duplication
    public function testResolveValidationGroupsExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1186
    {
1187
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1188
            ->expects($this->once())
1189
            ->method('getMasterRequest')
1190
            ->will($this->returnValue($request = $this->createRequestMock()));
1191
1192
        $request->attributes
1193
            ->expects($this->once())
1194
            ->method('get')
1195
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo([]))
1196
            ->will($this->returnValue($groups = ['group']));
1197
1198
        $this->assertSame($groups, $this->parameterResolver->resolveValidationGroups());
1199
    }
1200
1201
    public function testResolveVoterWithoutRequest()
1202
    {
1203
        $this->assertFalse($this->parameterResolver->resolveVoter());
1204
    }
1205
1206
    public function testResolveVoterDefault()
1207
    {
1208
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1209
            ->expects($this->once())
1210
            ->method('getMasterRequest')
1211
            ->will($this->returnValue($request = $this->createRequestMock()));
1212
1213
        $request->attributes
1214
            ->expects($this->once())
1215
            ->method('get')
1216
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1217
            ->will($this->returnValue(false));
1218
1219
        $this->assertFalse($this->parameterResolver->resolveVoter());
1220
    }
1221
1222 View Code Duplication
    public function testResolveVoterExplicit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1223
    {
1224
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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...
1225
            ->expects($this->once())
1226
            ->method('getMasterRequest')
1227
            ->will($this->returnValue($request = $this->createRequestMock()));
1228
1229
        $request->attributes
1230
            ->expects($this->once())
1231
            ->method('get')
1232
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1233
            ->will($this->returnValue(true));
1234
1235
        $this->assertTrue($this->parameterResolver->resolveVoter());
1236
    }
1237
1238
    /**
1239
     * @return \PHPUnit_Framework_MockObject_MockObject|RequestStack
1240
     */
1241
    private function createRequestStackMock()
1242
    {
1243
        return $this->createMock(RequestStack::class);
1244
    }
1245
1246
    /**
1247
     * @return \PHPUnit_Framework_MockObject_MockObject|PropertyAccessorInterface
1248
     */
1249
    private function createPropertyAccessorMock()
1250
    {
1251
        return $this->createMock(PropertyAccessorInterface::class);
1252
    }
1253
1254
    /**
1255
     * @return \PHPUnit_Framework_MockObject_MockObject|Request
1256
     */
1257
    private function createRequestMock()
1258
    {
1259
        $request = $this->createMock(Request::class);
1260
        $request->attributes = $this->createParameterBagMock();
0 ignored issues
show
Bug introduced by
Accessing attributes on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
1261
1262
        return $request;
1263
    }
1264
1265
    /**
1266
     * @return \PHPUnit_Framework_MockObject_MockObject|ParameterBag
1267
     */
1268
    private function createParameterBagMock()
1269
    {
1270
        return $this->createMock(ParameterBag::class);
1271
    }
1272
1273
    /**
1274
     * @return \PHPUnit_Framework_MockObject_MockObject|ResourceInterface
1275
     */
1276
    private function createResourceMock()
1277
    {
1278
        return $this->createMock(ResourceInterface::class);
1279
    }
1280
}
1281