1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Loevgaard\DandomainConsignmentBundle\Tests\DependencyInjection; |
6
|
|
|
|
7
|
|
|
use Loevgaard\DandomainConsignmentBundle\DependencyInjection\LoevgaardDandomainConsignmentExtension; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
11
|
|
|
use Symfony\Component\Yaml\Parser; |
12
|
|
|
|
13
|
|
|
class LoevgaardDandomainConsignmentExtensionTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
public function testThrowsInvalidConfigException() |
16
|
|
|
{ |
17
|
|
|
$this->expectException(InvalidConfigurationException::class); |
18
|
|
|
|
19
|
|
|
$loader = new LoevgaardDandomainConsignmentExtension(); |
20
|
|
|
$config = $this->getEmptyConfig(); |
21
|
|
|
unset($config['report_dir']); |
22
|
|
|
$loader->load([$config], new ContainerBuilder()); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testGettersSetters() |
26
|
|
|
{ |
27
|
|
|
$loader = new LoevgaardDandomainConsignmentExtension(); |
28
|
|
|
$config = $this->getEmptyConfig(); |
29
|
|
|
$container = new ContainerBuilder(); |
30
|
|
|
$loader->load([$config], $container); |
31
|
|
|
|
32
|
|
|
$this->assertSame($config['report_dir'], $container->getParameter('loevgaard_dandomain_consignment.report_dir')); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testThrowsLogicException() |
36
|
|
|
{ |
37
|
|
|
$this->expectException(\LogicException::class); |
38
|
|
|
|
39
|
|
|
$extension = new LoevgaardDandomainConsignmentExtension(); |
40
|
|
|
$extension->prepend(new ContainerBuilder()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return array |
45
|
|
|
*/ |
46
|
|
|
protected function getEmptyConfig() |
47
|
|
|
{ |
48
|
|
|
$yaml = <<<EOF |
49
|
|
|
report_dir: report_dir |
50
|
|
|
EOF; |
51
|
|
|
$parser = new Parser(); |
52
|
|
|
|
53
|
|
|
return $parser->parse($yaml); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|