Passed
Push — master ( 3efdf7...5c444f )
by Fabien
06:03
created

setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the FabienCrassat\CurriculumVitaeBundle Symfony bundle.
5
 *
6
 * (c) Fabien Crassat <[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 FabienCrassat\CurriculumVitaeBundle\Tests\DependencyInjection;
13
14
use FabienCrassat\CurriculumVitaeBundle\DependencyInjection\FabienCrassatCurriculumVitaeExtension;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\Yaml\Parser;
17
18
class FabienCrassatCurriculumVitaeExtensionExpectedExceptionTest extends \PHPUnit\Framework\TestCase
19
{
20
    /**
21
    * @var ContainerBuilder
22
    */
23
    private $configuration;
24
    private $loader;
25
26
    public function setUp()
27
    {
28
        $this->configuration = new ContainerBuilder;
29
        $this->loader        = new FabienCrassatCurriculumVitaeExtension;
30
    }
31
32
    /**
33
     * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
34
     */
35
    public function testBadDirectory()
36
    {
37
        $this->createBadConfiguration();
38
    }
39
40
    /**
41
    * Creates a bad configuration
42
    */
43
    private function createBadConfiguration()
44
    {
45
        $this->createConfiguration($this->getBadPathToCvConfig());
46
    }
47
48
    /**
49
    * Creates a configuration
50
    */
51
    private function createConfiguration($config)
52
    {
53
        $this->loader->load(array($config), $this->configuration);
54
        $this->assertTrue($this->configuration instanceof ContainerBuilder);
55
    }
56
57
    /**
58
    * Gets a full config
59
    *
60
    * @return String[]
61
    */
62
    private function getBadPathToCvConfig()
63
    {
64
        $yaml   = <<<EOF
65
path_to_cv:
66
    "itIsNotADirectory"
67
EOF;
68
        $parser = new Parser;
69
70
        return (array) $parser->parse($yaml);
71
    }
72
}
73