8000 Added unit tests to Dumper · symfony/symfony@992a440 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 992a440

Browse files
eddiejaoudefabpot
authored andcommitted
Added unit tests to Dumper
1 parent 19955c5 commit 992a440

File tree

1 file changed

+49
-23
lines changed

1 file changed

+49
-23
lines changed

src/Symfony/Component/Yaml/Tests/DumperTest.php

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ class DumperTest extends \PHPUnit_Framework_TestCase
2121
protected $dumper;
2222
protected $path;
2323

24+
protected $array = array(
25+
'' => 'bar',
26+
'foo' => '#bar',
27+
'foo\'bar' => array(),
28+
'bar' => array(1, 'foo'),
29+
'foobar' => array(
30+
'foo' => 'bar',
31+
'bar' => array(1, 'foo'),
32+
'foobar' => array(
33+
'foo' => 'bar',
34+
'bar' => array(1, 'foo'),
35+
),
36+
),
37+
);
38+
2439
protected function setUp()
2540
{
2641
$this->parser = new Parser();
@@ -33,6 +48,33 @@ protected function tearDown()
3348
$this->parser = null;
3449
$this->dumper = null;
3550
$this->path = null;
51+
$this->array = null;
52+
}
53+
54+
public function testSetIndentation()
55+
{
56+
$this->dumper->setIndentation(7);
57+
58+
$expected = <<<EOF
59+
'': bar
60+
foo: '#bar'
61+
'foo''bar': { }
62+
bar:
63< 10000 /td>+
- 1
64+
- foo
65+
foobar:
66+
foo: bar
67+
bar:
68+
- 1
69+
- foo
70+
foobar:
71+
foo: bar
72+
bar:
73+
- 1
74+
- foo
75+
76+
EOF;
77+
$this->assertEquals($expected, $this->dumper->dump($this->array, 4, 0));
3678
}
3779

3880
public function testSpecifications()
@@ -63,27 +105,11 @@ public function testSpecifications()
63105

64106
public function testInlineLevel()
65107
{
66-
// inline level
67-
$array = array(
68-
'' => 'bar',
69-
'foo' => '#bar',
70-
'foo\'bar' => array(),
71-
'bar' => array(1, 'foo'),
72-
'foobar' => array(
73-
'foo' => 'bar',
74-
'bar' => array(1, 'foo'),
75-
'foobar' => array(
76-
'foo' => 'bar',
77-
'bar' => array(1, 'foo'),
78-
),
79-
),
80-
);
81-
82108
$expected = <<<EOF
83109
{ '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
84110
EOF;
85-
$this->assertEquals($expected, $this->dumper->dump($array, -10), '->dump() takes an inline level argument');
86-
$this->assertEquals($expected, $this->dumper->dump($array, 0), '->dump() takes an inline level argument');
111+
$this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
112+
$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
87113

88114
$expected = <<<EOF
89115
'': bar
@@ -93,7 +119,7 @@ public function testInlineLevel()
93119
foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
94120
95121
EOF;
96-
$this->assertEquals($expected, $this->dumper->dump($array, 1), '->dump() takes an inline level argument');
122+
$this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
97123

98124
$expected = <<<EOF
99125
'': bar
@@ -108,7 +134,7 @@ public function testInlineLevel()
108134
foobar: { foo: bar, bar: [1, foo] }
109135
110136
EOF;
111-
$this->assertEquals($expected, $this->dumper->dump($array, 2), '->dump() takes an inline level argument');
137+
$this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
112138

113139
$expected = <<<EOF
114140
'': bar
@@ -127,7 +153,7 @@ public function testInlineLevel()
127153
bar: [1, foo]
128154
129155
EOF;
130-
$this->assertEquals($expected, $this->dumper->dump($array, 3), '->dump() takes an inline level argument');
156+
$this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
131157

132158
$expected = <<<EOF
133159
'': bar
@@ -148,8 +174,8 @@ public function testInlineLevel()
148174
- foo
149175
150176
EOF;
151-
$this->assertEquals($expected, $this->dumper->dump($array, 4), '->dump() takes an inline level argument');
152-
$this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument');
177+
$this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
178+
$this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
153179
}
154180

155181
public function testObjectSupportEnabled()

0 commit comments

Comments
 (0)
0