public function testGetRoot()
 {
     $serializer = new BaseSerializer();
     $obj = new RESTModelStub();
     $collection = new Collection();
     $this->assertEquals('foo', $serializer->getRoot($obj, 'foo'));
     $this->assertEquals('foos', $serializer->getRoot($collection, 'foo'));
 }
 /**
  * Serialize instance to json ready array.
  *
  * @param \Illuminate\Support\Contracts\ArrayableInterface $instance
  * @param string $root
  * @return array
  */
 public function serialize(ArrayableInterface $instance, $root)
 {
     $relationship = array();
     $serialized_data = parent::serialize($instance, $root);
     $root = $this->getRoot($instance, $root);
     if ($this->with_relations) {
         $serialized_data[$root] = $this->serializeKeys($instance)->toArray();
     }
     return array_merge($serialized_data, $relationship);
 }