1 | <?php |
||
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 |