Completed
Push — master ( ac6391...9b00f4 )
by Michael
12:56
created

YamlTest::testLegacyParseFromFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <[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 Symfony\Component\Yaml\Tests;
13
14
use Symfony\Component\Yaml\Yaml;
15
16
class YamlTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testParseAndDump()
19
    {
20
        $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
21
        $yml = Yaml::dump($data);
22
        $parsed = Yaml::parse($yml);
23
        $this->assertEquals($data, $parsed);
24
    }
25
26
    /**
27
     * @group legacy
28
     */
29
    public function testLegacyParseFromFile()
30
    {
31
        $filename = __DIR__.'/Fixtures/index.yml';
32
        $contents = file_get_contents($filename);
33
        $parsedByFilename = Yaml::parse($filename);
34
        $parsedByContents = Yaml::parse($contents);
35
        $this->assertEquals($parsedByFilename, $parsedByContents);
36
    }
37
38
    /**
39
     * @expectedException \InvalidArgumentException
40
     * @expectedExceptionMessage The indentation must be greater than zero
41
     */
42
    public function testZeroIndentationThrowsException()
43
    {
44
        Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
45
    }
46
47
    /**
48
     * @expectedException \InvalidArgumentException
49
     * @expectedExceptionMessage The indentation must be greater than zero
50
     */
51
    public function testNegativeIndentationThrowsException()
52
    {
53
        Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
54
    }
55
}
56