| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Core;
|
|
|
3 |
|
|
|
4 |
class EveryTest extends \Hamcrest\AbstractMatcherTest
|
|
|
5 |
{
|
|
|
6 |
|
|
|
7 |
protected function createMatcher()
|
|
|
8 |
{
|
|
|
9 |
return \Hamcrest\Core\Every::everyItem(anything());
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
public function testIsTrueWhenEveryValueMatches()
|
|
|
13 |
{
|
|
|
14 |
assertThat(array('AaA', 'BaB', 'CaC'), everyItem(containsString('a')));
|
|
|
15 |
assertThat(array('AbA', 'BbB', 'CbC'), not(everyItem(containsString('a'))));
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
public function testIsAlwaysTrueForEmptyLists()
|
|
|
19 |
{
|
|
|
20 |
assertThat(array(), everyItem(containsString('a')));
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
public function testDescribesItself()
|
|
|
24 |
{
|
|
|
25 |
$each = everyItem(containsString('a'));
|
|
|
26 |
$this->assertEquals('every item is a string containing "a"', (string) $each);
|
|
|
27 |
|
|
|
28 |
$this->assertMismatchDescription('an item was "BbB"', $each, array('BbB'));
|
|
|
29 |
}
|
|
|
30 |
}
|