@@ -206,25 +206,6 @@ public function testInlineLevel()
206
206
$ this ->assertEquals ($ expected , $ this ->dumper ->dump ($ this ->array , 10 ), '->dump() takes an inline level argument ' );
207
207
}
208
208
209
- public function testArrayObjectAsMapNotInLined ()
210
- {
211
- $ deep = new \ArrayObject (array ('deep1 ' => 'd ' , 'deep2 ' => 'e ' ));
212
- $ inner = new \ArrayObject (array ('inner1 ' => 'b ' , 'inner2 ' => 'c ' , 'inner3 ' => $ deep ));
213
- $ outer = new \ArrayObject (array ('outer1 ' => 'a ' , 'outer1 ' => $ inner ));
214
-
215
- $ yaml = $ this ->dumper ->dump ($ outer , 2 , 0 , Yaml::DUMP_OBJECT_AS_MAP );
216
-
217
- $ expected = <<<YAML
218
- outer1: a
219
- outer2:
220
- inner1: b
221
- inner2: c
222
- inner3: { deep1: d, deep2: e }
223
-
224
- YAML ;
225
- $ this ->assertEquals ($ expected , $ yaml );
226
- }
227
-
228
209
public function testObjectSupportEnabled ()
229
210
{
230
211
$ dump = $ this ->dumper ->dump (array ('foo ' => new A (), 'bar ' => 1 ), 0 , 0 , Yaml::DUMP_OBJECT );
@@ -352,6 +333,63 @@ public function objectAsMapProvider()
352
333
return $ tests ;
353
334
}
354
335
336
+ public function testDumpEmptyArrayObjectInstanceAsMap ()
337
+ {
338
+ $ this ->assertSame ('{ } ' , $ this ->dumper ->dump (new \ArrayObject (), 2 , 0 , Yaml::DUMP_OBJECT_AS_MAP ));
339
+ }
340
+
341
+ public function testDumpingArrayObjectInstancesRespectsInlineLevel ()
342
+ {
343
+ $ deep = new \ArrayObject (array ('deep1 ' => 'd ' , 'deep2 ' => 'e ' ));
344
+ $ inner = new \ArrayObject (array ('inner1 ' => 'b ' , 'inner2 ' => 'c ' , 'inner3 ' => $ deep ));
345
+ $ outer = new \ArrayObject (array ('outer1 ' => 'a ' , 'outer2 ' => $ inner ));
346
+
347
+ $ yaml = $ this ->dumper ->dump ($ outer , 2 , 0 , Yaml::DUMP_OBJECT_AS_MAP );
348
+
349
+ $ expected = <<<YAML
350
+ outer1: a
351
+ outer2:
352
+ inner1: b
353
+ inner2: c
354
+ inner3: { deep1: d, deep2: e }
355
+
356
+ YAML ;
357
+ $ this ->assertSame ($ expected , $ yaml );
358
+ }
359
+
360
+ public function testDumpEmptyStdClassInstanceAsMap ()
361
+ {
362
+ $ this ->assertSame ('{ } ' , $ this ->dumper ->dump (new \stdClass (), 2 , 0 , Yaml::DUMP_OBJECT_AS_MAP ));
363
+ }
364
+
365
+ public function testDumpingStdClassInstancesRespectsInlineLevel ()
366
+ {
367
+ $ deep = new \stdClass ();
368
+ $ deep ->deep1 = 'd ' ;
369
+ $ deep ->deep2 = 'e ' ;
370
+
371
+ $ inner = new \stdClass ();
372
+ $ inner ->inner1 = 'b ' ;
373
+ $ inner ->inner2 = 'c ' ;
374
+ $ inner ->inner3 = $ deep ;
375
+
376
+ $ outer = new \stdClass ();
377
+ $ outer ->outer1 = 'a ' ;
378
+ $ outer ->outer2 = $ inner ;
379
+
380
+ $ yaml = $ this ->dumper ->dump ($ outer , 2 , 0 , Yaml::DUMP_OBJECT_AS_MAP );
381
+
382
+ $ expected = <<<YAML
383
+ outer1: a
384
+ outer2:
385
+ inner1: b
386
+ inner2: c
387
+ inner3: { deep1: d, deep2: e }
388
+
389
+ YAML ;
390
+ $ this ->assertSame ($ expected , $ yaml );
391
+ }
392
+
355
393
public function testDumpMultiLineStringAsScalarBlock ()
356
394
{
357
395
$ data = array (
0 commit comments