|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LAG\AdminBundle\Tests\AdminBundle\Configuration; |
|
4
|
|
|
|
|
5
|
|
|
use LAG\AdminBundle\Application\Configuration\ApplicationConfiguration; |
|
6
|
|
|
use LAG\AdminBundle\Tests\AdminTestBase; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Exception\LogicException; |
|
8
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
9
|
|
|
|
|
10
|
|
|
class ConfigurationTest extends AdminTestBase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testHasParameter() |
|
13
|
|
|
{ |
|
14
|
|
|
$configuration = new ApplicationConfiguration(); |
|
15
|
|
|
|
|
16
|
|
|
// with no resolved configuration, the method should return false |
|
17
|
|
|
$this->assertFalse($configuration->hasParameter('a_parameter')); |
|
18
|
|
|
|
|
19
|
|
|
// with a resolved configuration should return true if a right parameter is provided |
|
20
|
|
|
$resolver = new OptionsResolver(); |
|
21
|
|
|
$configuration->configureOptions($resolver); |
|
22
|
|
|
$resolved = $resolver->resolve([ |
|
23
|
|
|
'title' => 'My Little Tauntaun', |
|
24
|
|
|
]); |
|
25
|
|
|
$configuration->setParameters($resolved); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertFalse($configuration->hasParameter('a_parameter')); |
|
28
|
|
|
$this->assertTrue($configuration->hasParameter('title')); |
|
29
|
|
|
$this->assertTrue($configuration->isResolved()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testSetParameters() |
|
33
|
|
|
{ |
|
34
|
|
|
$configuration = new ApplicationConfiguration(); |
|
35
|
|
|
$configuration->setParameters([ |
|
36
|
|
|
'title' => 'Planet Application', |
|
37
|
|
|
]); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertExceptionRaised(LogicException::class, function () use ($configuration) { |
|
40
|
|
|
$configuration->setParameters([ |
|
41
|
|
|
'an_other_configuration' => 'value', |
|
42
|
|
|
]); |
|
43
|
|
|
}); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testGetParameters() |
|
47
|
|
|
{ |
|
48
|
|
|
$configuration = new ApplicationConfiguration(); |
|
49
|
|
|
$configuration->setParameters([ |
|
50
|
|
|
'title' => 'Planet Application', |
|
51
|
|
|
]); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertInternalType('array', $configuration->getParameters()); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|