Passed
Push — master ( 5204b5...bf9fba )
by Alice
37s
created

YamlParserTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A test_loadDirErrorInvalid() 0 4 1
A test_loadFileErrorInvalid() 0 4 1
A test_load() 0 4 1
A loadErrorNotFoundProvider() 0 4 1
A test_loadFileErrorNotFound() 0 4 1
A test_loadDirErrorNotFound() 0 4 1
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