This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of the Cubiche package. |
||
5 | * |
||
6 | * Copyright (c) Cubiche |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | namespace Cubiche\Domain\System\Tests\Units; |
||
12 | |||
13 | use Cubiche\Domain\System\Integer; |
||
14 | use mageekguy\atoum\adapter as Adapter; |
||
15 | use mageekguy\atoum\annotations\extractor as Extractor; |
||
16 | use mageekguy\atoum\asserter\generator as Generator; |
||
17 | use mageekguy\atoum\test\assertion\manager as Manager; |
||
18 | |||
19 | /** |
||
20 | * RealTestCase class. |
||
21 | * |
||
22 | * @author Ivannis Suárez Jerez <[email protected]> |
||
23 | */ |
||
24 | abstract class RealTestCase extends NumberTestCase |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function __construct( |
||
30 | Adapter $adapter = null, |
||
31 | Extractor $annotationExtractor = null, |
||
32 | Generator $asserterGenerator = null, |
||
33 | Manager $assertionManager = null, |
||
34 | \Closure $reflectionClassFactory = null |
||
35 | ) { |
||
36 | parent::__construct( |
||
37 | $adapter, |
||
38 | $annotationExtractor, |
||
39 | $asserterGenerator, |
||
40 | $assertionManager, |
||
41 | $reflectionClassFactory |
||
42 | ); |
||
43 | |||
44 | $this->getAssertionManager() |
||
45 | ->setHandler( |
||
46 | 'positiveInfiniteNativeNumber', |
||
47 | function () { |
||
48 | return $this->positiveInfiniteNativeNumber(); |
||
49 | } |
||
50 | ) |
||
51 | ->setHandler( |
||
52 | 'negativeInfiniteNativeNumber', |
||
53 | function () { |
||
54 | return $this->negativeInfiniteNativeNumber(); |
||
55 | } |
||
56 | ) |
||
57 | ; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @return mixed |
||
62 | */ |
||
63 | abstract protected function positiveInfiniteNativeNumber(); |
||
64 | |||
65 | /** |
||
66 | * @return mixed |
||
67 | */ |
||
68 | abstract protected function negativeInfiniteNativeNumber(); |
||
69 | |||
70 | /* |
||
71 | * Test isInfinite. |
||
72 | */ |
||
73 | View Code Duplication | public function testIsInfinite() |
|
0 ignored issues
–
show
|
|||
74 | { |
||
75 | parent::testIsInfinite(); |
||
76 | |||
77 | $this |
||
78 | ->given( |
||
79 | $positiveInfinite = $this->positiveInfiniteNativeNumber(), |
||
80 | $number = $this->fromNative($positiveInfinite) |
||
81 | ) |
||
82 | ->then |
||
83 | ->boolean($number->isInfinite()) |
||
84 | ->isTrue() |
||
85 | ; |
||
86 | |||
87 | $this |
||
88 | ->given( |
||
89 | $negativeInfinite = $this->negativeInfiniteNativeNumber(), |
||
90 | $number = $this->fromNative($negativeInfinite) |
||
91 | ) |
||
92 | ->then |
||
93 | ->boolean($number->isInfinite()) |
||
94 | ->isTrue() |
||
95 | ; |
||
96 | } |
||
97 | |||
98 | /* |
||
99 | * Test isPositive. |
||
100 | */ |
||
101 | View Code Duplication | public function testIsPositive() |
|
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. ![]() |
|||
102 | { |
||
103 | parent::testIsPositive(); |
||
104 | |||
105 | $this |
||
106 | ->given( |
||
107 | $positiveInfinite = $this->positiveInfiniteNativeNumber(), |
||
108 | $number = $this->fromNative($positiveInfinite) |
||
109 | ) |
||
110 | ->then |
||
111 | ->boolean($number->isPositive()) |
||
112 | ->isTrue() |
||
113 | ; |
||
114 | |||
115 | $this |
||
116 | ->given( |
||
117 | $negativeInfinite = $this->negativeInfiniteNativeNumber(), |
||
118 | $number = $this->fromNative($negativeInfinite) |
||
119 | ) |
||
120 | ->then |
||
121 | ->boolean($number->isPositive()) |
||
122 | ->isFalse() |
||
123 | ; |
||
124 | } |
||
125 | |||
126 | /* |
||
127 | * Test isNegative. |
||
128 | */ |
||
129 | View Code Duplication | public function testIsNegative() |
|
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. ![]() |
|||
130 | { |
||
131 | parent::testIsNegative(); |
||
132 | |||
133 | $this |
||
134 | ->given( |
||
135 | $positiveInfinite = $this->positiveInfiniteNativeNumber(), |
||
136 | $number = $this->fromNative($positiveInfinite) |
||
137 | ) |
||
138 | ->then |
||
139 | ->boolean($number->isNegative()) |
||
140 | ->isFalse() |
||
141 | ; |
||
142 | |||
143 | $this |
||
144 | ->given( |
||
145 | $negativeInfinite = $this->negativeInfiniteNativeNumber(), |
||
146 | $number = $this->fromNative($negativeInfinite) |
||
147 | ) |
||
148 | ->then |
||
149 | ->boolean($number->isNegative()) |
||
150 | ->isTrue() |
||
151 | ; |
||
152 | } |
||
153 | |||
154 | /* |
||
155 | * Test add. |
||
156 | */ |
||
157 | View Code Duplication | public function testAdd() |
|
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. ![]() |
|||
158 | { |
||
159 | parent::testAdd(); |
||
160 | |||
161 | $this |
||
162 | ->given( |
||
163 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
||
164 | $negativeInfinite = $this->fromNative($this->negativeInfiniteNativeNumber()), |
||
165 | $number = $this->fromNative($this->randomNativeNumber()) |
||
166 | ) |
||
167 | ->then |
||
168 | ->boolean($number->add($positiveInfinite)->equals($positiveInfinite)) |
||
169 | ->isTrue() |
||
170 | ->boolean($positiveInfinite->add($number)->equals($positiveInfinite)) |
||
171 | ->isTrue() |
||
172 | ->boolean($number->add($negativeInfinite)->equals($negativeInfinite)) |
||
173 | ->isTrue() |
||
174 | ->boolean($negativeInfinite->add($number)->equals($negativeInfinite)) |
||
175 | ->isTrue() |
||
176 | ->boolean($positiveInfinite->add($positiveInfinite)->equals($positiveInfinite)) |
||
177 | ->isTrue() |
||
178 | ->boolean($negativeInfinite->add($negativeInfinite)->equals($negativeInfinite)) |
||
179 | ->isTrue() |
||
180 | ->exception(function () use ($positiveInfinite, $negativeInfinite) { |
||
181 | $positiveInfinite->add($negativeInfinite); |
||
182 | })->isInstanceOf(\Exception::class) |
||
183 | ; |
||
184 | } |
||
185 | |||
186 | /* |
||
187 | * Test sub. |
||
188 | */ |
||
189 | View Code Duplication | public function testSub() |
|
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. ![]() |
|||
190 | { |
||
191 | parent::testSub(); |
||
192 | |||
193 | $this |
||
194 | ->given( |
||
195 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
||
196 | $negativeInfinite = $this->fromNative($this->negativeInfiniteNativeNumber()), |
||
197 | $number = $this->fromNative($this->randomNativeNumber()) |
||
198 | ) |
||
199 | ->then |
||
200 | ->boolean($number->sub($positiveInfinite)->equals($negativeInfinite)) |
||
201 | ->isTrue() |
||
202 | ->boolean($positiveInfinite->sub($number)->equals($positiveInfinite)) |
||
203 | ->isTrue() |
||
204 | ->boolean($number->sub($negativeInfinite)->equals($positiveInfinite)) |
||
205 | ->isTrue() |
||
206 | ->boolean($negativeInfinite->sub($number)->equals($negativeInfinite)) |
||
207 | ->isTrue() |
||
208 | ->boolean($positiveInfinite->sub($negativeInfinite)->equals($positiveInfinite)) |
||
209 | ->isTrue() |
||
210 | ->boolean($negativeInfinite->sub($positiveInfinite)->equals($negativeInfinite)) |
||
211 | ->isTrue() |
||
212 | ->exception(function () use ($positiveInfinite) { |
||
213 | $positiveInfinite->sub($positiveInfinite); |
||
214 | })->isInstanceOf(\Exception::class) |
||
215 | ; |
||
216 | } |
||
217 | |||
218 | /* |
||
219 | * Test mult. |
||
220 | */ |
||
221 | public function testMult() |
||
222 | { |
||
223 | parent::testMult(); |
||
224 | |||
225 | $this |
||
226 | ->given( |
||
227 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
||
228 | $negativeInfinite = $this->fromNative($this->negativeInfiniteNativeNumber()), |
||
229 | $number = $this->fromNative($this->randomNativeNumber()), |
||
230 | $negativeNumber = $this->fromNative($this->negativeNativeNumber()) |
||
231 | ) |
||
232 | ->then |
||
233 | ->boolean($number->mult($positiveInfinite)->equals($positiveInfinite)) |
||
234 | ->isTrue() |
||
235 | ->boolean($positiveInfinite->mult($number)->equals($positiveInfinite)) |
||
236 | ->isTrue() |
||
237 | ->boolean($number->mult($negativeInfinite)->equals($negativeInfinite)) |
||
238 | ->isTrue() |
||
239 | ->boolean($negativeInfinite->mult($number)->equals($negativeInfinite)) |
||
240 | ->isTrue() |
||
241 | |||
242 | ->boolean($negativeNumber->mult($positiveInfinite)->equals($negativeInfinite)) |
||
243 | ->isTrue() |
||
244 | ->boolean($positiveInfinite->mult($negativeNumber)->equals($negativeInfinite)) |
||
245 | ->isTrue() |
||
246 | ->boolean($negativeNumber->mult($negativeInfinite)->equals($positiveInfinite)) |
||
247 | ->isTrue() |
||
248 | ->boolean($negativeInfinite->mult($negativeNumber)->equals($positiveInfinite)) |
||
249 | ->isTrue() |
||
250 | |||
251 | ->boolean($positiveInfinite->mult($positiveInfinite)->equals($positiveInfinite)) |
||
252 | ->isTrue() |
||
253 | ->boolean($negativeInfinite->mult($negativeInfinite)->equals($positiveInfinite)) |
||
254 | ->isTrue() |
||
255 | ->boolean($positiveInfinite->mult($negativeInfinite)->equals($negativeInfinite)) |
||
256 | ->isTrue() |
||
257 | ->boolean($negativeInfinite->mult($positiveInfinite)->equals($negativeInfinite)) |
||
258 | ->isTrue() |
||
259 | |||
260 | ->exception(function () use ($positiveInfinite) { |
||
261 | $zero = $this->fromNative(0); |
||
262 | $positiveInfinite->mult($zero); |
||
263 | })->isInstanceOf(\Exception::class) |
||
264 | ; |
||
265 | } |
||
266 | |||
267 | /* |
||
268 | * Test div. |
||
269 | */ |
||
270 | public function testDiv() |
||
271 | { |
||
272 | parent::testDiv(); |
||
273 | |||
274 | $this |
||
275 | ->given( |
||
276 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
||
277 | $negativeInfinite = $this->fromNative($this->negativeInfiniteNativeNumber()), |
||
278 | $number = $this->fromNative($this->randomNativeNumber()), |
||
279 | $negativeNumber = $this->fromNative($this->negativeNativeNumber()) |
||
280 | ) |
||
281 | ->then |
||
282 | ->boolean($number->div($positiveInfinite)->isZero()) |
||
283 | ->isTrue() |
||
284 | ->boolean($number->div($negativeInfinite)->isZero()) |
||
285 | ->isTrue() |
||
286 | |||
287 | ->boolean($positiveInfinite->div($number)->equals($positiveInfinite)) |
||
288 | ->isTrue() |
||
289 | ->boolean($negativeInfinite->div($number)->equals($negativeInfinite)) |
||
290 | ->isTrue() |
||
291 | ->boolean($positiveInfinite->div($negativeNumber)->equals($negativeInfinite)) |
||
292 | ->isTrue() |
||
293 | ->boolean($negativeInfinite->div($negativeNumber)->equals($positiveInfinite)) |
||
294 | ->isTrue() |
||
295 | |||
296 | ->exception(function () use ($positiveInfinite) { |
||
297 | $positiveInfinite->div($positiveInfinite); |
||
298 | })->isInstanceOf(\Exception::class) |
||
299 | ; |
||
300 | } |
||
301 | |||
302 | /* |
||
303 | * Test pow. |
||
304 | */ |
||
305 | public function testPow() |
||
306 | { |
||
307 | parent::testPow(); |
||
308 | |||
309 | $this |
||
310 | ->given( |
||
311 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
||
312 | $negativeInfinite = $this->fromNative($this->negativeInfiniteNativeNumber()), |
||
313 | $number = $this->fromNative($this->randomNativeNumber()), |
||
314 | $negativeNumber = $this->fromNative($this->negativeNativeNumber()) |
||
315 | ) |
||
316 | ->then |
||
317 | ->boolean($number->pow($positiveInfinite)->equals($positiveInfinite)) |
||
318 | ->isTrue() |
||
319 | ->boolean($number->pow($negativeInfinite)->isZero()) |
||
320 | ->isTrue() |
||
321 | |||
322 | ->boolean($positiveInfinite->pow($number)->equals($positiveInfinite)) |
||
323 | ->isTrue() |
||
324 | ->boolean($positiveInfinite->pow($number->toInteger())->equals($positiveInfinite)) |
||
325 | ->isTrue() |
||
326 | ->boolean($positiveInfinite->pow($number->toReal())->equals($positiveInfinite)) |
||
327 | ->isTrue() |
||
328 | |||
329 | ->boolean($positiveInfinite->pow($negativeNumber)->isZero()) |
||
330 | ->isTrue() |
||
331 | ->boolean($negativeInfinite->pow($negativeNumber)->isZero()) |
||
332 | ->isTrue() |
||
333 | |||
334 | ->boolean( |
||
335 | $negativeInfinite->pow( |
||
336 | $number->toInteger()->mult(Integer::fromNative(2)) |
||
337 | )->equals($positiveInfinite) |
||
338 | )->isTrue() |
||
339 | ->boolean( |
||
340 | $negativeInfinite->pow( |
||
341 | $number->toInteger()->mult(Integer::fromNative(2))->inc() |
||
342 | )->equals($negativeInfinite) |
||
343 | )->isTrue() |
||
344 | ; |
||
345 | } |
||
346 | |||
347 | /* |
||
348 | * Test compareTo. |
||
349 | */ |
||
350 | public function testCompareTo() |
||
351 | { |
||
352 | parent::testCompareTo(); |
||
353 | |||
354 | $this |
||
355 | ->given( |
||
356 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
||
357 | $negativeInfinite = $this->fromNative($this->negativeInfiniteNativeNumber()), |
||
358 | $number = $this->fromNative($this->randomNativeNumber()) |
||
359 | ) |
||
360 | ->then |
||
361 | ->variable($number->compareTo($positiveInfinite)) |
||
362 | ->isEqualTo(-1) |
||
363 | ->variable($number->compareTo($negativeInfinite)) |
||
364 | ->isEqualTo(1) |
||
365 | ->variable($negativeInfinite->compareTo($number)) |
||
366 | ->isEqualTo(-1) |
||
367 | ->variable($positiveInfinite->compareTo($number)) |
||
368 | ->isEqualTo(1) |
||
369 | ->variable($positiveInfinite->compareTo($negativeInfinite)) |
||
370 | ->isEqualTo(1) |
||
371 | ->variable($negativeInfinite->compareTo($positiveInfinite)) |
||
372 | ->isEqualTo(-1) |
||
373 | ->exception(function () use ($positiveInfinite) { |
||
374 | $positiveInfinite->compareTo($positiveInfinite); |
||
375 | })->isInstanceOf(\Exception::class) |
||
376 | ; |
||
377 | } |
||
378 | } |
||
379 |
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.