Completed
Pull Request — master (#16)
by Fabien
06:12 queued 03:13
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
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
    function setUp()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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