Exemplo n.º 1
0
 /**
  * @group 17
  */
 public function testCanSerializeTraversables()
 {
     $variables = ['some' => 'content', 'nested' => new ArrayObject(['objects' => 'should also be serialized', 'arbitrarily' => new ArrayIterator(['as' => 'deep as you like'])])];
     $iterator = new ArrayIterator($variables);
     $jsonModel = new JsonModel($iterator);
     $json = $jsonModel->serialize();
     $data = json_decode($json, true);
     $expected = ['some' => 'content', 'nested' => ['objects' => 'should also be serialized', 'arbitrarily' => ['as' => 'deep as you like']]];
     $this->assertEquals($expected, $data);
 }
Exemplo n.º 2
0
 /**
  * @group 17
  */
 public function testCanSerializeTraversables()
 {
     $variables = array(
         'some' => 'content',
         'nested' => new ArrayObject(array(
             'objects' => 'should also be serialized',
             'arbitrarily' => new ArrayIterator(array(
                 'as' => 'deep as you like',
             )),
         )),
     );
     $iterator  = new ArrayIterator($variables);
     $jsonModel = new JsonModel($iterator);
     $json = $jsonModel->serialize();
     $data = json_decode($json, true);
     $this->assertEquals(ArrayUtils::iteratorToArray($iterator), $data);
 }