NarrativeFilterTest::testIsFeatureMatchFilter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 9.536
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\NarrativeFilter;
6
use Behat\Gherkin\Node\FeatureNode;
7
8
class NarrativeFilterTest 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 NarrativeFilter('/as (?:a|an) french user/');
20
        $this->assertFalse($filter->isFeatureMatch($feature));
21
22
        $filter = new NarrativeFilter('/as (?:a|an) french user/i');
23
        $this->assertTrue($filter->isFeatureMatch($feature));
24
25
        $filter = new NarrativeFilter('/french .*/');
26
        $this->assertTrue($filter->isFeatureMatch($feature));
27
28
        $filter = new NarrativeFilter('/^french/');
29
        $this->assertFalse($filter->isFeatureMatch($feature));
30
31
        $filter = new NarrativeFilter('/user$/');
32
        $this->assertFalse($filter->isFeatureMatch($feature));
33
    }
34
}
35