Completed
Pull Request — master (#66)
by Eric
40:03 queued 32:00
created

testResolveSerializerGroupsExplicit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
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
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...
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
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
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
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...
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
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
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...
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
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
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...
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
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...
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
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...
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
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...
205
            ->expects($this->at(1))
206
            ->method('get')
207
            ->with($this->identicalTo('_route'), $this->isNull())
208
            ->will($this->returnValue('route'));
209
210
        $request
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
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
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
260
            ->expects($this->once())
261
            ->method('getForm')
262
            ->will($this->returnValue($form = 'form'));
263
264
        $this->assertSame($form, $this->parameterResolver->resolveForm($resource));
265
    }
266
267
    public function testResolveFormDefault()
268
    {
269
        $resource = $this->createResourceMock();
270
        $resource
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
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...
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));
287
    }
288
289
    public function testResolveFormExplicit()
290
    {
291
        $resource = $this->createResourceMock();
292
        $resource
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
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...
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));
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
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...
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)
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());
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
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...
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
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...
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
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...
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
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...
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
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...
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
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...
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
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...
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
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...
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
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
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...
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
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
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...
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
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 testResolveMaxPerPageTooBig()
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
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...
552
            ->expects($this->once())
553
            ->method('get')
554
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo(10))
555
            ->will($this->returnValue(10));
556
557
        $request
558
            ->expects($this->once())
559
            ->method('get')
560
            ->with($this->identicalTo('limit'), $this->identicalTo(10))
561
            ->will($this->returnValue(101));
562
563
        $this->assertSame(100, $this->parameterResolver->resolveMaxPerPage());
564
    }
565
566
    public function testResolveRedirectRoute()
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
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...
574
            ->expects($this->once())
575
            ->method('get')
576
            ->with($this->identicalTo('_lug_redirect_route'), $this->isNull())
577
            ->will($this->returnValue($route = 'route'));
578
579
        $this->assertSame($route, $this->parameterResolver->resolveRedirectRoute());
580
    }
581
582
    /**
583
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
584
     * @expectedExceptionMessage The request could not be found.
585
     */
586
    public function testResolveRedirectRouteWithoutRequest()
587
    {
588
        $this->parameterResolver->resolveRedirectRoute();
589
    }
590
591
    /**
592
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
593
     * @expectedExceptionMessage The redirect route could not be found for the route "route".
594
     */
595 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...
596
    {
597
        $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...
598
            ->expects($this->exactly(2))
599
            ->method('getMasterRequest')
600
            ->will($this->returnValue($request = $this->createRequestMock()));
601
602
        $request->attributes
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...
603
            ->expects($this->at(0))
604
            ->method('get')
605
            ->with($this->identicalTo('_lug_redirect_route'), $this->isNull())
606
            ->will($this->returnValue(null));
607
608
        $request->attributes
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...
609
            ->expects($this->at(1))
610
            ->method('get')
611
            ->with($this->identicalTo('_route'), $this->isNull())
612
            ->will($this->returnValue('route'));
613
614
        $this->parameterResolver->resolveRedirectRoute();
615
    }
616
617
    public function testResolveRedirectRouteParametersWithoutRequest()
618
    {
619
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters(new \stdClass()));
620
    }
621
622
    public function testResolveRedirectRouteParametersDefault()
623
    {
624
        $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...
625
            ->expects($this->once())
626
            ->method('getMasterRequest')
627
            ->will($this->returnValue($request = $this->createRequestMock()));
628
629
        $request->attributes
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...
630
            ->expects($this->once())
631
            ->method('get')
632
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo($parameters = []))
633
            ->will($this->returnValue($parameters));
634
635
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters(new \stdClass()));
636
    }
637
638 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...
639
    {
640
        $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...
641
            ->expects($this->once())
642
            ->method('getMasterRequest')
643
            ->will($this->returnValue($request = $this->createRequestMock()));
644
645
        $request->attributes
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...
646
            ->expects($this->once())
647
            ->method('get')
648
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
649
            ->will($this->returnValue([$parameter = 'id']));
650
651
        $object = new \stdClass();
652
        $object->{$parameter} = $value = 1;
653
654
        $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...
655
            ->expects($this->once())
656
            ->method('getValue')
657
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
658
            ->will($this->returnValue($value));
659
660
        $this->assertSame([$parameter => $value], $this->parameterResolver->resolveRedirectRouteParameters($object));
661
    }
662
663
    public function testResolveRedirectRouteParametersForwardParameters()
664
    {
665
        $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...
666
            ->expects($this->exactly(2))
667
            ->method('getMasterRequest')
668
            ->will($this->returnValue($request = $this->createRequestMock()));
669
670
        $request->attributes
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...
671
            ->expects($this->once())
672
            ->method('get')
673
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
674
            ->will($this->returnValue([$parameter = 'id']));
675
676
        $request->query = $this->createParameterBagMock();
0 ignored issues
show
Bug introduced by
Accessing query 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...
677
        $request->query
0 ignored issues
show
Bug introduced by
Accessing query 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...
678
            ->expects($this->once())
679
            ->method('all')
680
            ->will($this->returnValue($query = ['foo' => 'bar']));
681
682
        $object = new \stdClass();
683
        $object->{$parameter} = $value = 1;
684
685
        $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...
686
            ->expects($this->once())
687
            ->method('getValue')
688
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
689
            ->will($this->returnValue($value));
690
691
        $this->assertSame(
692
            array_merge($query, [$parameter => $value]),
693
            $this->parameterResolver->resolveRedirectRouteParameters($object, true)
694
        );
695
    }
696
697 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...
698
    {
699
        $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...
700
            ->expects($this->once())
701
            ->method('getMasterRequest')
702
            ->will($this->returnValue($request = $this->createRequestMock()));
703
704
        $request->attributes
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...
705
            ->expects($this->once())
706
            ->method('get')
707
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
708
            ->will($this->returnValue([]));
709
710
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
711
    }
712
713
    /**
714
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
715
     * @expectedExceptionMessage The route parameters could not be found for the route "redirect_route_parameters".
716
     */
717 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...
718
    {
719
        $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...
720
            ->expects($this->once())
721
            ->method('getMasterRequest')
722
            ->will($this->returnValue($request = $this->createRequestMock()));
723
724
        $request->attributes
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...
725
            ->expects($this->once())
726
            ->method('get')
727
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
728
            ->will($this->returnValue(['id']));
729
730
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
731
    }
732
733
    public function testResolveRedirectRouteParametersForwardWithoutRequest()
734
    {
735
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
736
    }
737
738
    public function testResolveRedirectRouteParametersForwardDefault()
739
    {
740
        $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...
741
            ->expects($this->once())
742
            ->method('getMasterRequest')
743
            ->will($this->returnValue($request = $this->createRequestMock()));
744
745
        $request->attributes
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...
746
            ->expects($this->once())
747
            ->method('get')
748
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo($forward = false))
749
            ->will($this->returnValue($forward));
750
751
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
752
    }
753
754 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...
755
    {
756
        $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...
757
            ->expects($this->once())
758
            ->method('getMasterRequest')
759
            ->will($this->returnValue($request = $this->createRequestMock()));
760
761
        $request->attributes
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...
762
            ->expects($this->once())
763
            ->method('get')
764
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false))
765
            ->will($this->returnValue(true));
766
767
        $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward());
768
    }
769
770
    public function testResolveRepositoryMethodWithoutRequest()
771
    {
772
        $this->assertSame('findForTest', $this->parameterResolver->resolveRepositoryMethod('test'));
773
    }
774
775
    public function testResolveRepositoryMethodDefault()
776
    {
777
        $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...
778
            ->expects($this->once())
779
            ->method('getMasterRequest')
780
            ->will($this->returnValue($request = $this->createRequestMock()));
781
782
        $request->attributes
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...
783
            ->expects($this->once())
784
            ->method('get')
785
            ->with($this->identicalTo('_lug_repository_method'), $this->identicalTo($repositoryMethod = 'findForTest'))
786
            ->will($this->returnValue($repositoryMethod));
787
788
        $this->assertSame($repositoryMethod, $this->parameterResolver->resolveRepositoryMethod('test'));
789
    }
790
791
    public function testResolveRepositoryMethodExplicit()
792
    {
793
        $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...
794
            ->expects($this->once())
795
            ->method('getMasterRequest')
796
            ->will($this->returnValue($request = $this->createRequestMock()));
797
798
        $request->attributes
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...
799
            ->expects($this->once())
800
            ->method('get')
801
            ->with($this->identicalTo('_lug_repository_method'), $this->identicalTo('findForTest'))
802
            ->will($this->returnValue($repositoryMethod = 'findForAction'));
803
804
        $this->assertSame($repositoryMethod, $this->parameterResolver->resolveRepositoryMethod('test'));
805
    }
806
807
    public function testResolveSerializerGroupsWithoutRequest()
808
    {
809
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
810
    }
811
812 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...
813
    {
814
        $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...
815
            ->expects($this->once())
816
            ->method('getMasterRequest')
817
            ->will($this->returnValue($request = $this->createRequestMock()));
818
819
        $request->attributes
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...
820
            ->expects($this->once())
821
            ->method('get')
822
            ->with(
823
                $this->identicalTo('_lug_serializer_groups'),
824
                $this->identicalTo($groups = [])
825
            )
826
            ->will($this->returnValue($groups));
827
828
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
829
    }
830
831
    public function testResolveSerializerGroupsExplicit()
832
    {
833
        $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...
834
            ->expects($this->once())
835
            ->method('getMasterRequest')
836
            ->will($this->returnValue($request = $this->createRequestMock()));
837
838
        $request->attributes
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...
839
            ->expects($this->once())
840
            ->method('get')
841
            ->with(
842
                $this->identicalTo('_lug_serializer_groups'),
843
                $this->identicalTo([])
844
            )
845
            ->will($this->returnValue($groups = ['group']));
846
847
        $this->assertSame($groups, $this->parameterResolver->resolveSerializerGroups());
848
    }
849
850
    public function testResolveSerializerNullWithoutRequest()
851
    {
852
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
853
    }
854
855 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...
856
    {
857
        $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...
858
            ->expects($this->once())
859
            ->method('getMasterRequest')
860
            ->will($this->returnValue($request = $this->createRequestMock()));
861
862
        $request->attributes
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...
863
            ->expects($this->once())
864
            ->method('get')
865
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true))
866
            ->will($this->returnValue($null));
867
868
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
869
    }
870
871
    public function testResolveSerializerNullExplicit()
872
    {
873
        $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...
874
            ->expects($this->once())
875
            ->method('getMasterRequest')
876
            ->will($this->returnValue($request = $this->createRequestMock()));
877
878
        $request->attributes
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...
879
            ->expects($this->once())
880
            ->method('get')
881
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo(true))
882
            ->will($this->returnValue(false));
883
884
        $this->assertFalse($this->parameterResolver->resolveSerializerNull());
885
    }
886
887
    public function testResolveSortingWithoutRequest()
888
    {
889
        $this->assertEmpty($this->parameterResolver->resolveSorting());
890
    }
891
892 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...
893
    {
894
        $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...
895
            ->expects($this->once())
896
            ->method('getMasterRequest')
897
            ->will($this->returnValue($request = $this->createRequestMock()));
898
899
        $request->attributes
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...
900
            ->expects($this->once())
901
            ->method('get')
902
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo($sorting = []))
903
            ->will($this->returnValue($sorting));
904
905
        $this->assertEmpty($this->parameterResolver->resolveSorting());
906
    }
907
908 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...
909
    {
910
        $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...
911
            ->expects($this->once())
912
            ->method('getMasterRequest')
913
            ->will($this->returnValue($request = $this->createRequestMock()));
914
915
        $request->attributes
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...
916
            ->expects($this->once())
917
            ->method('get')
918
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo([]))
919
            ->will($this->returnValue($sorting = ['foo' => 'ASC']));
920
921
        $this->assertSame($sorting, $this->parameterResolver->resolveSorting());
922
    }
923
924
    public function testResolveStatusCodeWithoutRequest()
925
    {
926
        $this->assertSame($statusCode = 200, $this->parameterResolver->resolveStatusCode($statusCode));
927
    }
928
929 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...
930
    {
931
        $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...
932
            ->expects($this->once())
933
            ->method('getMasterRequest')
934
            ->will($this->returnValue($request = $this->createRequestMock()));
935
936
        $request->attributes
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...
937
            ->expects($this->once())
938
            ->method('get')
939
            ->with($this->identicalTo('_lug_status_code'), $this->identicalTo($statusCode = 200))
940
            ->will($this->returnValue($statusCode));
941
942
        $this->assertSame($statusCode, $this->parameterResolver->resolveStatusCode($statusCode));
943
    }
944
945
    public function testResolveStatusCodeExplicit()
946
    {
947
        $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...
948
            ->expects($this->once())
949
            ->method('getMasterRequest')
950
            ->will($this->returnValue($request = $this->createRequestMock()));
951
952
        $request->attributes
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...
953
            ->expects($this->once())
954
            ->method('get')
955
            ->with($this->identicalTo('_lug_status_code'), $this->identicalTo($defaultStatusCode = 200))
956
            ->will($this->returnValue($statusCode = 201));
957
958
        $this->assertSame($statusCode, $this->parameterResolver->resolveStatusCode($defaultStatusCode));
959
    }
960
961
    public function testResolveTemplate()
962
    {
963
        $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...
964
            ->expects($this->exactly(2))
965
            ->method('getMasterRequest')
966
            ->will($this->returnValue($request = $this->createRequestMock()));
967
968
        $request->attributes
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...
969
            ->expects($this->once())
970
            ->method('get')
971
            ->with($this->identicalTo('_lug_template'), $this->isNull())
972
            ->will($this->returnValue($template = 'template'));
973
974
        $this->assertSame($template, $this->parameterResolver->resolveTemplate());
975
    }
976
977
    /**
978
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
979
     * @expectedExceptionMessage The request could not be found.
980
     */
981
    public function testResolveTemplateWithoutRequest()
982
    {
983
        $this->parameterResolver->resolveTemplate();
984
    }
985
986
    /**
987
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
988
     * @expectedExceptionMessage The template could not be found for the route "route".
989
     */
990 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...
991
    {
992
        $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...
993
            ->expects($this->exactly(2))
994
            ->method('getMasterRequest')
995
            ->will($this->returnValue($request = $this->createRequestMock()));
996
997
        $request->attributes
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...
998
            ->expects($this->at(0))
999
            ->method('get')
1000
            ->with($this->identicalTo('_lug_template'), $this->isNull())
1001
            ->will($this->returnValue(null));
1002
1003
        $request->attributes
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...
1004
            ->expects($this->at(1))
1005
            ->method('get')
1006
            ->with($this->identicalTo('_route'), $this->isNull())
1007
            ->will($this->returnValue('route'));
1008
1009
        $this->parameterResolver->resolveTemplate();
1010
    }
1011
1012
    public function testResolveThemesWithoutRequest()
1013
    {
1014
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1015
    }
1016
1017 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...
1018
    {
1019
        $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...
1020
            ->expects($this->once())
1021
            ->method('getMasterRequest')
1022
            ->will($this->returnValue($request = $this->createRequestMock()));
1023
1024
        $request->attributes
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...
1025
            ->expects($this->once())
1026
            ->method('get')
1027
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo($themes = []))
1028
            ->will($this->returnValue($themes));
1029
1030
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1031
    }
1032
1033 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...
1034
    {
1035
        $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...
1036
            ->expects($this->once())
1037
            ->method('getMasterRequest')
1038
            ->will($this->returnValue($request = $this->createRequestMock()));
1039
1040
        $request->attributes
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...
1041
            ->expects($this->once())
1042
            ->method('get')
1043
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo([]))
1044
            ->will($this->returnValue($themes = ['theme']));
1045
1046
        $this->assertSame($themes, $this->parameterResolver->resolveThemes());
1047
    }
1048
1049
    public function testResolveTranslationDomainWithoutRequest()
1050
    {
1051
        $this->assertSame('forms', $this->parameterResolver->resolveTranslationDomain());
1052
    }
1053
1054 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...
1055
    {
1056
        $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...
1057
            ->expects($this->exactly(2))
1058
            ->method('getMasterRequest')
1059
            ->will($this->returnValue($request = $this->createRequestMock()));
1060
1061
        $request->attributes
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...
1062
            ->expects($this->at(0))
1063
            ->method('get')
1064
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1065
            ->will($this->returnValue(null));
1066
1067
        $request->attributes
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...
1068
            ->expects($this->at(1))
1069
            ->method('get')
1070
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo($translationDomain = 'forms'))
1071
            ->will($this->returnValue($translationDomain));
1072
1073
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1074
    }
1075
1076 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...
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
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...
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
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...
1090
            ->expects($this->at(1))
1091
            ->method('get')
1092
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo('forms'))
1093
            ->will($this->returnValue($translationDomain = 'translation_domain'));
1094
1095
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1096
    }
1097
1098 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...
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
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...
1106
            ->expects($this->at(0))
1107
            ->method('get')
1108
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1109
            ->will($this->returnValue(['grid']));
1110
1111
        $request->attributes
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...
1112
            ->expects($this->at(1))
1113
            ->method('get')
1114
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo($translationDomain = 'grids'))
1115
            ->will($this->returnValue($translationDomain));
1116
1117
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1118
    }
1119
1120 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...
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
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...
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
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...
1134
            ->expects($this->at(1))
1135
            ->method('get')
1136
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo('grids'))
1137
            ->will($this->returnValue($translationDomain = 'translation_domain'));
1138
1139
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1140
    }
1141
1142
    public function testResolveValidationGroupsWithoutRequest()
1143
    {
1144
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1145
    }
1146
1147 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...
1148
    {
1149
        $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...
1150
            ->expects($this->once())
1151
            ->method('getMasterRequest')
1152
            ->will($this->returnValue($request = $this->createRequestMock()));
1153
1154
        $request->attributes
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...
1155
            ->expects($this->once())
1156
            ->method('get')
1157
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo($groups = []))
1158
            ->will($this->returnValue($groups));
1159
1160
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1161
    }
1162
1163 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...
1164
    {
1165
        $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...
1166
            ->expects($this->once())
1167
            ->method('getMasterRequest')
1168
            ->will($this->returnValue($request = $this->createRequestMock()));
1169
1170
        $request->attributes
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...
1171
            ->expects($this->once())
1172
            ->method('get')
1173
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo([]))
1174
            ->will($this->returnValue($groups = ['group']));
1175
1176
        $this->assertSame($groups, $this->parameterResolver->resolveValidationGroups());
1177
    }
1178
1179
    public function testResolveVoterWithoutRequest()
1180
    {
1181
        $this->assertFalse($this->parameterResolver->resolveVoter());
1182
    }
1183
1184
    public function testResolveVoterDefault()
1185
    {
1186
        $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...
1187
            ->expects($this->once())
1188
            ->method('getMasterRequest')
1189
            ->will($this->returnValue($request = $this->createRequestMock()));
1190
1191
        $request->attributes
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...
1192
            ->expects($this->once())
1193
            ->method('get')
1194
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1195
            ->will($this->returnValue(false));
1196
1197
        $this->assertFalse($this->parameterResolver->resolveVoter());
1198
    }
1199
1200 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...
1201
    {
1202
        $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...
1203
            ->expects($this->once())
1204
            ->method('getMasterRequest')
1205
            ->will($this->returnValue($request = $this->createRequestMock()));
1206
1207
        $request->attributes
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...
1208
            ->expects($this->once())
1209
            ->method('get')
1210
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1211
            ->will($this->returnValue(true));
1212
1213
        $this->assertTrue($this->parameterResolver->resolveVoter());
1214
    }
1215
1216
    /**
1217
     * @return \PHPUnit_Framework_MockObject_MockObject|RequestStack
1218
     */
1219
    private function createRequestStackMock()
1220
    {
1221
        return $this->createMock(RequestStack::class);
1222
    }
1223
1224
    /**
1225
     * @return \PHPUnit_Framework_MockObject_MockObject|PropertyAccessorInterface
1226
     */
1227
    private function createPropertyAccessorMock()
1228
    {
1229
        return $this->createMock(PropertyAccessorInterface::class);
1230
    }
1231
1232
    /**
1233
     * @return \PHPUnit_Framework_MockObject_MockObject|Request
1234
     */
1235
    private function createRequestMock()
1236
    {
1237
        $request = $this->createMock(Request::class);
1238
        $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...
1239
1240
        return $request;
1241
    }
1242
1243
    /**
1244
     * @return \PHPUnit_Framework_MockObject_MockObject|ParameterBag
1245
     */
1246
    private function createParameterBagMock()
1247
    {
1248
        return $this->createMock(ParameterBag::class);
1249
    }
1250
1251
    /**
1252
     * @return \PHPUnit_Framework_MockObject_MockObject|ResourceInterface
1253
     */
1254
    private function createResourceMock()
1255
    {
1256
        return $this->createMock(ResourceInterface::class);
1257
    }
1258
}
1259