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

HeaderTest::testIsNotExcluded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
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\Header;
15
use Zend\Diactoros\ServerRequestFactory;
16
17
/**
18
 * Class HeaderTest.
19
 */
20
class HeaderTest extends \PHPUnit_Framework_TestCase
21
{
22
    public function testIsExcludedExists()
23
    {
24
        $request = ServerRequestFactory::fromGlobals();
25
        $excluder = new Header('X-Custom-Header');
26
27
        self::assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', '')));
28
    }
29
30
    public function testIsExcludedByString()
31
    {
32
        $request = ServerRequestFactory::fromGlobals();
33
        $excluder = new Header('X-Custom-Header', 'my-value');
34
35
        self::assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', 'my-value')));
36
    }
37
38
    public function testIsExcludedByRegex()
39
    {
40
        $request = ServerRequestFactory::fromGlobals();
41
        $excluder = new Header('X-Custom-Header', '/^my/');
42
43
        self::assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', 'my-value')));
44
    }
45
46
    public function testIsNotExcluded()
47
    {
48
        $excluder = new Header('X-Custom-Header');
49
50
        self::assertFalse($excluder->isExcluded(ServerRequestFactory::fromGlobals()));
51
    }
52
}
53