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
/*
5
 Copyright (c) 2009 hamcrest.org
6
 */
7
use Hamcrest\BaseMatcher;
8
use Hamcrest\Description;
9
use Hamcrest\Matcher;
10
use Hamcrest\Util;
11
 
12
/**
13
 * Decorates another Matcher, retaining the behavior but allowing tests
14
 * to be slightly more expressive.
15
 *
16
 * For example:  assertThat($cheese, equalTo($smelly))
17
 *          vs.  assertThat($cheese, is(equalTo($smelly)))
18
 */
19
class Is extends BaseMatcher
20
{
21
 
22
    private $_matcher;
23
 
24
    public function __construct(Matcher $matcher)
25
    {
26
        $this->_matcher = $matcher;
27
    }
28
 
29
    public function matches($arg)
30
    {
31
        return $this->_matcher->matches($arg);
32
    }
33
 
34
    public function describeTo(Description $description)
35
    {
36
        $description->appendText('is ')->appendDescriptionOf($this->_matcher);
37
    }
38
 
39
    public function describeMismatch($item, Description $mismatchDescription)
40
    {
41
        $this->_matcher->describeMismatch($item, $mismatchDescription);
42
    }
43
 
44
    /**
45
     * Decorates another Matcher, retaining the behavior but allowing tests
46
     * to be slightly more expressive.
47
     *
48
     * For example:  assertThat($cheese, equalTo($smelly))
49
     *          vs.  assertThat($cheese, is(equalTo($smelly)))
50
     *
51
     * @factory
52
     */
53
    public static function is($value)
54
    {
55
        return new self(Util::wrapValueWithIsEqual($value));
56
    }
57
}