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\Text;
3
 
4
class StringStartsWithTest extends \Hamcrest\AbstractMatcherTest
5
{
6
 
7
    const EXCERPT = 'EXCERPT';
8
 
9
    private $_stringStartsWith;
10
 
11
    protected function setUp()
12
    {
13
        $this->_stringStartsWith = \Hamcrest\Text\StringStartsWith::startsWith(self::EXCERPT);
14
    }
15
 
16
    protected function createMatcher()
17
    {
18
        return $this->_stringStartsWith;
19
    }
20
 
21
    public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring()
22
    {
23
        $this->assertTrue(
24
            $this->_stringStartsWith->matches(self::EXCERPT . 'END'),
25
            'should be true if excerpt at beginning'
26
        );
27
        $this->assertFalse(
28
            $this->_stringStartsWith->matches('START' . self::EXCERPT),
29
            'should be false if excerpt at end'
30
        );
31
        $this->assertFalse(
32
            $this->_stringStartsWith->matches('START' . self::EXCERPT . 'END'),
33
            'should be false if excerpt in middle'
34
        );
35
        $this->assertTrue(
36
            $this->_stringStartsWith->matches(self::EXCERPT . self::EXCERPT),
37
            'should be true if excerpt is at beginning and repeated'
38
        );
39
 
40
        $this->assertFalse(
41
            $this->_stringStartsWith->matches('Something else'),
42
            'should be false if excerpt is not in string'
43
        );
44
        $this->assertFalse(
45
            $this->_stringStartsWith->matches(substr(self::EXCERPT, 1)),
46
            'should be false if part of excerpt is at start of string'
47
        );
48
    }
49
 
50
    public function testEvaluatesToTrueIfArgumentIsEqualToSubstring()
51
    {
52
        $this->assertTrue(
53
            $this->_stringStartsWith->matches(self::EXCERPT),
54
            'should be true if excerpt is entire string'
55
        );
56
    }
57
 
58
    public function testHasAReadableDescription()
59
    {
60
        $this->assertDescription('a string starting with "EXCERPT"', $this->_stringStartsWith);
61
    }
62
}