1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Cubiche package. |
4
|
|
|
* |
5
|
|
|
* Copyright (c) Cubiche |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace Cubiche\Core\Specification\Tests\Units\Quantifier; |
11
|
|
|
|
12
|
|
|
use Cubiche\Core\Specification\Criteria; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* At Least Tests Class. |
16
|
|
|
* |
17
|
|
|
* @author Ivannis Suárez Jerez <[email protected]> |
18
|
|
|
* @author Karel Osorio Ramírez <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class AtLeastTests extends QuantifierTestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function defaultConstructorArguments() |
26
|
|
|
{ |
27
|
|
|
return array(2, Criteria::this(), Criteria::gt(5)); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
protected function evaluateSuccessDataProvider() |
34
|
|
|
{ |
35
|
|
|
return array( |
36
|
|
|
array(array(4, 6, 5, 3, 9)), |
37
|
|
|
array(array(4, 6, 5, 8, 9)), |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
View Code Duplication |
protected function evaluateFailureDataProvider() |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
return array( |
47
|
|
|
array(array(1, 4, 5, 3, 5)), |
48
|
|
|
array(array()), |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Test evaluate at least zero. |
54
|
|
|
*/ |
55
|
|
|
public function testEvaluateAtLeastZero() |
56
|
|
|
{ |
57
|
|
|
$this |
58
|
|
|
->given($atLeast = $this->newTestedInstance(0, Criteria::this(), Criteria::gt(5))) |
59
|
|
|
->then() |
60
|
|
|
->boolean($atLeast->evaluate(array())) |
61
|
|
|
->isTrue() |
62
|
|
|
->boolean($atLeast->evaluate(array(1, 2, 3))) |
63
|
|
|
->isTrue() |
64
|
|
|
; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.