Passed
Push — test ( e89324...128558 )
by Tom
04:08
created

YamlTest::testCreateFromNonExistentFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Yaml;
6
7
use Ktomk\Pipelines\TestCase;
8
9
/**
10
 * @covers \Ktomk\Pipelines\Yaml\Yaml
11
 */
12
class YamlTest extends TestCase
13
{
14
    protected function doTearDown()
15
    {
16
        Yaml::$classes = array();
17
        parent::doTearDown();
18
    }
19
20
    public function testFileParsing()
21
    {
22
        $path = __DIR__ . '/../../../bitbucket-pipelines.yml';
23
24
        $struct = Yaml::file($path);
25
26
        self::assertIsArray($struct);
27
    }
28
29
    /**
30
     */
31
    public function testCreateFromNonExistentFile()
32
    {
33
        $this->expectException('InvalidArgumentException');
34
        $this->expectExceptionMessage('not a readable file: \'xxx\'');
35
36
        Yaml::file('xxx');
37
    }
38
39
    /**
40
     * Non-YAML files normally parse again to some array
41
     */
42
    public function testNonYamlFile()
43
    {
44
        $array = Yaml::file(__FILE__);
45
46
        self::assertNull($array);
47
    }
48
49
    public function testYamlNull()
50
    {
51
        $array = Yaml::buffer('first: ~');
52
53
        self::assertArrayHasKey('first', $array);
54
        self::assertNull($array['first']);
55
    }
56
57
    public function testNoParserAvailable()
58
    {
59
        Yaml::$classes = array('');
60
61
        $this->expectException('BadMethodCallException');
62
        $this->expectExceptionMessage('No YAML parser available');
63
64
        Yaml::buffer('---');
65
    }
66
}
67