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;
3
 
4
class Thingy
5
{
6
    private $_result;
7
    public function __construct($result)
8
    {
9
        $this->_result = $result;
10
    }
11
    public function getResult()
12
    {
13
        return $this->_result;
14
    }
15
}
16
 
17
/* Test-specific subclass only */
18
class ResultMatcher extends \Hamcrest\FeatureMatcher
19
{
20
    public function __construct()
21
    {
22
        parent::__construct(self::TYPE_ANY, null, equalTo('bar'), 'Thingy with result', 'result');
23
    }
24
    public function featureValueOf($actual)
25
    {
26
        if ($actual instanceof \Hamcrest\Thingy) {
27
            return $actual->getResult();
28
        }
29
    }
30
}
31
 
32
class FeatureMatcherTest extends \Hamcrest\AbstractMatcherTest
33
{
34
 
35
    private $_resultMatcher;
36
 
37
    protected function setUp()
38
    {
39
        $this->_resultMatcher = $this->_resultMatcher();
40
    }
41
 
42
    protected function createMatcher()
43
    {
44
        return $this->_resultMatcher();
45
    }
46
 
47
    public function testMatchesPartOfAnObject()
48
    {
49
        $this->assertMatches($this->_resultMatcher, new \Hamcrest\Thingy('bar'), 'feature');
50
        $this->assertDescription('Thingy with result "bar"', $this->_resultMatcher);
51
    }
52
 
53
    public function testMismatchesPartOfAnObject()
54
    {
55
        $this->assertMismatchDescription(
56
            'result was "foo"',
57
            $this->_resultMatcher,
58
            new \Hamcrest\Thingy('foo')
59
        );
60
    }
61
 
62
    public function testDoesNotGenerateNoticesForNull()
63
    {
64
        $this->assertMismatchDescription('result was null', $this->_resultMatcher, null);
65
    }
66
 
67
    // -- Creation Methods
68
 
69
    private function _resultMatcher()
70
    {
71
        return new \Hamcrest\ResultMatcher();
72
    }
73
}