Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
namespace Hamcrest\Arrays;
3
 
4
use Hamcrest\AbstractMatcherTest;
5
 
6
class IsArrayContainingInAnyOrderTest extends AbstractMatcherTest
7
{
8
 
9
    protected function createMatcher()
10
    {
11
        return IsArrayContainingInAnyOrder::arrayContainingInAnyOrder(array(1, 2));
12
    }
13
 
14
    public function testHasAReadableDescription()
15
    {
16
        $this->assertDescription('[<1>, <2>] in any order', containsInAnyOrder(array(1, 2)));
17
    }
18
 
19
    public function testMatchesItemsInAnyOrder()
20
    {
21
        $this->assertMatches(containsInAnyOrder(array(1, 2, 3)), array(1, 2, 3), 'in order');
22
        $this->assertMatches(containsInAnyOrder(array(1, 2, 3)), array(3, 2, 1), 'out of order');
23
        $this->assertMatches(containsInAnyOrder(array(1)), array(1), 'single');
24
    }
25
 
26
    public function testAppliesMatchersInAnyOrder()
27
    {
28
        $this->assertMatches(
29
            containsInAnyOrder(array(1, 2, 3)),
30
            array(1, 2, 3),
31
            'in order'
32
        );
33
        $this->assertMatches(
34
            containsInAnyOrder(array(1, 2, 3)),
35
            array(3, 2, 1),
36
            'out of order'
37
        );
38
        $this->assertMatches(
39
            containsInAnyOrder(array(1)),
40
            array(1),
41
            'single'
42
        );
43
    }
44
 
45
    public function testMismatchesItemsInAnyOrder()
46
    {
47
        $matcher = containsInAnyOrder(array(1, 2, 3));
48
 
49
        $this->assertMismatchDescription('was null', $matcher, null);
50
        $this->assertMismatchDescription('No item matches: <1>, <2>, <3> in []', $matcher, array());
51
        $this->assertMismatchDescription('No item matches: <2>, <3> in [<1>]', $matcher, array(1));
52
        $this->assertMismatchDescription('Not matched: <4>', $matcher, array(4, 3, 2, 1));
53
    }
54
}