| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Core;
|
|
|
3 |
|
|
|
4 |
class AnyOfTest extends \Hamcrest\AbstractMatcherTest
|
|
|
5 |
{
|
|
|
6 |
|
|
|
7 |
protected function createMatcher()
|
|
|
8 |
{
|
|
|
9 |
return \Hamcrest\Core\AnyOf::anyOf('irrelevant');
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
public function testAnyOfEvaluatesToTheLogicalDisjunctionOfTwoOtherMatchers()
|
|
|
13 |
{
|
|
|
14 |
assertThat('good', anyOf('bad', 'good'));
|
|
|
15 |
assertThat('good', anyOf('good', 'good'));
|
|
|
16 |
assertThat('good', anyOf('good', 'bad'));
|
|
|
17 |
|
|
|
18 |
assertThat('good', not(anyOf('bad', startsWith('b'))));
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
public function testAnyOfEvaluatesToTheLogicalDisjunctionOfManyOtherMatchers()
|
|
|
22 |
{
|
|
|
23 |
assertThat('good', anyOf('bad', 'good', 'bad', 'bad', 'bad'));
|
|
|
24 |
assertThat('good', not(anyOf('bad', 'bad', 'bad', 'bad', 'bad')));
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function testAnyOfSupportsMixedTypes()
|
|
|
28 |
{
|
|
|
29 |
$combined = anyOf(
|
|
|
30 |
equalTo(new \Hamcrest\Core\SampleBaseClass('good')),
|
|
|
31 |
equalTo(new \Hamcrest\Core\SampleBaseClass('ugly')),
|
|
|
32 |
equalTo(new \Hamcrest\Core\SampleSubClass('good'))
|
|
|
33 |
);
|
|
|
34 |
|
|
|
35 |
assertThat(new \Hamcrest\Core\SampleSubClass('good'), $combined);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public function testAnyOfHasAReadableDescription()
|
|
|
39 |
{
|
|
|
40 |
$this->assertDescription(
|
|
|
41 |
'("good" or "bad" or "ugly")',
|
|
|
42 |
anyOf('good', 'bad', 'ugly')
|
|
|
43 |
);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public function testNoneOfEvaluatesToTheLogicalDisjunctionOfTwoOtherMatchers()
|
|
|
47 |
{
|
|
|
48 |
assertThat('good', not(noneOf('bad', 'good')));
|
|
|
49 |
assertThat('good', not(noneOf('good', 'good')));
|
|
|
50 |
assertThat('good', not(noneOf('good', 'bad')));
|
|
|
51 |
|
|
|
52 |
assertThat('good', noneOf('bad', startsWith('b')));
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public function testNoneOfEvaluatesToTheLogicalDisjunctionOfManyOtherMatchers()
|
|
|
56 |
{
|
|
|
57 |
assertThat('good', not(noneOf('bad', 'good', 'bad', 'bad', 'bad')));
|
|
|
58 |
assertThat('good', noneOf('bad', 'bad', 'bad', 'bad', 'bad'));
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
public function testNoneOfSupportsMixedTypes()
|
|
|
62 |
{
|
|
|
63 |
$combined = noneOf(
|
|
|
64 |
equalTo(new \Hamcrest\Core\SampleBaseClass('good')),
|
|
|
65 |
equalTo(new \Hamcrest\Core\SampleBaseClass('ugly')),
|
|
|
66 |
equalTo(new \Hamcrest\Core\SampleSubClass('good'))
|
|
|
67 |
);
|
|
|
68 |
|
|
|
69 |
assertThat(new \Hamcrest\Core\SampleSubClass('bad'), $combined);
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
public function testNoneOfHasAReadableDescription()
|
|
|
73 |
{
|
|
|
74 |
$this->assertDescription(
|
|
|
75 |
'not ("good" or "bad" or "ugly")',
|
|
|
76 |
noneOf('good', 'bad', 'ugly')
|
|
|
77 |
);
|
|
|
78 |
}
|
|
|
79 |
}
|