Passed
Push — test ( d838cf...cef4a5 )
by Tom
03:29
created

Sf2YamlTest::testParseFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
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
 * Class Sf2YamlTest
11
 *
12
 * @covers \Ktomk\Pipelines\Yaml\Sf2Yaml
13
 *
14
 * @package Ktomk\Pipelines\Yaml
15
 */
16
class Sf2YamlTest extends TestCase
17
{
18
    public function testCreation()
19
    {
20
        $parser = new Sf2Yaml();
21
        self::assertInstanceOf('Ktomk\Pipelines\Yaml\Sf2Yaml', $parser);
22
        self::assertInstanceOf('Ktomk\Pipelines\Yaml\ParserInterface', $parser);
23
24
        return $parser;
25
    }
26
27
    /**
28
     * @param Sf2Yaml $parser
29
     * @depends testCreation
30
     */
31
    public function testParsing(Sf2Yaml $parser)
32
    {
33
        $tester = new YamlTester($this, $parser);
34
35
        $tester->assertParser();
36
    }
37
38
    /**
39
     * @depends testCreation
40
     *
41
     * @param Sf2Yaml $parser
42
     * @covers \Ktomk\Pipelines\Yaml\Sf2Yaml::parseFile
43
     */
44
    public function testParseFile(Sf2Yaml $parser)
45
    {
46
        $path = __DIR__ . '/../../../bitbucket-pipelines.yml';
47
48
        $struct = $parser->parseFile($path);
49
50
        self::assertIsArray($struct);
51
    }
52
53
    /**
54
     * Symfony YAML based YAML parser needs to return NULL on
55
     * invalid yaml file which it does not so needs patching
56
     * tested for.
57
     *
58
     * @depends testCreation
59
     *
60
     * @param Sf2Yaml $parser
61
     * @covers \Ktomk\Pipelines\Yaml\Sf2Yaml::parseBuffer
62
     */
63
    public function testParseFileError(Sf2Yaml $parser)
64
    {
65
        $path = __DIR__ . '/../../data/yml/error.yml';
66
67
        $struct = $parser->parseFile($path);
68
69
        self::assertNull($struct);
70
    }
71
}
72