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

HeaderTest::testIsExcludedByRegex()   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
 * 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