SimpleMatcherSpec   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 33
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_should_not_be_constructed_with_non_string_subject() 0 6 1
A it_should_return_subject() 0 4 1
A it_should_match_pattern_against_subject() 0 8 1
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