File: EveryTest.php

package info (click to toggle)
php-hamcrest 2.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,168 kB
  • sloc: php: 6,353; makefile: 14; sh: 9
file content (30 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Hamcrest\Core;

class EveryTest extends \Hamcrest\AbstractMatcherTestCase
{

    protected function createMatcher()
    {
        return \Hamcrest\Core\Every::everyItem(anything());
    }

    public function testIsTrueWhenEveryValueMatches()
    {
        assertThat(array('AaA', 'BaB', 'CaC'), everyItem(containsString('a')));
        assertThat(array('AbA', 'BbB', 'CbC'), not(everyItem(containsString('a'))));
    }

    public function testIsAlwaysTrueForEmptyLists()
    {
        assertThat(array(), everyItem(containsString('a')));
    }

    public function testDescribesItself()
    {
        $each = everyItem(containsString('a'));
        $this->assertEquals('every item is a string containing "a"', (string) $each);

        $this->assertMismatchDescription('an item was "BbB"', $each, array('BbB'));
    }
}