|
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('American User'); |
|
67
|
|
|
$this->assertTrue($filter->isFeatureMatch($feature)); |
|
68
|
|
|
|
|
69
|
|
|
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1); |
|
70
|
|
|
$filter = new RoleFilter('American User'); |
|
71
|
|
|
$this->assertFalse($filter->isFeatureMatch($feature)); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|