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

HeaderTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 46
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsExcludedExists() 0 7 1
A testIsExcludedByString() 0 7 1
A testIsExcludedByRegex() 0 7 1
A testIsNotExcluded() 0 6 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\Header;
13
use Zend\Diactoros\ServerRequestFactory;
14
15
/**
16
 * @covers \Janitor\Excluder\Header
17
 */
18
class HeaderTest extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @covers \Janitor\Excluder\Header::isExcluded
22
     */
23
    public function testIsExcludedExists()
24
    {
25
        $request = ServerRequestFactory::fromGlobals();
26
        $excluder = new Header('X-Custom-Header');
27
28
        $this->assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', '')));
29
    }
30
31
    /**
32
     * @covers \Janitor\Excluder\Header::__construct
33
     * @covers \Janitor\Excluder\Header::isExcluded
34
     */
35
    public function testIsExcludedByString()
36
    {
37
        $request = ServerRequestFactory::fromGlobals();
38
        $excluder = new Header('X-Custom-Header', 'my-value');
39
40
        $this->assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', 'my-value')));
41
    }
42
43
    /**
44
     * @covers \Janitor\Excluder\Header::isExcluded
45
     */
46
    public function testIsExcludedByRegex()
47
    {
48
        $request = ServerRequestFactory::fromGlobals();
49
        $excluder = new Header('X-Custom-Header', '/^my/');
50
51
        $this->assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', 'my-value')));
52
    }
53
54
    /**
55
     * @covers \Janitor\Excluder\Header::isExcluded
56
     */
57
    public function testIsNotExcluded()
58
    {
59
        $excluder = new Header('X-Custom-Header');
60
61
        $this->assertFalse($excluder->isExcluded(ServerRequestFactory::fromGlobals()));
62
    }
63
}
64