|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: james |
|
5
|
|
|
* Date: 24/07/2018 |
|
6
|
|
|
* Time: 09:28 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
use Specter\Container\ParameterContainer; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class ParameterContainerTest |
|
14
|
|
|
*/ |
|
15
|
|
|
class ParameterContainerTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @covers \Specter\Container\ParameterContainer::__construct() |
|
20
|
|
|
* @covers \Specter\Container\ParameterContainer::getParameterBag() |
|
21
|
|
|
*/ |
|
22
|
|
|
public function testCanConstructWithNoArgs() |
|
23
|
|
|
{ |
|
24
|
|
|
$container = new ParameterContainer(); |
|
25
|
|
|
|
|
26
|
|
|
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\ParameterBag::class, |
|
27
|
|
|
$container->getParameterBag()); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @covers \Specter\Container\ParameterContainer::__construct() |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testConstructWithArgs() |
|
34
|
|
|
{ |
|
35
|
|
|
$bag = new \Symfony\Component\HttpFoundation\ParameterBag([ |
|
36
|
|
|
'config.debug' => true |
|
37
|
|
|
]); |
|
38
|
|
|
|
|
39
|
|
|
$container = new ParameterContainer($bag); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\ParameterBag::class, |
|
42
|
|
|
$container->getParameterBag()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @covers \Specter\Container\ParameterContainer::__construct() |
|
47
|
|
|
* @covers \Specter\Container\ParameterContainer::set() |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testSetParameter() |
|
50
|
|
|
{ |
|
51
|
|
|
$bag = new \Symfony\Component\HttpFoundation\ParameterBag([ |
|
52
|
|
|
'config.debug' => true |
|
53
|
|
|
]); |
|
54
|
|
|
|
|
55
|
|
|
$container = new ParameterContainer($bag); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\ParameterBag::class, |
|
58
|
|
|
$container->getParameterBag()); |
|
59
|
|
|
|
|
60
|
|
|
$container->setParameter('config.foo', 'baz'); |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testHasParameter() |
|
65
|
|
|
{ |
|
66
|
|
|
$bag = new \Symfony\Component\HttpFoundation\ParameterBag([ |
|
67
|
|
|
'config.debug' => true |
|
68
|
|
|
]); |
|
69
|
|
|
|
|
70
|
|
|
$container = new ParameterContainer($bag); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\ParameterBag::class, |
|
73
|
|
|
$container->getParameterBag()); |
|
74
|
|
|
|
|
75
|
|
|
$container->setParameter('config.foo', 'baz'); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertTrue($container->hasParameter('config.foo')); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @covers \Specter\Container\ParameterContainer::get() |
|
82
|
|
|
*/ |
|
83
|
|
|
public function testGetParameter() |
|
84
|
|
|
{ |
|
85
|
|
|
$bag = new \Symfony\Component\HttpFoundation\ParameterBag([ |
|
86
|
|
|
'config.debug' => true |
|
87
|
|
|
]); |
|
88
|
|
|
|
|
89
|
|
|
$container = new ParameterContainer($bag); |
|
90
|
|
|
|
|
91
|
|
|
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\ParameterBag::class, |
|
92
|
|
|
$container->getParameterBag()); |
|
93
|
|
|
|
|
94
|
|
|
$container->setParameter('config.foo', 'baz'); |
|
95
|
|
|
|
|
96
|
|
|
$this->assertTrue($container->hasParameter('config.foo')); |
|
97
|
|
|
|
|
98
|
|
|
$this->assertEquals('baz', $container->getParameter('config.foo')); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|