@@ -21,6 +21,21 @@ class DumperTest extends \PHPUnit_Framework_TestCase
21
21
protected $ dumper ;
22
22
protected $ path ;
23
23
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
+
24
39
protected function setUp ()
25
40
{
26
41
$ this ->parser = new Parser ();
@@ -33,6 +48,33 @@ protected function tearDown()
33
48
$ this ->parser = null ;
34
49
$ this ->dumper = null ;
35
50
$ 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 ));
36
78
}
37
79
38
80
public function testSpecifications ()
@@ -63,27 +105,11 @@ public function testSpecifications()
63
105
64
106
public function testInlineLevel ()
65
107
{
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
-
82
108
$ expected = <<<EOF
83
109
{ '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
84
110
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 ' );
87
113
88
114
$ expected = <<<EOF
89
115
'': bar
@@ -93,7 +119,7 @@ public function testInlineLevel()
93
119
foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
94
120
95
121
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 ' );
97
123
98
124
$ expected = <<<EOF
99
125
'': bar
@@ -108,7 +134,7 @@ public function testInlineLevel()
108
134
foobar: { foo: bar, bar: [1, foo] }
109
135
110
136
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 ' );
112
138
113
139
$ expected = <<<EOF
114
140
'': bar
@@ -127,7 +153,7 @@ public function testInlineLevel()
127
153
bar: [1, foo]
128
154
129
155
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 ' );
131
157
132
158
$ expected = <<<EOF
133
159
'': bar
@@ -148,8 +174,8 @@ public function testInlineLevel()
148
174
- foo
149
175
150
176
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 ' );
153
179
}
154
180
155
181
public function testObjectSupportEnabled ()
0 commit comments