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 StringContainsIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
5
{
6
 
7
    const EXCERPT = 'ExcErPt';
8
 
9
    private $_stringContains;
10
 
11
    protected function setUp()
12
    {
13
        $this->_stringContains = \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase(
14
            strtolower(self::EXCERPT)
15
        );
16
    }
17
 
18
    protected function createMatcher()
19
    {
20
        return $this->_stringContains;
21
    }
22
 
23
    public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring()
24
    {
25
        $this->assertTrue(
26
            $this->_stringContains->matches(self::EXCERPT . 'END'),
27
            'should be true if excerpt at beginning'
28
        );
29
        $this->assertTrue(
30
            $this->_stringContains->matches('START' . self::EXCERPT),
31
            'should be true if excerpt at end'
32
        );
33
        $this->assertTrue(
34
            $this->_stringContains->matches('START' . self::EXCERPT . 'END'),
35
            'should be true if excerpt in middle'
36
        );
37
        $this->assertTrue(
38
            $this->_stringContains->matches(self::EXCERPT . self::EXCERPT),
39
            'should be true if excerpt is repeated'
40
        );
41
 
42
        $this->assertFalse(
43
            $this->_stringContains->matches('Something else'),
44
            'should not be true if excerpt is not in string'
45
        );
46
        $this->assertFalse(
47
            $this->_stringContains->matches(substr(self::EXCERPT, 1)),
48
            'should not be true if part of excerpt is in string'
49
        );
50
    }
51
 
52
    public function testEvaluatesToTrueIfArgumentIsEqualToSubstring()
53
    {
54
        $this->assertTrue(
55
            $this->_stringContains->matches(self::EXCERPT),
56
            'should be true if excerpt is entire string'
57
        );
58
    }
59
 
60
    public function testEvaluatesToTrueIfArgumentContainsExactSubstring()
61
    {
62
        $this->assertTrue(
63
            $this->_stringContains->matches(strtolower(self::EXCERPT)),
64
            'should be false if excerpt is entire string ignoring case'
65
        );
66
        $this->assertTrue(
67
            $this->_stringContains->matches('START' . strtolower(self::EXCERPT) . 'END'),
68
            'should be false if excerpt is contained in string ignoring case'
69
        );
70
    }
71
 
72
    public function testHasAReadableDescription()
73
    {
74
        $this->assertDescription(
75
            'a string containing in any case "'
76
            . strtolower(self::EXCERPT) . '"',
77
            $this->_stringContains
78
        );
79
    }
80
}