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')); } }