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 AlgoWeb\ODataMetadata\Tests\v3\edm\EntityContainer; |
||
4 | |||
5 | use AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\EntitySetAnonymousType; |
||
6 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType; |
||
7 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType; |
||
8 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TValueAnnotationType; |
||
9 | use AlgoWeb\ODataMetadata\Tests\TestCase; |
||
10 | use Mockery as m; |
||
11 | |||
12 | class EntitySetAnonymousTypeTest extends TestCase |
||
13 | { |
||
14 | public function testSetBadName() |
||
15 | { |
||
16 | $expected = "Name must be a valid TSimpleIdentifier"; |
||
17 | $actual = null; |
||
18 | |||
19 | $foo = new EntitySetAnonymousType(); |
||
20 | $name = " _ "; |
||
21 | |||
22 | try { |
||
23 | $foo->setName($name); |
||
24 | } catch (\InvalidArgumentException $e) { |
||
25 | $actual = $e->getMessage(); |
||
26 | } |
||
27 | $this->assertEquals($expected, $actual); |
||
28 | } |
||
29 | |||
30 | public function testSetBadEntityType() |
||
31 | { |
||
32 | $expected = "Entity type must be a valid TQualifiedName"; |
||
33 | $actual = null; |
||
34 | |||
35 | $foo = new EntitySetAnonymousType(); |
||
36 | $name = " _ "; |
||
37 | |||
38 | try { |
||
39 | $foo->setEntityType($name); |
||
40 | } catch (\InvalidArgumentException $e) { |
||
41 | $actual = $e->getMessage(); |
||
42 | } |
||
43 | $this->assertEquals($expected, $actual); |
||
44 | } |
||
45 | |||
46 | public function testSetBadGetterAccess() |
||
47 | { |
||
48 | $expected = "Getter access must be a valid TAccess"; |
||
49 | $actual = null; |
||
50 | |||
51 | $foo = new EntitySetAnonymousType(); |
||
52 | $name = " _ "; |
||
53 | |||
54 | try { |
||
55 | $foo->setGetterAccess($name); |
||
56 | } catch (\InvalidArgumentException $e) { |
||
57 | $actual = $e->getMessage(); |
||
58 | } |
||
59 | $this->assertEquals($expected, $actual); |
||
60 | } |
||
61 | |||
62 | View Code Duplication | public function testIsTEntitySetAttributesOKBadName() |
|
63 | { |
||
64 | $expectedStarts = "Name must be a valid TSimpleIdentifier"; |
||
65 | $expectedEnds = "AlgoWeb_ODataMetadata_MetadataV3_edm_EntityContainer_EntitySetAnonymousType"; |
||
66 | $actual = null; |
||
67 | |||
68 | $foo = m::mock(EntitySetAnonymousType::class)->makePartial(); |
||
69 | $foo->shouldReceive('isTSimpleIdentifierValid')->andReturn(true, false)->twice(); |
||
70 | |||
71 | $foo->setName(" _ "); |
||
72 | |||
73 | $this->assertFalse($foo->isTEntitySetAttributesOK($actual)); |
||
74 | $this->assertStringStartsWith($expectedStarts, $actual); |
||
75 | $this->assertStringEndsWith($expectedEnds, $actual); |
||
76 | } |
||
77 | |||
78 | View Code Duplication | public function testIsTEntitySetAttributesOKBadEntityType() |
|
79 | { |
||
80 | $expectedStarts = "Entity type must be a valid TQualifiedName"; |
||
81 | $expectedEnds = "AlgoWeb_ODataMetadata_MetadataV3_edm_EntityContainer_EntitySetAnonymousType"; |
||
82 | $actual = null; |
||
83 | |||
84 | $foo = m::mock(EntitySetAnonymousType::class)->makePartial(); |
||
85 | $foo->shouldReceive('isTQualifiedNameValid')->andReturn(true, false)->twice(); |
||
86 | |||
87 | $foo->setEntityType(" _ "); |
||
88 | |||
89 | $this->assertFalse($foo->isTEntitySetAttributesOK($actual)); |
||
90 | $this->assertStringStartsWith($expectedStarts, $actual); |
||
91 | $this->assertStringEndsWith($expectedEnds, $actual); |
||
92 | } |
||
93 | |||
94 | View Code Duplication | public function testIsTEntitySetAttributesOKBadGetterAccess() |
|
95 | { |
||
96 | $expectedStarts = "Getter access must be a valid TAccess"; |
||
97 | $expectedEnds = "AlgoWeb_ODataMetadata_MetadataV3_edm_EntityContainer_EntitySetAnonymousType"; |
||
98 | $actual = null; |
||
99 | |||
100 | $foo = m::mock(EntitySetAnonymousType::class)->makePartial(); |
||
101 | $foo->shouldReceive('isTAccessOk')->andReturn(true, false)->twice(); |
||
102 | |||
103 | $foo->setGetterAccess(" _ "); |
||
104 | |||
105 | $this->assertFalse($foo->isTEntitySetAttributesOK($actual)); |
||
106 | $this->assertStringStartsWith($expectedStarts, $actual); |
||
107 | $this->assertStringEndsWith($expectedEnds, $actual); |
||
108 | } |
||
109 | |||
110 | View Code Duplication | public function testSetBadTypeAnnotation() |
|
0 ignored issues
–
show
|
|||
111 | { |
||
112 | $expected = ""; |
||
113 | $actual = null; |
||
114 | |||
115 | $type = m::mock(TTypeAnnotationType::class)->makePartial(); |
||
116 | $type->shouldReceive('isOK')->andReturn(false); |
||
117 | |||
118 | $foo = new EntitySetAnonymousType(); |
||
119 | |||
120 | try { |
||
121 | $foo->setTypeAnnotation([$type]); |
||
1 ignored issue
–
show
array($type) is of type array<integer,object<Moc...bject<Mockery\\Mock>"}> , but the function expects a array<integer,object<Alg...m\TTypeAnnotationType>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
122 | } catch (\InvalidArgumentException $e) { |
||
123 | $actual = $e->getMessage(); |
||
124 | } |
||
125 | $this->assertEquals($expected, $actual); |
||
126 | } |
||
127 | |||
128 | View Code Duplication | public function testAddBadTypeAnnotation() |
|
0 ignored issues
–
show
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...
|
|||
129 | { |
||
130 | $expected = ''; |
||
131 | $actual = null; |
||
132 | |||
133 | $type = m::mock(TTypeAnnotationType::class)->makePartial(); |
||
134 | $type->shouldReceive('isOK')->andReturn(false); |
||
135 | |||
136 | $foo = new EntitySetAnonymousType(); |
||
137 | |||
138 | try { |
||
139 | $foo->addToTypeAnnotation($type); |
||
1 ignored issue
–
show
$type is of type object<Mockery\Mock> , but the function expects a object<AlgoWeb\ODataMeta...dm\TTypeAnnotationType> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
140 | } catch (\InvalidArgumentException $e) { |
||
141 | $actual = $e->getMessage(); |
||
142 | } |
||
143 | $this->assertEquals($expected, $actual); |
||
144 | } |
||
145 | |||
146 | View Code Duplication | public function testAddGoodTypeAnnotation() |
|
0 ignored issues
–
show
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...
|
|||
147 | { |
||
148 | $type = m::mock(TTypeAnnotationType::class)->makePartial(); |
||
149 | $type->shouldReceive('isOK')->andReturn(true); |
||
150 | |||
151 | $foo = new EntitySetAnonymousType(); |
||
152 | |||
153 | $foo->addToTypeAnnotation($type); |
||
1 ignored issue
–
show
$type is of type object<Mockery\Mock> , but the function expects a object<AlgoWeb\ODataMeta...dm\TTypeAnnotationType> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
154 | $this->assertTrue($foo->issetTypeAnnotation(0)); |
||
155 | $foo->unsetTypeAnnotation(0); |
||
156 | $this->assertFalse($foo->issetTypeAnnotation(0)); |
||
157 | } |
||
158 | |||
159 | View Code Duplication | public function testAddBadDocumentation() |
|
0 ignored issues
–
show
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...
|
|||
160 | { |
||
161 | $expected = ''; |
||
162 | $actual = null; |
||
163 | |||
164 | $doc = m::mock(TDocumentationType::class); |
||
165 | $doc->shouldReceive('isOK')->andReturn(false); |
||
1 ignored issue
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
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...
|
|||
166 | |||
167 | $foo = new EntitySetAnonymousType(); |
||
168 | |||
169 | try { |
||
170 | $foo->addToDocumentation($doc); |
||
171 | } catch (\InvalidArgumentException $e) { |
||
172 | $actual = $e->getMessage(); |
||
173 | } |
||
174 | $this->assertEquals($expected, $actual); |
||
175 | } |
||
176 | |||
177 | View Code Duplication | public function testAddGoodDocumentation() |
|
0 ignored issues
–
show
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...
|
|||
178 | { |
||
179 | $doc = m::mock(TDocumentationType::class); |
||
180 | $doc->shouldReceive('isOK')->andReturn(true); |
||
1 ignored issue
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
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...
|
|||
181 | |||
182 | $foo = new EntitySetAnonymousType(); |
||
183 | |||
184 | $foo->addToDocumentation($doc); |
||
185 | $this->assertTrue($foo->issetDocumentation(0)); |
||
186 | $foo->unsetDocumentation(0); |
||
187 | $this->assertFalse($foo->issetDocumentation(0)); |
||
188 | } |
||
189 | |||
190 | View Code Duplication | public function testSetBadDocumentation() |
|
0 ignored issues
–
show
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...
|
|||
191 | { |
||
192 | $expected = ''; |
||
193 | $actual = null; |
||
194 | |||
195 | $doc = m::mock(TDocumentationType::class); |
||
196 | $doc->shouldReceive('isOK')->andReturn(false); |
||
1 ignored issue
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
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...
|
|||
197 | |||
198 | $foo = new EntitySetAnonymousType(); |
||
199 | |||
200 | try { |
||
201 | $foo->setDocumentation([$doc]); |
||
1 ignored issue
–
show
array($doc) is of type array<integer,object<Moc...kery\\MockInterface>"}> , but the function expects a array<integer,object<Alg...dm\TDocumentationType>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
202 | } catch (\InvalidArgumentException $e) { |
||
203 | $actual = $e->getMessage(); |
||
204 | } |
||
205 | $this->assertEquals($expected, $actual); |
||
206 | } |
||
207 | |||
208 | View Code Duplication | public function testSetBadValueAnnotation() |
|
0 ignored issues
–
show
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...
|
|||
209 | { |
||
210 | $expected = ""; |
||
211 | $actual = null; |
||
212 | |||
213 | $type = m::mock(TValueAnnotationType::class)->makePartial(); |
||
214 | $type->shouldReceive('isOK')->andReturn(false); |
||
215 | |||
216 | $foo = new EntitySetAnonymousType(); |
||
217 | |||
218 | try { |
||
219 | $foo->setValueAnnotation([$type]); |
||
1 ignored issue
–
show
array($type) is of type array<integer,object<Moc...bject<Mockery\\Mock>"}> , but the function expects a array<integer,object<Alg...\TValueAnnotationType>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
220 | } catch (\InvalidArgumentException $e) { |
||
221 | $actual = $e->getMessage(); |
||
222 | } |
||
223 | $this->assertEquals($expected, $actual); |
||
224 | } |
||
225 | |||
226 | View Code Duplication | public function testAddBadValueAnnotation() |
|
0 ignored issues
–
show
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...
|
|||
227 | { |
||
228 | $expected = ''; |
||
229 | $actual = null; |
||
230 | |||
231 | $type = m::mock(TValueAnnotationType::class)->makePartial(); |
||
232 | $type->shouldReceive('isOK')->andReturn(false); |
||
233 | |||
234 | $foo = new EntitySetAnonymousType(); |
||
235 | |||
236 | try { |
||
237 | $foo->addToValueAnnotation($type); |
||
1 ignored issue
–
show
$type is of type object<Mockery\Mock> , but the function expects a object<AlgoWeb\ODataMeta...m\TValueAnnotationType> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
238 | } catch (\InvalidArgumentException $e) { |
||
239 | $actual = $e->getMessage(); |
||
240 | } |
||
241 | $this->assertEquals($expected, $actual); |
||
242 | } |
||
243 | |||
244 | View Code Duplication | public function testAddGoodValueAnnotation() |
|
0 ignored issues
–
show
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...
|
|||
245 | { |
||
246 | $type = m::mock(TValueAnnotationType::class)->makePartial(); |
||
247 | $type->shouldReceive('isOK')->andReturn(true); |
||
248 | |||
249 | $foo = new EntitySetAnonymousType(); |
||
250 | |||
251 | $foo->addToValueAnnotation($type); |
||
1 ignored issue
–
show
$type is of type object<Mockery\Mock> , but the function expects a object<AlgoWeb\ODataMeta...m\TValueAnnotationType> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
252 | $this->assertTrue($foo->issetValueAnnotation(0)); |
||
253 | $foo->unsetValueAnnotation(0); |
||
254 | $this->assertFalse($foo->issetValueAnnotation(0)); |
||
255 | } |
||
256 | |||
257 | View Code Duplication | public function testIsOkTooManyDocumentation() |
|
0 ignored issues
–
show
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...
|
|||
258 | { |
||
259 | $expected = 'Supplied array not a valid array: ' |
||
260 | .'AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\EntitySetAnonymousType'; |
||
261 | $actual = null; |
||
262 | |||
263 | $doc = m::mock(TDocumentationType::class); |
||
264 | $doc->shouldReceive('isOK')->andReturn(true); |
||
1 ignored issue
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
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...
|
|||
265 | |||
266 | $foo = new EntitySetAnonymousType(); |
||
267 | $foo->addToDocumentation($doc); |
||
268 | $foo->addToDocumentation($doc); |
||
269 | |||
270 | $this->assertFalse($foo->isOK($actual)); |
||
271 | $this->assertEquals($expected, $actual); |
||
272 | } |
||
273 | |||
274 | View Code Duplication | public function testIsOKBadTypeAnnotations() |
|
0 ignored issues
–
show
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...
|
|||
275 | { |
||
276 | $expected = ''; |
||
277 | $actual = null; |
||
278 | |||
279 | $type = m::mock(TTypeAnnotationType::class)->makePartial(); |
||
280 | $type->shouldReceive('isOK')->andReturn(true, false)->twice(); |
||
281 | |||
282 | $foo = new EntitySetAnonymousType(); |
||
283 | $foo->addToTypeAnnotation($type); |
||
1 ignored issue
–
show
$type is of type object<Mockery\Mock> , but the function expects a object<AlgoWeb\ODataMeta...dm\TTypeAnnotationType> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
284 | |||
285 | $this->assertFalse($foo->isOK($actual)); |
||
286 | $this->assertEquals($expected, $actual); |
||
287 | } |
||
288 | |||
289 | View Code Duplication | public function testIsOKBadValueAnnotations() |
|
0 ignored issues
–
show
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...
|
|||
290 | { |
||
291 | $expected = ''; |
||
292 | $actual = null; |
||
293 | |||
294 | $type = m::mock(TValueAnnotationType::class)->makePartial(); |
||
295 | $type->shouldReceive('isOK')->andReturn(true, false)->twice(); |
||
296 | |||
297 | $foo = new EntitySetAnonymousType(); |
||
298 | $foo->addToValueAnnotation($type); |
||
1 ignored issue
–
show
$type is of type object<Mockery\Mock> , but the function expects a object<AlgoWeb\ODataMeta...m\TValueAnnotationType> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
299 | |||
300 | $this->assertFalse($foo->isOK($actual)); |
||
301 | $this->assertEquals($expected, $actual); |
||
302 | } |
||
303 | } |
||
304 |
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.