These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace AerialShip\SamlSPBundle\Tests\RelyingParty; |
||
4 | |||
5 | use AerialShip\SamlSPBundle\RelyingParty\RelyingPartyCollection; |
||
6 | |||
7 | class RelyingPartyCollectionTest extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | /** |
||
10 | * @test |
||
11 | */ |
||
12 | public function shouldImplementsRelyingPartyInterface() |
||
13 | { |
||
14 | $rc = new \ReflectionClass('AerialShip\SamlSPBundle\RelyingParty\RelyingPartyCollection'); |
||
15 | $this->assertTrue($rc->implementsInterface('AerialShip\SamlSPBundle\RelyingParty\RelyingPartyInterface')); |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * @test |
||
20 | */ |
||
21 | public function couldBeConstructedWithoutAnyArguments() |
||
22 | { |
||
23 | new RelyingPartyCollection(); |
||
24 | } |
||
25 | |||
26 | |||
27 | /** |
||
28 | * @test |
||
29 | */ |
||
30 | public function shouldAllowPrependRelyingParty() |
||
31 | { |
||
32 | $collection = new RelyingPartyCollection; |
||
33 | $collection->prepend($this->createRelyingPartyMock()); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @test |
||
38 | */ |
||
39 | public function shouldAllowAppendRelyingParty() |
||
40 | { |
||
41 | $collection = new RelyingPartyCollection; |
||
42 | $collection->append($this->createRelyingPartyMock()); |
||
0 ignored issues
–
show
It seems like
$this->createRelyingPartyMock() targeting AerialShip\SamlSPBundle\...reateRelyingPartyMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @test |
||
47 | */ |
||
48 | public function shouldNotSupportIfCollectionEmpty() |
||
49 | { |
||
50 | $collection = new RelyingPartyCollection; |
||
51 | $this->assertFalse($collection->supports($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...yCollection::supports() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
52 | } |
||
53 | |||
54 | |||
55 | /** |
||
56 | * @test |
||
57 | */ |
||
58 | public function shouldNotSupportIfAnyRelyingPartyInCollectionNotSupport() |
||
59 | { |
||
60 | $relyingPartyOneMock = $this->createRelyingPartyMock(); |
||
61 | $relyingPartyOneMock |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in AerialShip\SamlSPBundle\...y\RelyingPartyInterface .
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
Loading history...
|
|||
62 | ->expects($this->once()) |
||
63 | ->method('supports') |
||
64 | ->will($this->returnValue(false)) |
||
65 | ; |
||
66 | |||
67 | $relyingPartyTwoMock = $this->createRelyingPartyMock(); |
||
68 | $relyingPartyTwoMock |
||
69 | ->expects($this->once()) |
||
70 | ->method('supports') |
||
71 | ->will($this->returnValue(false)) |
||
72 | ; |
||
73 | |||
74 | $collection = new RelyingPartyCollection; |
||
75 | |||
76 | $collection->append($relyingPartyOneMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyOneMock defined by $this->createRelyingPartyMock() on line 60 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
77 | $collection->prepend($relyingPartyTwoMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyTwoMock defined by $this->createRelyingPartyMock() on line 67 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...tyCollection::prepend() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
78 | |||
79 | $this->assertFalse($collection->supports($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...yCollection::supports() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @test |
||
84 | */ |
||
85 | public function shouldSupportIfRelyingPartyInCollectionSupport() |
||
86 | { |
||
87 | $relyingPartyOneMock = $this->createRelyingPartyMock(); |
||
88 | $relyingPartyOneMock |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in AerialShip\SamlSPBundle\...y\RelyingPartyInterface .
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
Loading history...
|
|||
89 | ->expects($this->once()) |
||
90 | ->method('supports') |
||
91 | ->will($this->returnValue(false)) |
||
92 | ; |
||
93 | |||
94 | $relyingPartyTwoMock = $this->createRelyingPartyMock(); |
||
95 | $relyingPartyTwoMock |
||
96 | ->expects($this->once()) |
||
97 | ->method('supports') |
||
98 | ->will($this->returnValue(true)) |
||
99 | ; |
||
100 | |||
101 | $collection = new RelyingPartyCollection; |
||
102 | |||
103 | $collection->append($relyingPartyOneMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyOneMock defined by $this->createRelyingPartyMock() on line 87 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
104 | $collection->append($relyingPartyTwoMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyTwoMock defined by $this->createRelyingPartyMock() on line 94 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
105 | |||
106 | $this->assertTrue($collection->supports($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...yCollection::supports() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
107 | } |
||
108 | |||
109 | |||
110 | /** |
||
111 | * @test |
||
112 | */ |
||
113 | public function shouldStopOnFirstSupportedRelyingPartyWhileCheckingWhetherCollectionSupportOrNot() |
||
114 | { |
||
115 | $relyingPartyOneMock = $this->createRelyingPartyMock(); |
||
116 | $relyingPartyOneMock |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in AerialShip\SamlSPBundle\...y\RelyingPartyInterface .
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
Loading history...
|
|||
117 | ->expects($this->once()) |
||
118 | ->method('supports') |
||
119 | ->will($this->returnValue(true)) |
||
120 | ; |
||
121 | |||
122 | $relyingPartyTwoMock = $this->createRelyingPartyMock(); |
||
123 | $relyingPartyTwoMock |
||
124 | ->expects($this->never()) |
||
125 | ->method('supports') |
||
126 | ; |
||
127 | |||
128 | $collection = new RelyingPartyCollection; |
||
129 | |||
130 | $collection->append($relyingPartyOneMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyOneMock defined by $this->createRelyingPartyMock() on line 115 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
131 | $collection->append($relyingPartyTwoMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyTwoMock defined by $this->createRelyingPartyMock() on line 122 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
132 | |||
133 | $this->assertTrue($collection->supports($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...yCollection::supports() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @test |
||
138 | * |
||
139 | * @expectedException \InvalidArgumentException |
||
140 | * @expectedExceptionMessage The relying party does not support the request |
||
141 | */ |
||
142 | public function throwIfTryManageEmptyCollection() |
||
143 | { |
||
144 | $collection = new RelyingPartyCollection; |
||
145 | $this->assertFalse($collection->supports($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...yCollection::supports() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
146 | $collection->manage($this->createRequestMock()); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::manage() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @test |
||
151 | * |
||
152 | * @expectedException InvalidArgumentException |
||
153 | * @expectedExceptionMessage The relying party does not support the request |
||
154 | */ |
||
155 | public function throwIfTryManageRequestNotSupportedByAnyRelyingPartyInCollection() |
||
156 | { |
||
157 | $relyingPartyOneMock = $this->createRelyingPartyMock(); |
||
158 | $relyingPartyOneMock |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in AerialShip\SamlSPBundle\...y\RelyingPartyInterface .
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
Loading history...
|
|||
159 | ->expects($this->atLeastOnce()) |
||
160 | ->method('supports') |
||
161 | ->will($this->returnValue(false)) |
||
162 | ; |
||
163 | |||
164 | $relyingPartyTwoMock = $this->createRelyingPartyMock(); |
||
165 | $relyingPartyTwoMock |
||
166 | ->expects($this->atLeastOnce()) |
||
167 | ->method('supports') |
||
168 | ->will($this->returnValue(false)) |
||
169 | ; |
||
170 | |||
171 | $collection = new RelyingPartyCollection; |
||
172 | |||
173 | $collection->append($relyingPartyOneMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyOneMock defined by $this->createRelyingPartyMock() on line 157 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
174 | $collection->append($relyingPartyTwoMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyTwoMock defined by $this->createRelyingPartyMock() on line 164 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
175 | |||
176 | $this->assertFalse($collection->supports($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...yCollection::supports() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
177 | |||
178 | $collection->manage($this->createRequestMock()); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::manage() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
179 | } |
||
180 | |||
181 | |||
182 | /** |
||
183 | * @test |
||
184 | */ |
||
185 | public function shouldProxyManagingToRelyingPartyWhichSupportRequest() |
||
186 | { |
||
187 | $expectedRequest = $this->createRequestMock(); |
||
188 | |||
189 | $relyingPartyOneMock = $this->createRelyingPartyMock(); |
||
190 | $relyingPartyOneMock |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in AerialShip\SamlSPBundle\...y\RelyingPartyInterface .
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
Loading history...
|
|||
191 | ->expects($this->any()) |
||
192 | ->method('supports') |
||
193 | ->will($this->returnValue(true)) |
||
194 | ; |
||
195 | $relyingPartyOneMock |
||
196 | ->expects($this->once()) |
||
197 | ->method('manage') |
||
198 | ->with($expectedRequest) |
||
199 | ; |
||
200 | |||
201 | $collection = new RelyingPartyCollection; |
||
202 | |||
203 | $collection->append($relyingPartyOneMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyOneMock defined by $this->createRelyingPartyMock() on line 189 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
204 | |||
205 | $collection->manage($expectedRequest); |
||
0 ignored issues
–
show
It seems like
$expectedRequest defined by $this->createRequestMock() on line 187 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::manage() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
206 | } |
||
207 | |||
208 | |||
209 | /** |
||
210 | * @test |
||
211 | */ |
||
212 | public function shouldReturnResultOfRelyingPartyWhichSupportRequestOnManaging() |
||
213 | { |
||
214 | $expectedResult = 'the_relying_party_result'; |
||
215 | |||
216 | $relyingPartyOneMock = $this->createRelyingPartyMock(); |
||
217 | $relyingPartyOneMock |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in AerialShip\SamlSPBundle\...y\RelyingPartyInterface .
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
Loading history...
|
|||
218 | ->expects($this->any()) |
||
219 | ->method('supports') |
||
220 | ->will($this->returnValue(true)) |
||
221 | ; |
||
222 | $relyingPartyOneMock |
||
223 | ->expects($this->once()) |
||
224 | ->method('manage') |
||
225 | ->will($this->returnValue($expectedResult)) |
||
226 | ; |
||
227 | |||
228 | $collection = new RelyingPartyCollection; |
||
229 | |||
230 | $collection->append($relyingPartyOneMock); |
||
0 ignored issues
–
show
It seems like
$relyingPartyOneMock defined by $this->createRelyingPartyMock() on line 216 can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::append() does only seem to accept object<AerialShip\SamlSP...\RelyingPartyInterface> , 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...
|
|||
231 | |||
232 | $this->assertSame($expectedResult, $collection->manage($this->createRequestMock())); |
||
0 ignored issues
–
show
It seems like
$this->createRequestMock() targeting AerialShip\SamlSPBundle\...st::createRequestMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, AerialShip\SamlSPBundle\...rtyCollection::manage() does only seem to accept object<Symfony\Component\HttpFoundation\Request> , 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...
|
|||
233 | } |
||
234 | |||
235 | /** |
||
236 | * @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\HttpFoundation\Request |
||
237 | */ |
||
238 | public function createRequestMock() |
||
239 | { |
||
240 | return $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); |
||
241 | } |
||
242 | |||
243 | /** |
||
244 | * @return \PHPUnit_Framework_MockObject_MockObject|\AerialShip\SamlSPBundle\RelyingParty\RelyingPartyInterface |
||
245 | */ |
||
246 | public function createRelyingPartyMock() |
||
247 | { |
||
248 | return $this->getMock('AerialShip\SamlSPBundle\RelyingParty\RelyingPartyInterface'); |
||
249 | } |
||
250 | } |
||
251 |
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.