protected function getEntry() { $entries = array(); $author = new Serializer\TestAuthor(); $author->setName('bar'); $object = new Serializer\TestObject(); $object->setTitle('foo'); $object->setAuthor($author); $object->setContributors([$author, $author]); $object->setTags(['foo', 'bar']); $entries[] = $object; $author = new Serializer\TestAuthor(); $author->setName('bar'); $object = new Serializer\TestObject(); $object->setTitle('bar'); $object->setAuthor($author); $object->setContributors([$author, $author]); $object->setTags(['foo', 'bar']); $entries[] = $object; return $entries; }
public function testSerialize() { $author = new Serializer\TestAuthor(); $author->setName('bar'); $object = new Serializer\TestObject(); $object->setTitle('foo'); $object->setAuthor($author); $object->setContributors([$author, $author]); $object->setTags(['foo', 'bar']); $return = Environment::getService('serializer')->serialize($object); $author = array(); $author['name'] = 'bar'; $expect = array(); $expect['title'] = 'foo'; $expect['author'] = $author; $expect['contributors'] = [$author, $author]; $expect['tags'] = ['foo', 'bar']; $this->assertEquals($expect, $return); }