|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sonata Project package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sonata\CacheBundle\Tests\DependencyInjection\Configuration; |
|
13
|
|
|
|
|
14
|
|
|
use Sonata\CacheBundle\DependencyInjection\Configuration; |
|
15
|
|
|
use Symfony\Component\Config\Definition\Processor; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Tests the Configuration class. |
|
19
|
|
|
*/ |
|
20
|
|
|
class ConfigurationTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Asserts APC has default timeout values. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testApcDefaultTimeout() |
|
26
|
|
|
{ |
|
27
|
|
|
$expected = array( |
|
28
|
|
|
'RCV' => array(), |
|
29
|
|
|
'SND' => array(), |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
|
|
$configs = array(array( |
|
33
|
|
|
'caches' => array( |
|
34
|
|
|
'apc' => array( |
|
35
|
|
|
'token' => '', |
|
36
|
|
|
'prefix' => '', |
|
37
|
|
|
), |
|
38
|
|
|
), |
|
39
|
|
|
)); |
|
40
|
|
|
|
|
41
|
|
|
$config = $this->process($configs); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertArrayHasKey('timeout', $config['caches']['apc']); |
|
44
|
|
|
$this->assertEquals($expected, $config['caches']['apc']['timeout']); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Asserts APC timeout has custom values. |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testApcCustomTimeout() |
|
51
|
|
|
{ |
|
52
|
|
|
$expected = array( |
|
53
|
|
|
'RCV' => array('sec' => 10, 'usec' => 0), |
|
54
|
|
|
'SND' => array('sec' => 18, 'usec' => 12), |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
$configs = array(array( |
|
58
|
|
|
'caches' => array( |
|
59
|
|
|
'apc' => array( |
|
60
|
|
|
'token' => '', |
|
61
|
|
|
'prefix' => '', |
|
62
|
|
|
'timeout' => $expected, |
|
63
|
|
|
), |
|
64
|
|
|
), |
|
65
|
|
|
)); |
|
66
|
|
|
|
|
67
|
|
|
$config = $this->process($configs); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertArrayHasKey('timeout', $config['caches']['apc']); |
|
70
|
|
|
$this->assertEquals($expected, $config['caches']['apc']['timeout']); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Processes an array of configurations and returns a compiled version. |
|
75
|
|
|
* |
|
76
|
|
|
* @param array $configs An array of raw configurations |
|
77
|
|
|
* |
|
78
|
|
|
* @return array A normalized array |
|
79
|
|
|
*/ |
|
80
|
|
|
protected function process(array $configs) |
|
81
|
|
|
{ |
|
82
|
|
|
$processor = new Processor(); |
|
83
|
|
|
|
|
84
|
|
|
return $processor->processConfiguration(new Configuration(), $configs); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|