Completed
Push — master ( 0a7932...aee286 )
by Maksim
13s
created

testShouldSingAndSuccessfullyCheckPathWithRuntimeConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Liip\ImagineBundle\Tests\Imagine\Cache;
4
5
use Liip\ImagineBundle\Tests\AbstractTest;
6
use Liip\ImagineBundle\Imagine\Cache\Signer;
7
8
class SignerTest extends AbstractTest
9
{
10
    public function testImplementsSignerInterface()
11
    {
12
        $rc = new \ReflectionClass('Liip\ImagineBundle\Imagine\Cache\Signer');
13
14
        $this->assertTrue($rc->implementsInterface('Liip\ImagineBundle\Imagine\Cache\SignerInterface'));
15
    }
16
17
    public function testCouldBeConstructedWithSecret()
18
    {
19
        new Signer('aSecret');
20
    }
21
22
    public function testShouldReturnShortHashOnSign()
23
    {
24
        $singer = new Signer('aSecret');
25
26
        $this->assertEquals(8, strlen($singer->sign('aPath')));
27
    }
28
29
    public function testShouldSingAndSuccessfullyCheckPathWithoutRuntimeConfig()
30
    {
31
        $singer = new Signer('aSecret');
32
33
        $this->assertTrue($singer->check($singer->sign('aPath'), 'aPath'));
34
    }
35
36
    public function testShouldSingAndSuccessfullyCheckPathWithRuntimeConfig()
37
    {
38
        $singer = new Signer('aSecret');
39
40
        $this->assertTrue($singer->check($singer->sign('aPath', array('aConfig')), 'aPath', array('aConfig')));
41
    }
42
43
    public function testShouldConvertRecursivelyToStringAllRuntimeConfigParameters()
44
    {
45
        $singer = new Signer('aSecret');
46
47
        $runtimeConfigInts = array(
48
            'foo' => 14,
49
            'bar' => array(
50
                'bar' => 15,
51
            ),
52
        );
53
54
        $runtimeConfigStrings = array(
55
            'foo' => '14',
56
            'bar' => array(
57
                'bar' => '15',
58
            ),
59
        );
60
61
        $this->assertTrue($singer->check($singer->sign('aPath', $runtimeConfigInts), 'aPath', $runtimeConfigStrings));
62
    }
63
}
64