YamlTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 12
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testParseAndDump() 0 6 1
A testLegacyParseFromFile() 0 7 1
A testZeroIndentationThrowsException() 0 3 1
A testNegativeIndentationThrowsException() 0 3 1
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 PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Symfony\Component\Yaml\Yaml;
16
17
class YamlTest extends TestCase
18
{
19
    public function testParseAndDump()
20
    {
21
        $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
22
        $yml = Yaml::dump($data);
23
        $parsed = Yaml::parse($yml);
24
        $this->assertEquals($data, $parsed);
25
    }
26
27
    /**
28
     * @group legacy
29
     */
30
    public function testLegacyParseFromFile()
31
    {
32
        $filename = __DIR__.'/Fixtures/index.yml';
33
        $contents = file_get_contents($filename);
34
        $parsedByFilename = Yaml::parse($filename);
35
        $parsedByContents = Yaml::parse($contents);
36
        $this->assertEquals($parsedByFilename, $parsedByContents);
37
    }
38
39
    /**
40
     * @expectedException \InvalidArgumentException
41
     * @expectedExceptionMessage The indentation must be greater than zero
42
     */
43
    public function testZeroIndentationThrowsException()
44
    {
45
        Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
46
    }
47
48
    /**
49
     * @expectedException \InvalidArgumentException
50
     * @expectedExceptionMessage The indentation must be greater than zero
51
     */
52
    public function testNegativeIndentationThrowsException()
53
    {
54
        Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
55
    }
56
}
57