Completed
Pull Request — master (#45)
by Eric
12:15
created

testResolveSerializerGroupsDefault()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 15
Ratio 83.33 %

Importance

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

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

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

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

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

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
76
            ->expects($this->exactly(2))
77
            ->method('getMasterRequest')
78
            ->will($this->returnValue($request = $this->createRequestMock()));
79
80
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
81
            ->expects($this->once())
82
            ->method('getRequestFormat')
83
            ->will($this->returnValue('html'));
84
85
        $this->assertFalse($this->parameterResolver->resolveApi());
86
    }
87
88 View Code Duplication
    public function testResolveApiWithCustomRequest()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
91
            ->expects($this->exactly(2))
92
            ->method('getMasterRequest')
93
            ->will($this->returnValue($request = $this->createRequestMock()));
94
95
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

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

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

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
111
            ->expects($this->exactly(2))
112
            ->method('getMasterRequest')
113
            ->will($this->returnValue($request = $this->createRequestMock()));
114
115
        $request->attributes
116
            ->expects($this->once())
117
            ->method('get')
118
            ->with($this->identicalTo('_lug_criteria'), $this->identicalTo([$identifier = 'id']))
119
            ->will($this->returnValue([$identifier]));
120
121
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

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

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

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
133
            ->expects($this->exactly(2))
134
            ->method('getMasterRequest')
135
            ->will($this->returnValue($request = $this->createRequestMock()));
136
137
        $request->attributes
138
            ->expects($this->once())
139
            ->method('get')
140
            ->with($this->identicalTo('_lug_criteria'), $this->identicalTo(['id']))
141
            ->will($this->returnValue([$identifier = 'code']));
142
143
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

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

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

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

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

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
211
            ->expects($this->once())
212
            ->method('get')
213
            ->with($this->identicalTo($identifier), $this->isNull())
214
            ->will($this->returnValue(null));
215
216
        $this->parameterResolver->resolveCriteria(true);
217
    }
218
219
    public function testResolveCurrentPageWithoutRequest()
220
    {
221
        $this->assertSame(1, $this->parameterResolver->resolveCurrentPage());
222
    }
223
224
    public function testResolveCurrentPageDefault()
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->exactly(2))
228
            ->method('getMasterRequest')
229
            ->will($this->returnValue($request = $this->createRequestMock()));
230
231
        $request->attributes
232
            ->expects($this->once())
233
            ->method('get')
234
            ->with($this->identicalTo('_lug_page_parameter'), $this->identicalTo($pageParameter = 'page'))
235
            ->will($this->returnValue($pageParameter));
236
237
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
238
            ->expects($this->once())
239
            ->method('get')
240
            ->with($this->identicalTo($pageParameter), $this->identicalTo($page = 1))
241
            ->will($this->returnValue($page));
242
243
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
244
    }
245
246 View Code Duplication
    public function testResolveCurrentPageExplicitParameter()
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...
247
    {
248
        $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...
249
            ->expects($this->exactly(2))
250
            ->method('getMasterRequest')
251
            ->will($this->returnValue($request = $this->createRequestMock()));
252
253
        $request->attributes
254
            ->expects($this->once())
255
            ->method('get')
256
            ->with($this->identicalTo('_lug_page_parameter'), $this->identicalTo('page'))
257
            ->will($this->returnValue($pageParameter = 'p'));
258
259
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
260
            ->expects($this->once())
261
            ->method('get')
262
            ->with($this->identicalTo($pageParameter), $this->identicalTo($page = 1))
263
            ->will($this->returnValue($page));
264
265
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
266
    }
267
268 View Code Duplication
    public function testResolveCurrentPageExplicitPage()
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...
269
    {
270
        $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...
271
            ->expects($this->exactly(2))
272
            ->method('getMasterRequest')
273
            ->will($this->returnValue($request = $this->createRequestMock()));
274
275
        $request->attributes
276
            ->expects($this->once())
277
            ->method('get')
278
            ->with($this->identicalTo('_lug_page_parameter'), $this->identicalTo($pageParameter = 'page'))
279
            ->will($this->returnValue($pageParameter));
280
281
        $request
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\Request.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
282
            ->expects($this->once())
283
            ->method('get')
284
            ->with($this->identicalTo($pageParameter), $this->identicalTo(1))
285
            ->will($this->returnValue($page = 2));
286
287
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
288
    }
289
290
    public function testResolveFormWithoutRequest()
291
    {
292
        $resource = $this->createResourceMock();
293
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
294
            ->expects($this->once())
295
            ->method('getForm')
296
            ->will($this->returnValue($form = 'form'));
297
298
        $this->assertSame($form, $this->parameterResolver->resolveForm($resource));
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 292 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveForm() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
299
    }
300
301
    public function testResolveFormDefault()
302
    {
303
        $resource = $this->createResourceMock();
304
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
305
            ->expects($this->once())
306
            ->method('getForm')
307
            ->will($this->returnValue($form = 'form'));
308
309
        $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...
310
            ->expects($this->once())
311
            ->method('getMasterRequest')
312
            ->will($this->returnValue($request = $this->createRequestMock()));
313
314
        $request->attributes
315
            ->expects($this->once())
316
            ->method('get')
317
            ->with($this->identicalTo('_lug_form'), $this->identicalTo($form))
318
            ->will($this->returnValue($form));
319
320
        $this->assertSame($form, $this->parameterResolver->resolveForm($resource));
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 303 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveForm() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
321
    }
322
323
    public function testResolveFormExplicit()
324
    {
325
        $resource = $this->createResourceMock();
326
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
327
            ->expects($this->once())
328
            ->method('getForm')
329
            ->will($this->returnValue($form = 'form'));
330
331
        $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...
332
            ->expects($this->once())
333
            ->method('getMasterRequest')
334
            ->will($this->returnValue($request = $this->createRequestMock()));
335
336
        $request->attributes
337
            ->expects($this->once())
338
            ->method('get')
339
            ->with($this->identicalTo('_lug_form'), $this->identicalTo($form))
340
            ->will($this->returnValue($explicitForm = 'explicit_form'));
341
342
        $this->assertSame($explicitForm, $this->parameterResolver->resolveForm($resource));
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 325 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveForm() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
343
    }
344
345
    public function testResolveGrid()
346
    {
347
        $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...
348
            ->expects($this->exactly(2))
349
            ->method('getMasterRequest')
350
            ->will($this->returnValue($request = $this->createRequestMock()));
351
352
        $request->attributes
353
            ->expects($this->once())
354
            ->method('get')
355
            ->with($this->identicalTo('_lug_grid'), $this->identicalTo([]))
356
            ->will($this->returnValue($grid = ['foo' => 'bar']));
357
358
        $this->assertSame(
359
            array_merge(['resource' => $resource = $this->createResourceMock()], $grid),
360
            $this->parameterResolver->resolveGrid($resource)
0 ignored issues
show
Bug introduced by
It seems like $resource defined by $this->createResourceMock() on line 359 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveGrid() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
361
        );
362
    }
363
364
    /**
365
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
366
     * @expectedExceptionMessage The request could not be found.
367
     */
368
    public function testResolveGridWithoutRequest()
369
    {
370
        $this->parameterResolver->resolveGrid($this->createResourceMock());
0 ignored issues
show
Bug introduced by
It seems like $this->createResourceMock() targeting Lug\Bundle\ResourceBundl...t::createResourceMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Lug\Bundle\ResourceBundl...Resolver::resolveGrid() does only seem to accept object<Lug\Component\Res...odel\ResourceInterface>, maybe add an additional type check?

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

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

An additional type check may prevent trouble.

Loading history...
371
    }
372
373
    public function testResolveHateoasWithoutRequest()
374
    {
375
        $this->assertFalse($this->parameterResolver->resolveHateoas());
376
    }
377
378
    public function testResolveHateoasDefault()
379
    {
380
        $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...
381
            ->expects($this->once())
382
            ->method('getMasterRequest')
383
            ->will($this->returnValue($request = $this->createRequestMock()));
384
385
        $request->attributes
386
            ->expects($this->once())
387
            ->method('get')
388
            ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo($hateaos = false))
389
            ->will($this->returnValue($hateaos));
390
391
        $this->assertFalse($this->parameterResolver->resolveHateoas());
392
    }
393
394 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...
395
    {
396
        $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...
397
            ->expects($this->once())
398
            ->method('getMasterRequest')
399
            ->will($this->returnValue($request = $this->createRequestMock()));
400
401
        $request->attributes
402
            ->expects($this->once())
403
            ->method('get')
404
            ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo(false))
405
            ->will($this->returnValue(true));
406
407
        $this->assertTrue($this->parameterResolver->resolveHateoas());
408
    }
409
410
    public function testResolveLocationRoute()
411
    {
412
        $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...
413
            ->expects($this->exactly(2))
414
            ->method('getMasterRequest')
415
            ->will($this->returnValue($request = $this->createRequestMock()));
416
417
        $request->attributes
418
            ->expects($this->once())
419
            ->method('get')
420
            ->with($this->identicalTo('_lug_location_route'), $this->isNull())
421
            ->will($this->returnValue($route = 'route'));
422
423
        $this->assertSame($route, $this->parameterResolver->resolveLocationRoute());
424
    }
425
426
    /**
427
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
428
     * @expectedExceptionMessage The request could not be found.
429
     */
430
    public function testResolveLocationRouteWithoutRequest()
431
    {
432
        $this->parameterResolver->resolveLocationRoute();
433
    }
434
435
    /**
436
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
437
     * @expectedExceptionMessage The location route could not be found for the route "route".
438
     */
439 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...
440
    {
441
        $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...
442
            ->expects($this->exactly(2))
443
            ->method('getMasterRequest')
444
            ->will($this->returnValue($request = $this->createRequestMock()));
445
446
        $request->attributes
447
            ->expects($this->at(0))
448
            ->method('get')
449
            ->with($this->identicalTo('_lug_location_route'), $this->isNull())
450
            ->will($this->returnValue(null));
451
452
        $request->attributes
453
            ->expects($this->at(1))
454
            ->method('get')
455
            ->with($this->identicalTo('_route'), $this->isNull())
456
            ->will($this->returnValue('route'));
457
458
        $this->parameterResolver->resolveLocationRoute();
459
    }
460
461
    public function testResolveLocationRouteParametersWithoutRequest()
462
    {
463
        $this->assertEmpty($this->parameterResolver->resolveLocationRouteParameters(new \stdClass()));
464
    }
465
466
    public function testResolveLocationRouteParametersDefault()
467
    {
468
        $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...
469
            ->expects($this->once())
470
            ->method('getMasterRequest')
471
            ->will($this->returnValue($request = $this->createRequestMock()));
472
473
        $request->attributes
474
            ->expects($this->once())
475
            ->method('get')
476
            ->with($this->identicalTo('_lug_location_route_parameters'), $this->identicalTo($parameters = []))
477
            ->will($this->returnValue($parameters));
478
479
        $this->assertEmpty($this->parameterResolver->resolveLocationRouteParameters(new \stdClass()));
480
    }
481
482 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...
483
    {
484
        $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...
485
            ->expects($this->once())
486
            ->method('getMasterRequest')
487
            ->will($this->returnValue($request = $this->createRequestMock()));
488
489
        $request->attributes
490
            ->expects($this->once())
491
            ->method('get')
492
            ->with($this->identicalTo('_lug_location_route_parameters'), $this->identicalTo([]))
493
            ->will($this->returnValue([$parameter = 'id']));
494
495
        $object = new \stdClass();
496
        $object->{$parameter} = $value = 1;
497
498
        $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...
499
            ->expects($this->once())
500
            ->method('getValue')
501
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
502
            ->will($this->returnValue($value));
503
504
        $this->assertSame([$parameter => $value], $this->parameterResolver->resolveLocationRouteParameters($object));
505
    }
506
507
    public function testResolveMaxPerPageWithoutRequest()
508
    {
509
        $this->assertSame(10, $this->parameterResolver->resolveMaxPerPage());
510
    }
511
512
    public function testResolveMaxPerPageDefault()
513
    {
514
        $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...
515
            ->expects($this->once())
516
            ->method('getMasterRequest')
517
            ->will($this->returnValue($request = $this->createRequestMock()));
518
519
        $request->attributes
520
            ->expects($this->once())
521
            ->method('get')
522
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo($maxPerPage = 10))
523
            ->will($this->returnValue($maxPerPage));
524
525
        $this->assertSame($maxPerPage, $this->parameterResolver->resolveMaxPerPage());
526
    }
527
528
    public function testResolveMaxPerPageExplicit()
529
    {
530
        $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...
531
            ->expects($this->once())
532
            ->method('getMasterRequest')
533
            ->will($this->returnValue($request = $this->createRequestMock()));
534
535
        $request->attributes
536
            ->expects($this->once())
537
            ->method('get')
538
            ->with($this->identicalTo('_lug_max_per_page'), $this->identicalTo(10))
539
            ->will($this->returnValue($maxPerPage = 5));
540
541
        $this->assertSame($maxPerPage, $this->parameterResolver->resolveMaxPerPage());
542
    }
543
544
    public function testResolveRedirectRoute()
545
    {
546
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
547
            ->expects($this->exactly(2))
548
            ->method('getMasterRequest')
549
            ->will($this->returnValue($request = $this->createRequestMock()));
550
551
        $request->attributes
552
            ->expects($this->once())
553
            ->method('get')
554
            ->with($this->identicalTo('_lug_redirect_route'), $this->isNull())
555
            ->will($this->returnValue($route = 'route'));
556
557
        $this->assertSame($route, $this->parameterResolver->resolveRedirectRoute());
558
    }
559
560
    /**
561
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
562
     * @expectedExceptionMessage The request could not be found.
563
     */
564
    public function testResolveRedirectRouteWithoutRequest()
565
    {
566
        $this->parameterResolver->resolveRedirectRoute();
567
    }
568
569
    /**
570
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
571
     * @expectedExceptionMessage The redirect route could not be found for the route "route".
572
     */
573 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...
574
    {
575
        $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...
576
            ->expects($this->exactly(2))
577
            ->method('getMasterRequest')
578
            ->will($this->returnValue($request = $this->createRequestMock()));
579
580
        $request->attributes
581
            ->expects($this->at(0))
582
            ->method('get')
583
            ->with($this->identicalTo('_lug_redirect_route'), $this->isNull())
584
            ->will($this->returnValue(null));
585
586
        $request->attributes
587
            ->expects($this->at(1))
588
            ->method('get')
589
            ->with($this->identicalTo('_route'), $this->isNull())
590
            ->will($this->returnValue('route'));
591
592
        $this->parameterResolver->resolveRedirectRoute();
593
    }
594
595
    public function testResolveRedirectRouteParametersWithoutRequest()
596
    {
597
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters(new \stdClass()));
598
    }
599
600
    public function testResolveRedirectRouteParametersDefault()
601
    {
602
        $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...
603
            ->expects($this->once())
604
            ->method('getMasterRequest')
605
            ->will($this->returnValue($request = $this->createRequestMock()));
606
607
        $request->attributes
608
            ->expects($this->once())
609
            ->method('get')
610
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo($parameters = []))
611
            ->will($this->returnValue($parameters));
612
613
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters(new \stdClass()));
614
    }
615
616 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...
617
    {
618
        $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...
619
            ->expects($this->once())
620
            ->method('getMasterRequest')
621
            ->will($this->returnValue($request = $this->createRequestMock()));
622
623
        $request->attributes
624
            ->expects($this->once())
625
            ->method('get')
626
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
627
            ->will($this->returnValue([$parameter = 'id']));
628
629
        $object = new \stdClass();
630
        $object->{$parameter} = $value = 1;
631
632
        $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...
633
            ->expects($this->once())
634
            ->method('getValue')
635
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
636
            ->will($this->returnValue($value));
637
638
        $this->assertSame([$parameter => $value], $this->parameterResolver->resolveRedirectRouteParameters($object));
639
    }
640
641
    public function testResolveRedirectRouteParametersForwardParameters()
642
    {
643
        $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...
644
            ->expects($this->exactly(2))
645
            ->method('getMasterRequest')
646
            ->will($this->returnValue($request = $this->createRequestMock()));
647
648
        $request->attributes
649
            ->expects($this->once())
650
            ->method('get')
651
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
652
            ->will($this->returnValue([$parameter = 'id']));
653
654
        $request->query = $this->createParameterBagMock();
655
        $request->query
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\ParameterBag.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
656
            ->expects($this->once())
657
            ->method('all')
658
            ->will($this->returnValue($query = ['foo' => 'bar']));
659
660
        $object = new \stdClass();
661
        $object->{$parameter} = $value = 1;
662
663
        $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...
664
            ->expects($this->once())
665
            ->method('getValue')
666
            ->with($this->identicalTo($object), $this->identicalTo($parameter))
667
            ->will($this->returnValue($value));
668
669
        $this->assertSame(
670
            array_merge($query, [$parameter => $value]),
671
            $this->parameterResolver->resolveRedirectRouteParameters($object, true)
672
        );
673
    }
674
675 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...
676
    {
677
        $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...
678
            ->expects($this->once())
679
            ->method('getMasterRequest')
680
            ->will($this->returnValue($request = $this->createRequestMock()));
681
682
        $request->attributes
683
            ->expects($this->once())
684
            ->method('get')
685
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
686
            ->will($this->returnValue([]));
687
688
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
689
    }
690
691
    /**
692
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
693
     * @expectedExceptionMessage The route parameters could not be found for the route "redirect_route_parameters".
694
     */
695 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...
696
    {
697
        $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...
698
            ->expects($this->once())
699
            ->method('getMasterRequest')
700
            ->will($this->returnValue($request = $this->createRequestMock()));
701
702
        $request->attributes
703
            ->expects($this->once())
704
            ->method('get')
705
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
706
            ->will($this->returnValue(['id']));
707
708
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
709
    }
710
711
    public function testResolveRedirectRouteParametersForwardWithoutRequest()
712
    {
713
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
714
    }
715
716
    public function testResolveRedirectRouteParametersForwardDefault()
717
    {
718
        $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...
719
            ->expects($this->once())
720
            ->method('getMasterRequest')
721
            ->will($this->returnValue($request = $this->createRequestMock()));
722
723
        $request->attributes
724
            ->expects($this->once())
725
            ->method('get')
726
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo($forward = false))
727
            ->will($this->returnValue($forward));
728
729
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
730
    }
731
732 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...
733
    {
734
        $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...
735
            ->expects($this->once())
736
            ->method('getMasterRequest')
737
            ->will($this->returnValue($request = $this->createRequestMock()));
738
739
        $request->attributes
740
            ->expects($this->once())
741
            ->method('get')
742
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false))
743
            ->will($this->returnValue(true));
744
745
        $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward());
746
    }
747
748
    public function testResolveRepositoryMethodWithoutRequest()
749
    {
750
        $this->assertSame('findForTest', $this->parameterResolver->resolveRepositoryMethod('test'));
751
    }
752
753
    public function testResolveRepositoryMethodDefault()
754
    {
755
        $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...
756
            ->expects($this->once())
757
            ->method('getMasterRequest')
758
            ->will($this->returnValue($request = $this->createRequestMock()));
759
760
        $request->attributes
761
            ->expects($this->once())
762
            ->method('get')
763
            ->with($this->identicalTo('_lug_repository_method'), $this->identicalTo($repositoryMethod = 'findForTest'))
764
            ->will($this->returnValue($repositoryMethod));
765
766
        $this->assertSame($repositoryMethod, $this->parameterResolver->resolveRepositoryMethod('test'));
767
    }
768
769
    public function testResolveRepositoryMethodExplicit()
770
    {
771
        $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...
772
            ->expects($this->once())
773
            ->method('getMasterRequest')
774
            ->will($this->returnValue($request = $this->createRequestMock()));
775
776
        $request->attributes
777
            ->expects($this->once())
778
            ->method('get')
779
            ->with($this->identicalTo('_lug_repository_method'), $this->identicalTo('findForTest'))
780
            ->will($this->returnValue($repositoryMethod = 'findForAction'));
781
782
        $this->assertSame($repositoryMethod, $this->parameterResolver->resolveRepositoryMethod('test'));
783
    }
784
785
    public function testResolveSerializerGroupsWithoutRequest()
786
    {
787
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
788
    }
789
790 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...
791
    {
792
        $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...
793
            ->expects($this->once())
794
            ->method('getMasterRequest')
795
            ->will($this->returnValue($request = $this->createRequestMock()));
796
797
        $request->attributes
798
            ->expects($this->once())
799
            ->method('get')
800
            ->with(
801
                $this->identicalTo('_lug_serializer_groups'),
802
                $this->identicalTo($groups = [])
803
            )
804
            ->will($this->returnValue($groups));
805
806
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
807
    }
808
809
    public function testResolveSerializerGroupsExplicit()
810
    {
811
        $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...
812
            ->expects($this->once())
813
            ->method('getMasterRequest')
814
            ->will($this->returnValue($request = $this->createRequestMock()));
815
816
        $request->attributes
817
            ->expects($this->once())
818
            ->method('get')
819
            ->with(
820
                $this->identicalTo('_lug_serializer_groups'),
821
                $this->identicalTo([])
822
            )
823
            ->will($this->returnValue($groups = ['group']));
824
825
        $this->assertSame($groups, $this->parameterResolver->resolveSerializerGroups());
826
    }
827
828
    public function testResolveSerializerNullWithoutRequest()
829
    {
830
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
831
    }
832
833 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...
834
    {
835
        $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...
836
            ->expects($this->once())
837
            ->method('getMasterRequest')
838
            ->will($this->returnValue($request = $this->createRequestMock()));
839
840
        $request->attributes
841
            ->expects($this->once())
842
            ->method('get')
843
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true))
844
            ->will($this->returnValue($null));
845
846
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
847
    }
848
849
    public function testResolveSerializerNullExplicit()
850
    {
851
        $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...
852
            ->expects($this->once())
853
            ->method('getMasterRequest')
854
            ->will($this->returnValue($request = $this->createRequestMock()));
855
856
        $request->attributes
857
            ->expects($this->once())
858
            ->method('get')
859
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo(true))
860
            ->will($this->returnValue(false));
861
862
        $this->assertFalse($this->parameterResolver->resolveSerializerNull());
863
    }
864
865
    public function testResolveSortingWithoutRequest()
866
    {
867
        $this->assertEmpty($this->parameterResolver->resolveSorting());
868
    }
869
870 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...
871
    {
872
        $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...
873
            ->expects($this->once())
874
            ->method('getMasterRequest')
875
            ->will($this->returnValue($request = $this->createRequestMock()));
876
877
        $request->attributes
878
            ->expects($this->once())
879
            ->method('get')
880
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo($sorting = []))
881
            ->will($this->returnValue($sorting));
882
883
        $this->assertEmpty($this->parameterResolver->resolveSorting());
884
    }
885
886 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...
887
    {
888
        $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...
889
            ->expects($this->once())
890
            ->method('getMasterRequest')
891
            ->will($this->returnValue($request = $this->createRequestMock()));
892
893
        $request->attributes
894
            ->expects($this->once())
895
            ->method('get')
896
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo([]))
897
            ->will($this->returnValue($sorting = ['foo' => 'ASC']));
898
899
        $this->assertSame($sorting, $this->parameterResolver->resolveSorting());
900
    }
901
902
    public function testResolveTemplate()
903
    {
904
        $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...
905
            ->expects($this->exactly(2))
906
            ->method('getMasterRequest')
907
            ->will($this->returnValue($request = $this->createRequestMock()));
908
909
        $request->attributes
910
            ->expects($this->once())
911
            ->method('get')
912
            ->with($this->identicalTo('_lug_template'), $this->isNull())
913
            ->will($this->returnValue($template = 'template'));
914
915
        $this->assertSame($template, $this->parameterResolver->resolveTemplate());
916
    }
917
918
    /**
919
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
920
     * @expectedExceptionMessage The request could not be found.
921
     */
922
    public function testResolveTemplateWithoutRequest()
923
    {
924
        $this->parameterResolver->resolveTemplate();
925
    }
926
927
    /**
928
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
929
     * @expectedExceptionMessage The template could not be found for the route "route".
930
     */
931 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...
932
    {
933
        $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...
934
            ->expects($this->exactly(2))
935
            ->method('getMasterRequest')
936
            ->will($this->returnValue($request = $this->createRequestMock()));
937
938
        $request->attributes
939
            ->expects($this->at(0))
940
            ->method('get')
941
            ->with($this->identicalTo('_lug_template'), $this->isNull())
942
            ->will($this->returnValue(null));
943
944
        $request->attributes
945
            ->expects($this->at(1))
946
            ->method('get')
947
            ->with($this->identicalTo('_route'), $this->isNull())
948
            ->will($this->returnValue('route'));
949
950
        $this->parameterResolver->resolveTemplate();
951
    }
952
953
    public function testResolveThemesWithoutRequest()
954
    {
955
        $this->assertEmpty($this->parameterResolver->resolveThemes());
956
    }
957
958 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...
959
    {
960
        $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...
961
            ->expects($this->once())
962
            ->method('getMasterRequest')
963
            ->will($this->returnValue($request = $this->createRequestMock()));
964
965
        $request->attributes
966
            ->expects($this->once())
967
            ->method('get')
968
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo($themes = []))
969
            ->will($this->returnValue($themes));
970
971
        $this->assertEmpty($this->parameterResolver->resolveThemes());
972
    }
973
974 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...
975
    {
976
        $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...
977
            ->expects($this->once())
978
            ->method('getMasterRequest')
979
            ->will($this->returnValue($request = $this->createRequestMock()));
980
981
        $request->attributes
982
            ->expects($this->once())
983
            ->method('get')
984
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo([]))
985
            ->will($this->returnValue($themes = ['theme']));
986
987
        $this->assertSame($themes, $this->parameterResolver->resolveThemes());
988
    }
989
990
    public function testResolveTranslationDomainWithoutRequest()
991
    {
992
        $this->assertSame('forms', $this->parameterResolver->resolveTranslationDomain());
993
    }
994
995 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...
996
    {
997
        $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...
998
            ->expects($this->exactly(2))
999
            ->method('getMasterRequest')
1000
            ->will($this->returnValue($request = $this->createRequestMock()));
1001
1002
        $request->attributes
1003
            ->expects($this->at(0))
1004
            ->method('get')
1005
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1006
            ->will($this->returnValue(null));
1007
1008
        $request->attributes
1009
            ->expects($this->at(1))
1010
            ->method('get')
1011
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo($translationDomain = 'forms'))
1012
            ->will($this->returnValue($translationDomain));
1013
1014
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1015
    }
1016
1017 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...
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->exactly(2))
1021
            ->method('getMasterRequest')
1022
            ->will($this->returnValue($request = $this->createRequestMock()));
1023
1024
        $request->attributes
1025
            ->expects($this->at(0))
1026
            ->method('get')
1027
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1028
            ->will($this->returnValue(null));
1029
1030
        $request->attributes
1031
            ->expects($this->at(1))
1032
            ->method('get')
1033
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo('forms'))
1034
            ->will($this->returnValue($translationDomain = 'translation_domain'));
1035
1036
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1037
    }
1038
1039 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...
1040
    {
1041
        $this->requestStack
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\HttpFoundation\RequestStack.

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

Let’s take a look at an example:

class A
{
    public function foo() { }
}

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

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

Available Fixes

  1. Add an additional type-check:

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

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1042
            ->expects($this->exactly(2))
1043
            ->method('getMasterRequest')
1044
            ->will($this->returnValue($request = $this->createRequestMock()));
1045
1046
        $request->attributes
1047
            ->expects($this->at(0))
1048
            ->method('get')
1049
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1050
            ->will($this->returnValue(['grid']));
1051
1052
        $request->attributes
1053
            ->expects($this->at(1))
1054
            ->method('get')
1055
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo($translationDomain = 'grids'))
1056
            ->will($this->returnValue($translationDomain));
1057
1058
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1059
    }
1060
1061 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...
1062
    {
1063
        $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...
1064
            ->expects($this->exactly(2))
1065
            ->method('getMasterRequest')
1066
            ->will($this->returnValue($request = $this->createRequestMock()));
1067
1068
        $request->attributes
1069
            ->expects($this->at(0))
1070
            ->method('get')
1071
            ->with($this->identicalTo('_lug_grid'), $this->isNull())
1072
            ->will($this->returnValue(['grid']));
1073
1074
        $request->attributes
1075
            ->expects($this->at(1))
1076
            ->method('get')
1077
            ->with($this->identicalTo('_lug_translation_domain'), $this->identicalTo('grids'))
1078
            ->will($this->returnValue($translationDomain = 'translation_domain'));
1079
1080
        $this->assertSame($translationDomain, $this->parameterResolver->resolveTranslationDomain());
1081
    }
1082
1083
    public function testResolveValidationGroupsWithoutRequest()
1084
    {
1085
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1086
    }
1087
1088 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...
1089
    {
1090
        $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...
1091
            ->expects($this->once())
1092
            ->method('getMasterRequest')
1093
            ->will($this->returnValue($request = $this->createRequestMock()));
1094
1095
        $request->attributes
1096
            ->expects($this->once())
1097
            ->method('get')
1098
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo($groups = []))
1099
            ->will($this->returnValue($groups));
1100
1101
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1102
    }
1103
1104 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...
1105
    {
1106
        $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...
1107
            ->expects($this->once())
1108
            ->method('getMasterRequest')
1109
            ->will($this->returnValue($request = $this->createRequestMock()));
1110
1111
        $request->attributes
1112
            ->expects($this->once())
1113
            ->method('get')
1114
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo([]))
1115
            ->will($this->returnValue($groups = ['group']));
1116
1117
        $this->assertSame($groups, $this->parameterResolver->resolveValidationGroups());
1118
    }
1119
1120
    public function testResolveVoterWithoutRequest()
1121
    {
1122
        $this->assertFalse($this->parameterResolver->resolveVoter());
1123
    }
1124
1125
    public function testResolveVoterDefault()
1126
    {
1127
        $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...
1128
            ->expects($this->once())
1129
            ->method('getMasterRequest')
1130
            ->will($this->returnValue($request = $this->createRequestMock()));
1131
1132
        $request->attributes
1133
            ->expects($this->once())
1134
            ->method('get')
1135
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1136
            ->will($this->returnValue(false));
1137
1138
        $this->assertFalse($this->parameterResolver->resolveVoter());
1139
    }
1140
1141 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...
1142
    {
1143
        $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...
1144
            ->expects($this->once())
1145
            ->method('getMasterRequest')
1146
            ->will($this->returnValue($request = $this->createRequestMock()));
1147
1148
        $request->attributes
1149
            ->expects($this->once())
1150
            ->method('get')
1151
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1152
            ->will($this->returnValue(true));
1153
1154
        $this->assertTrue($this->parameterResolver->resolveVoter());
1155
    }
1156
1157
    /**
1158
     * @return \PHPUnit_Framework_MockObject_MockObject|RequestStack
1159
     */
1160
    private function createRequestStackMock()
1161
    {
1162
        return $this->getMock(RequestStack::class);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1163
    }
1164
1165
    /**
1166
     * @return \PHPUnit_Framework_MockObject_MockObject|PropertyAccessorInterface
1167
     */
1168
    private function createPropertyAccessorMock()
1169
    {
1170
        return $this->getMock(PropertyAccessorInterface::class);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1171
    }
1172
1173
    /**
1174
     * @return \PHPUnit_Framework_MockObject_MockObject|Request
1175
     */
1176
    private function createRequestMock()
1177
    {
1178
        $request = $this->getMock(Request::class);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1179
        $request->attributes = $this->createParameterBagMock();
1180
1181
        return $request;
1182
    }
1183
1184
    /**
1185
     * @return \PHPUnit_Framework_MockObject_MockObject|ParameterBag
1186
     */
1187
    private function createParameterBagMock()
1188
    {
1189
        return $this->getMock(ParameterBag::class);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1190
    }
1191
1192
    /**
1193
     * @return \PHPUnit_Framework_MockObject_MockObject|ResourceInterface
1194
     */
1195
    private function createResourceMock()
1196
    {
1197
        return $this->getMock(ResourceInterface::class);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1198
    }
1199
}
1200