public function testCollectionRestore() { $objCollection = [$this->instance(Post::class), $this->instance(Post::class), $this->instance(Post::class)]; $collProjection = Post1Representer::collection($objCollection)->toArray(); $restoredCollection = Post1Representer::restoreCollection(Post::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->format('Y-m-d'), $object->pubDate->format('Y-m-d')); } }
public function testDeserializationFromYaml() { $yaml = "titleAs: 'Cool story bro'\nstatus: 1\npubDate: '2016-01-18'\n"; $object = Post1Representer::restore(Post::class)->fromYAML($yaml); $this->assertInstanceOf(Post::class, $object); }