Completed
Push — http_cache_mvc ( 5374b9 )
by
unknown
27:11
created

testSetSharedMaxAgeNoReplace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
4
 * @license For full copyright and license information view LICENSE file distributed with this source code.
5
 */
6
7
namespace eZ\Publish\Core\MVC\Symfony\Cache\Tests\Http;
8
9
use eZ\Publish\Core\MVC\Symfony\Cache\Http\ResponseCacheConfigurator;
10
use PHPUnit_Framework_TestCase;
11
use Symfony\Component\HttpFoundation\Response;
12
13
class ResponseCacheConfiguratorTest extends PHPUnit_Framework_TestCase
14
{
15
    public function testEnableCache()
16
    {
17
        $configurator = new ResponseCacheConfigurator();
18
19
        $response = new Response();
20
        $configurator->enableCache($response);
21
22
        self::assertEquals(
23
            'public',
24
            $response->headers->get('cache-control')
25
        );
26
    }
27
28 View Code Duplication
    public function testSetSharedMaxAge()
29
    {
30
        $configurator = new ResponseCacheConfigurator();
31
32
        $response = new Response();
33
        $configurator->setSharedMaxAge($response, 30);
34
35
        self::assertEquals(
36
            30,
37
            $response->headers->getCacheControlDirective('s-maxage')
38
        );
39
    }
40
41 View Code Duplication
    public function testSetSharedMaxAgeNoReplace()
42
    {
43
        $configurator = new ResponseCacheConfigurator();
44
45
        $response = new Response();
46
        $configurator->setSharedMaxAge($response, 30);
47
        $configurator->setSharedMaxAge($response, 60);
48
49
        self::assertEquals(
50
            30,
51
            $response->headers->getCacheControlDirective('s-maxage')
52
        );
53
    }
54
55 View Code Duplication
    public function testSetSharedMaxAgeReplace()
56
    {
57
        $configurator = new ResponseCacheConfigurator();
58
59
        $response = new Response();
60
        $configurator->setSharedMaxAge($response, 30);
61
        $configurator->setSharedMaxAge($response, 60, true);
62
63
        self::assertEquals(
64
            60,
65
            $response->headers->getCacheControlDirective('s-maxage')
66
        );
67
    }
68
69
    public function testAddCacheTags()
70
    {
71
        $configurator = new ResponseCacheConfigurator();
0 ignored issues
show
Unused Code introduced by
$configurator is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
72
73
        $response = new Response();
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
74
    }
75
}
76