SimpleMatcherSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Greppy package.
5
 *
6
 * (c) Daniel Ribeiro <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Relax\Greppy;
13
14
use Prophecy\Argument;
15
use PhpSpec\ObjectBehavior;
16
use Relax\Greppy\Pattern;
17
18
class SimpleMatcherSpec extends ObjectBehavior
19
{
20
    function let()
21
    {
22
        $this->beConstructedWith("subject");
23
    }
24
    
25
    function it_is_initializable()
26
    {
27
        $this->shouldHaveType('Relax\Greppy\Matcher');
28
    }
29
    
30
    function it_should_not_be_constructed_with_non_string_subject()
31
    {
32
        $this->shouldThrow(
33
            new \InvalidArgumentException("Expected string subject, got 1.")
34
        )->during('__construct', array(1));
35
    }
36
    
37
    function it_should_return_subject()
38
    {
39
        $this->getSubject()->shouldReturn("subject");
40
    }
41
    
42
    function it_should_match_pattern_against_subject(Pattern $pattern)
43
    {
44
        $pattern->__toString()->willReturn("/./");
45
        $this->matches($pattern)->shouldReturn(true);
46
47
        $pattern->__toString()->willReturn("/different/");
48
        $this->matches($pattern)->shouldReturn(false);
49
    }
50
}
51