1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BestIt\KitchensinkBundle\Tests\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use BestIt\KitchensinkBundle\DependencyInjection\BestItKitchensinkExtension; |
6
|
|
|
use Exception; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class BestItKitchensinkExtensionTest |
13
|
|
|
* |
14
|
|
|
* @author blange <[email protected]> |
15
|
|
|
* @package BestIt\KitchensinkBundle |
16
|
|
|
*/ |
17
|
|
|
class BestItKitchensinkExtensionTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Test container with all values |
21
|
|
|
* |
22
|
|
|
* @throws Exception Unknown errors |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function testContainer() |
27
|
|
|
{ |
28
|
|
|
$extension = new BestItKitchensinkExtension(); |
29
|
|
|
$container = new ContainerBuilder(); |
30
|
|
|
|
31
|
|
|
$extension->load( |
32
|
|
|
[ |
33
|
|
|
[ |
34
|
|
|
'template' => $template = uniqid(), |
35
|
|
|
'data_provider' => $provider = uniqid(), |
36
|
|
|
'template_engine' => $engine = uniqid(), |
37
|
|
|
] |
38
|
|
|
], |
39
|
|
|
$container |
40
|
|
|
); |
41
|
|
|
|
42
|
|
|
static::assertSame($template, $container->getParameter('best_it_kitchensink.template')); |
43
|
|
|
static::assertTrue($container->hasAlias('best_it_kitchensink.template_engine')); |
44
|
|
|
static::assertTrue($container->hasAlias('best_it_kitchensink.data_provider')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Test missing data provider |
49
|
|
|
* |
50
|
|
|
* @throws Exception Unknown errors |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function testMissingProvider() |
55
|
|
|
{ |
56
|
|
|
$this->expectException(InvalidConfigurationException::class); |
57
|
|
|
$this->expectExceptionMessageRegExp('/data_provider/'); |
58
|
|
|
|
59
|
|
|
$extension = new BestItKitchensinkExtension(); |
60
|
|
|
$container = new ContainerBuilder(); |
61
|
|
|
|
62
|
|
|
$extension->load( |
63
|
|
|
[ |
64
|
|
|
[ |
65
|
|
|
'template' => $template = uniqid(), |
66
|
|
|
'template_engine' => $engine = uniqid(), |
67
|
|
|
] |
68
|
|
|
], |
69
|
|
|
$container |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|