Completed
Push — develop ( 183c36...cfc9ab )
by Stéphane
02:42
created

Rule::testDisallow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 9.3142
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the beebot package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2016
8
 * @author    Stephane HULARD <[email protected]>
9
 */
10
11
namespace Bee4\RobotsTxt\Test\Units;
12
13
use mageekguy\atoum;
14
use Bee4\RobotsTxt\Rule as SUT;
15
16
/**
17
 * Rule unit test
18
 */
19
class Rule extends atoum
20
{
21 View Code Duplication
    public function testAllowAllAsDefault()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $this
24
            ->given($sut = new SUT(''))
25
            ->when($match = $sut->match('/some/url'))
26
            ->then
27
                ->boolean($match)
28
                    ->isTrue();
29
    }
30
31 View Code Duplication
    public function testAllow()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $this
34
            ->given(
35
                $sut = new SUT(''),
36
                $sut->allow('/foo/bar')
37
            )
38
            ->when($match = $sut->match('/foo/bar'))
39
            ->then
40
                ->boolean($match)
41
                    ->isTrue();
42
    }
43
44 View Code Duplication
    public function testDisallow()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $this
47
            ->given(
48
                $sut = new SUT(''),
49
                $sut->disallow('/foo/bar'),
50
                $sut->allow('/foo/bar/baz$')
51
            )
52
            ->when($match = $sut->match('/foo/bar'))
53
            ->then
54
                ->boolean($match)
55
                    ->isFalse()
56
            ->when($match = $sut->match('/foo/bar/baz/'))
57
            ->then
58
                ->boolean($match)
59
                    ->isFalse()
60
            ->when($match = $sut->match('/foo/bar/baz'))
61
            ->then
62
                ->boolean($match)
63
                    ->isTrue();
64
    }
65
66
    public function testUserAgent()
67
    {
68
        $this
69
            ->given($sut = new SUT('UA'))
70
            ->then
71
                ->string($sut->getUserAgent())
72
                    ->isEqualTo('UA');
73
    }
74
75 View Code Duplication
    public function testMultipleExpression()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $this
78
            ->given(
79
                $sut = new SUT(''),
80
                $sut->disallow('/foo/bar'),
81
                $sut->allow('/foo/bar/baz$'),
82
                $sut->allow('/foo$')
83
            )
84
            ->when($match = $sut->match('/foo/bar'))
85
            ->then
86
                ->boolean($match)
87
                    ->isFalse()
88
            ->when($match = $sut->match('/foo/bar/baz/'))
89
            ->then
90
                ->boolean($match)
91
                    ->isFalse()
92
            ->when($match = $sut->match('/foo/bar/baz'))
93
            ->then
94
                ->boolean($match)
95
                    ->isTrue();
96
    }
97
}
98