Completed
Pull Request — master (#10)
by Alice
02:26
created

YamlParserTest::test_loadDirErrorInvalid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wonderland\Container\Tests\Configuration\Parser;
4
5
use PHPUnit\Framework\TestCase;
6
use Wonderland\Container\Configuration\Parser\YamlParser;
7
use Wonderland\Container\Exception\InvalidResourceException;
8
use Wonderland\Container\Exception\ResourceNotFoundException;
9
10
/**
11
 * Class YamlParserTest
12
 * @package Wonderland\Container\Tests\Configuration\Parser
13
 * @author Alice Praud <[email protected]>
14
 */
15
class YamlParserTest extends TestCase
16
{
17
	/** @var YamlParser */
18
	private $parser;
19
20
	public function setUp()
21
	{
22
		$this->parser = new YamlParser();
23
	}
24
25
	/**
26
	 * @throws \Wonderland\Container\Exception\InvalidResourceException
27
	 * @throws \Wonderland\Container\Exception\ResourceNotFoundException
28
	 */
29
	public function test_load()
30
	{
31
		$this->assertInternalType('array', $this->parser->loadFile(__DIR__ . '/../data/yml/test-full.yml'));
32
		$this->assertInternalType('array', $this->parser->loadDirectory(__DIR__ . '/../data/yml/'));
33
	}
34
35
	/**
36
	 * @return array
37
	 */
38
	public function loadErrorNotFoundProvider()
39
	{
40
		return [
41
			['dontexists']
42
		];
43
	}
44
45
	/**
46
	 * @dataProvider loadErrorNotFoundProvider
47
	 * @param string $filePath
48
	 * @throws \Wonderland\Container\Exception\InvalidResourceException
49
	 * @throws \Wonderland\Container\Exception\ResourceNotFoundException
50
	 */
51
	public function test_loadFileErrorNotFound($filePath)
52
	{
53
		$this->expectException(ResourceNotFoundException::class);
54
		$this->parser->loadFile($filePath);
55
	}
56
57
	/**
58
	 * @dataProvider loadErrorNotFoundProvider
59
	 * @param string $filePath
60
	 * @throws \Wonderland\Container\Exception\InvalidResourceException
61
	 * @throws \Wonderland\Container\Exception\ResourceNotFoundException
62
	 */
63
	public function test_loadDirErrorNotFound($filePath)
64
	{
65
		$this->expectException(ResourceNotFoundException::class);
66
		$this->parser->loadDirectory($filePath);
67
	}
68
69
	/**
70
	 * @throws \Wonderland\Container\Exception\InvalidResourceException
71
	 * @throws \Wonderland\Container\Exception\ResourceNotFoundException
72
	 */
73
	public function test_loadFileErrorInvalid()
74
	{
75
		$this->expectException(InvalidResourceException::class);
76
		$this->parser->loadFile(__DIR__ . '/../data/yml');
77
	}
78
79
	/**
80
	 * @throws \Wonderland\Container\Exception\InvalidResourceException
81
	 * @throws \Wonderland\Container\Exception\ResourceNotFoundException
82
	 */
83
	public function test_loadDirErrorInvalid()
84
	{
85
		$this->expectException(InvalidResourceException::class);
86
		$this->parser->loadDirectory(__DIR__ . '/../data/yml/test-full.yml');
87
	}
88
89
}
90