| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Core;
|
|
|
3 |
|
|
|
4 |
class AllOfTest extends \Hamcrest\AbstractMatcherTest
|
|
|
5 |
{
|
|
|
6 |
|
|
|
7 |
protected function createMatcher()
|
|
|
8 |
{
|
|
|
9 |
return \Hamcrest\Core\AllOf::allOf('irrelevant');
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
public function testEvaluatesToTheLogicalConjunctionOfTwoOtherMatchers()
|
|
|
13 |
{
|
|
|
14 |
assertThat('good', allOf('good', 'good'));
|
|
|
15 |
|
|
|
16 |
assertThat('good', not(allOf('bad', 'good')));
|
|
|
17 |
assertThat('good', not(allOf('good', 'bad')));
|
|
|
18 |
assertThat('good', not(allOf('bad', 'bad')));
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
public function testEvaluatesToTheLogicalConjunctionOfManyOtherMatchers()
|
|
|
22 |
{
|
|
|
23 |
assertThat('good', allOf('good', 'good', 'good', 'good', 'good'));
|
|
|
24 |
assertThat('good', not(allOf('good', endsWith('d'), 'bad', 'good', 'good')));
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function testSupportsMixedTypes()
|
|
|
28 |
{
|
|
|
29 |
$all = allOf(
|
|
|
30 |
equalTo(new \Hamcrest\Core\SampleBaseClass('good')),
|
|
|
31 |
equalTo(new \Hamcrest\Core\SampleBaseClass('good')),
|
|
|
32 |
equalTo(new \Hamcrest\Core\SampleSubClass('ugly'))
|
|
|
33 |
);
|
|
|
34 |
|
|
|
35 |
$negated = not($all);
|
|
|
36 |
|
|
|
37 |
assertThat(new \Hamcrest\Core\SampleSubClass('good'), $negated);
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
public function testHasAReadableDescription()
|
|
|
41 |
{
|
|
|
42 |
$this->assertDescription(
|
|
|
43 |
'("good" and "bad" and "ugly")',
|
|
|
44 |
allOf('good', 'bad', 'ugly')
|
|
|
45 |
);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public function testMismatchDescriptionDescribesFirstFailingMatch()
|
|
|
49 |
{
|
|
|
50 |
$this->assertMismatchDescription(
|
|
|
51 |
'"good" was "bad"',
|
|
|
52 |
allOf('bad', 'good'),
|
|
|
53 |
'bad'
|
|
|
54 |
);
|
|
|
55 |
}
|
|
|
56 |
}
|