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\Core;
3
 
4
class SetTest extends \Hamcrest\AbstractMatcherTest
5
{
6
 
7
    public static $_classProperty;
8
    public $_instanceProperty;
9
 
10
    protected function setUp()
11
    {
12
        self::$_classProperty = null;
13
        unset($this->_instanceProperty);
14
    }
15
 
16
    protected function createMatcher()
17
    {
18
        return \Hamcrest\Core\Set::set('property_name');
19
    }
20
 
21
    public function testEvaluatesToTrueIfArrayPropertyIsSet()
22
    {
23
        assertThat(array('foo' => 'bar'), set('foo'));
24
    }
25
 
26
    public function testNegatedEvaluatesToFalseIfArrayPropertyIsSet()
27
    {
28
        assertThat(array('foo' => 'bar'), not(notSet('foo')));
29
    }
30
 
31
    public function testEvaluatesToTrueIfClassPropertyIsSet()
32
    {
33
        self::$_classProperty = 'bar';
34
        assertThat('Hamcrest\Core\SetTest', set('_classProperty'));
35
    }
36
 
37
    public function testNegatedEvaluatesToFalseIfClassPropertyIsSet()
38
    {
39
        self::$_classProperty = 'bar';
40
        assertThat('Hamcrest\Core\SetTest', not(notSet('_classProperty')));
41
    }
42
 
43
    public function testEvaluatesToTrueIfObjectPropertyIsSet()
44
    {
45
        $this->_instanceProperty = 'bar';
46
        assertThat($this, set('_instanceProperty'));
47
    }
48
 
49
    public function testNegatedEvaluatesToFalseIfObjectPropertyIsSet()
50
    {
51
        $this->_instanceProperty = 'bar';
52
        assertThat($this, not(notSet('_instanceProperty')));
53
    }
54
 
55
    public function testEvaluatesToFalseIfArrayPropertyIsNotSet()
56
    {
57
        assertThat(array('foo' => 'bar'), not(set('baz')));
58
    }
59
 
60
    public function testNegatedEvaluatesToTrueIfArrayPropertyIsNotSet()
61
    {
62
        assertThat(array('foo' => 'bar'), notSet('baz'));
63
    }
64
 
65
    public function testEvaluatesToFalseIfClassPropertyIsNotSet()
66
    {
67
        assertThat('Hamcrest\Core\SetTest', not(set('_classProperty')));
68
    }
69
 
70
    public function testNegatedEvaluatesToTrueIfClassPropertyIsNotSet()
71
    {
72
        assertThat('Hamcrest\Core\SetTest', notSet('_classProperty'));
73
    }
74
 
75
    public function testEvaluatesToFalseIfObjectPropertyIsNotSet()
76
    {
77
        assertThat($this, not(set('_instanceProperty')));
78
    }
79
 
80
    public function testNegatedEvaluatesToTrueIfObjectPropertyIsNotSet()
81
    {
82
        assertThat($this, notSet('_instanceProperty'));
83
    }
84
 
85
    public function testHasAReadableDescription()
86
    {
87
        $this->assertDescription('set property foo', set('foo'));
88
        $this->assertDescription('unset property bar', notSet('bar'));
89
    }
90
 
91
    public function testDecribesPropertySettingInMismatchMessage()
92
    {
93
        $this->assertMismatchDescription(
94
            'was not set',
95
            set('bar'),
96
            array('foo' => 'bar')
97
        );
98
        $this->assertMismatchDescription(
99
            'was "bar"',
100
            notSet('foo'),
101
            array('foo' => 'bar')
102
        );
103
        self::$_classProperty = 'bar';
104
        $this->assertMismatchDescription(
105
            'was "bar"',
106
            notSet('_classProperty'),
107
            'Hamcrest\Core\SetTest'
108
        );
109
        $this->_instanceProperty = 'bar';
110
        $this->assertMismatchDescription(
111
            'was "bar"',
112
            notSet('_instanceProperty'),
113
            $this
114
        );
115
    }
116
}