public function testBuildLink()
 {
     Config::shouldReceive('get')->with('andizzle/rest-framework::page_limit')->andReturn('5');
     REST::shouldReceive('getApiPrefix')->andReturn('api/v1');
     $serializer = new HyperlinkedJSONSerializer();
     $fooobj = new RESTModelStub();
     $fooobj->id = 1;
     $fooobj->root = 'roots';
     $collection = new Collection();
     $collection->add($fooobj);
     $this->assertEquals('api/v1/roots/1', $serializer->buildLink($fooobj));
     $this->assertEquals('api/v1/roots?ids=1', $serializer->buildLink($collection));
 }
Exemplo n.º 2
0
 /**
  * Process the request and replace the input
  *
  * @param $route
  * @param $request
  * @return void
  */
 public function preprocessRequest($route, $request)
 {
     $input = REST::convertCase($request->all(), 'snakeCase');
     $input = $this->handleRequest($input);
     $request->replace($input);
 }
 public function __construct()
 {
     $this->api_prefix = REST::getApiPrefix();
 }
Exemplo n.º 4
0
 /**
  * Convert the array keys to wanted case format.
  *
  * @param array $data
  * @return array
  */
 public function dehydrate(array $data)
 {
     return REST::convertCase($data);
 }