fromArray() публичный статический Метод

public static fromArray ( $array )
Пример #1
0
 public function testDeserializeArray()
 {
     $jsonData = '[{"title":"foo","numbers":[5,3]},{"title":"bar","numbers":[2,8]}]';
     $expectedData = array(Model::fromArray(array('title' => 'foo', 'numbers' => array(5, 3))), Model::fromArray(array('title' => 'bar', 'numbers' => array(2, 8))));
     $serializer = new Serializer(array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array('json' => new JsonEncoder()));
     $this->assertEquals($expectedData, $serializer->deserialize($jsonData, __NAMESPACE__ . '\\Model[]', 'json'));
 }
Пример #2
0
 /**
  * @expectedException \Symfony\Component\Serializer\Exception\LogicException
  */
 public function testSerializeNoNormalizer()
 {
     $this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));
     $data = array('title' => 'foo', 'numbers' => array(5, 3));
     $this->serializer->serialize(Model::fromArray($data), 'json');
 }