public function testCollectionRestore() { $objCollection = [clone $this->target, clone $this->target, clone $this->target]; $collProjection = Example1Representer::collection($objCollection)->toArray(); $restoredCollection = Example1Representer::restoreCollection(Example1::class)->fromArray($collProjection); $this->assertEquals(count($objCollection), count($restoredCollection)); foreach ($restoredCollection as $key => $object) { $this->assertEquals($objCollection[$key]->title, $object->title); $this->assertEquals($objCollection[$key]->status, $object->status); $this->assertEquals($objCollection[$key]->pubDate, $object->pubDate); } }
public function testDeserializationFromYaml() { $yaml = "titleAs: 'Cool story bro'\nstatus: 1\npubDate: '2016-01-18'\n"; $object = Example1Representer::restore(Example1::class)->fromYAML($yaml); $this->assertInstanceOf(Example1::class, $object); }