Completed
Push — master ( ecd5d7...f9662e )
by Julián
11:22
created

PathTest::testIsExcludedByString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * janitor (http://juliangut.com/janitor).
5
 * Effortless maintenance management.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/janitor
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
namespace Janitor\Test\Excluder;
13
14
use Janitor\Excluder\Path;
15
use Zend\Diactoros\ServerRequestFactory;
16
17
/**
18
 * Class PathTest.
19
 */
20
class PathTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * @var array
24
     */
25
    protected $excludedPaths = [
26
        '/user',
27
        '/^\/blog\/.+/',
28
    ];
29
30
    public function testIsExcludedByString()
31
    {
32
        $request = ServerRequestFactory::fromGlobals();
33
        $excluder = new Path($this->excludedPaths[0]);
34
35
        self::assertTrue($excluder->isExcluded($request->withUri($request->getUri()->withPath('/user'))));
36
    }
37
38
    public function testIsExcludedByRegex()
39
    {
40
        $request = ServerRequestFactory::fromGlobals();
41
        $excluder = new Path($this->excludedPaths);
42
43
        self::assertTrue($excluder->isExcluded($request->withUri($request->getUri()->withPath('/blog/post'))));
44
    }
45
46
    public function testIsNotExcluded()
47
    {
48
        $request = ServerRequestFactory::fromGlobals();
49
        $excluder = new Path($this->excludedPaths);
50
51
        self::assertFalse($excluder->isExcluded($request->withUri($request->getUri()->withPath('/home'))));
52
    }
53
}
54