RoleFilterTest::testFeatureRolePrefixedWithAn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 9.376
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\Behat\Gherkin\Filter;
4
5
use Behat\Gherkin\Filter\RoleFilter;
6
use Behat\Gherkin\Node\FeatureNode;
7
8
class RoleFilterTest extends FilterTest
9
{
10
    public function testIsFeatureMatchFilter()
11
    {
12
        $description = <<<NAR
13
In order to be able to read news in my own language
14
As a french user
15
I need to be able to switch website language to french
16
NAR;
17
        $feature = new FeatureNode(null, $description, array(), null, array(), null, null, null, 1);
18
19
        $filter = new RoleFilter('french user');
20
        $this->assertTrue($filter->isFeatureMatch($feature));
21
22
        $filter = new RoleFilter('french *');
23
        $this->assertTrue($filter->isFeatureMatch($feature));
24
25
        $filter = new RoleFilter('french');
26
        $this->assertFalse($filter->isFeatureMatch($feature));
27
28
        $filter = new RoleFilter('user');
29
        $this->assertFalse($filter->isFeatureMatch($feature));
30
31
        $filter = new RoleFilter('*user');
32
        $this->assertTrue($filter->isFeatureMatch($feature));
33
34
        $filter = new RoleFilter('French User');
35
        $this->assertTrue($filter->isFeatureMatch($feature));
36
37
        $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1);
38
        $filter = new RoleFilter('French User');
39
        $this->assertFalse($filter->isFeatureMatch($feature));
40
    }
41
42
    public function testFeatureRolePrefixedWithAn()
43
    {
44
        $description = <<<NAR
45
In order to be able to read news in my own language
46
As an american user
47
I need to be able to switch website language to french
48
NAR;
49
        $feature = new FeatureNode(null, $description, array(), null, array(), null, null, null, 1);
50
51
        $filter = new RoleFilter('american user');
52
        $this->assertTrue($filter->isFeatureMatch($feature));
53
54
        $filter = new RoleFilter('american *');
55
        $this->assertTrue($filter->isFeatureMatch($feature));
56
57
        $filter = new RoleFilter('american');
58
        $this->assertFalse($filter->isFeatureMatch($feature));
59
60
        $filter = new RoleFilter('user');
61
        $this->assertFalse($filter->isFeatureMatch($feature));
62
63
        $filter = new RoleFilter('*user');
64
        $this->assertTrue($filter->isFeatureMatch($feature));
65
        
66
        $filter = new RoleFilter('[\w\s]+user');
67
        $this->assertFalse($filter->isFeatureMatch($feature));
68
69
        $filter = new RoleFilter('American User');
70
        $this->assertTrue($filter->isFeatureMatch($feature));
71
72
        $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1);
73
        $filter = new RoleFilter('American User');
74
        $this->assertFalse($filter->isFeatureMatch($feature));
75
    }
76
}
77