Completed
Push — master ( ba7c5d...c3b626 )
by Julián
02:08
created

PathTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 7
Bugs 1 Features 0
Metric Value
wmc 3
c 7
b 1
f 0
lcom 1
cbo 5
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsExcludedByString() 0 7 1
A testIsExcludedByRegex() 0 7 1
A testIsNotExcluded() 0 7 1
1
<?php
2
/**
3
 * Effortless maintenance management (http://juliangut.com/janitor)
4
 *
5
 * @link https://github.com/juliangut/janitor for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/janitor/blob/master/LICENSE
8
 */
9
10
namespace Janitor\Test\Excluder;
11
12
use Janitor\Excluder\Path;
13
use Zend\Diactoros\ServerRequestFactory;
14
15
/**
16
 * @covers \Janitor\Excluder\Path
17
 */
18
class PathTest extends \PHPUnit_Framework_TestCase
19
{
20
    protected $excludedPaths = [
21
        '/user',
22
        '/^\/blog\/.+/',
23
    ];
24
25
    /**
26
     * @covers \Janitor\Excluder\Path::__construct
27
     * @covers \Janitor\Excluder\Path::addPath
28
     * @covers \Janitor\Excluder\Path::isExcluded
29
     */
30
    public function testIsExcludedByString()
31
    {
32
        $request = ServerRequestFactory::fromGlobals();
33
        $excluder = new Path($this->excludedPaths);
34
35
        $this->assertTrue($excluder->isExcluded($request->withUri($request->getUri()->withPath('/user'))));
36
    }
37
38
    /**
39
     * @covers \Janitor\Excluder\Path::__construct
40
     * @covers \Janitor\Excluder\Path::addPath
41
     * @covers \Janitor\Excluder\Path::isExcluded
42
     */
43
    public function testIsExcludedByRegex()
44
    {
45
        $request = ServerRequestFactory::fromGlobals();
46
        $excluder = new Path($this->excludedPaths);
47
48
        $this->assertTrue($excluder->isExcluded($request->withUri($request->getUri()->withPath('/blog/post'))));
49
    }
50
51
    /**
52
     * @covers \Janitor\Excluder\Path::isExcluded
53
     */
54
    public function testIsNotExcluded()
55
    {
56
        $request = ServerRequestFactory::fromGlobals();
57
        $excluder = new Path($this->excludedPaths);
58
59
        $this->assertFalse($excluder->isExcluded($request->withUri($request->getUri()->withPath('/home'))));
60
    }
61
}
62