Beispiel #1
0
 public function testViewNotFound()
 {
     $data = self::$objects;
     try {
         $a = \JsonApiBuilder::setData([$data['user']])->entity('auth.show1')->relationships(['comments', 'posts'])->included(['interests']);
     } catch (\Exception $e) {
         $this->assertEquals($e->getCode(), 0);
         $this->assertEquals($e->getMessage(), "View [auth.show1] not found.");
     }
 }
Beispiel #2
0
 public function testPaginationPaginationClass()
 {
     $data = self::$objects;
     $relationships = ['comments', 'posts'];
     $a = \JsonApiBuilder::setData([$data['user']])->entity('auth.show')->relationships($relationships)->included(['posts', 'comments' => ['post_id', 'content']]);
     $response = $a->parse();
     $parse = \Mockery::mock('Leeduc\\JsonApiBuilder\\JsonApiBuilder\\Parse[checkPaginationObject]', [$this->app->request, $this->app->view, $response, $a->getData()]);
     $parse->shouldReceive('checkPaginationObject')->andReturn(true);
     $parse1 = \Mockery::mock('Leeduc\\JsonApiBuilder\\JsonApiBuilder\\Generate[json]', [$this->app->request, $this->app->view]);
     $parse1->shouldReceive('json')->once()->andReturn($parse);
     $a = $parse1->setData($data['user'])->entity('auth.show')->json()->pagination()->response();
     $a = json_decode($a->content(), true);
     $compare = ["self" => "http://localhost", "first" => "examlple.com/1", "prev" => "example.com/previous", "next" => "example.com/next", "last" => "examlple.com/10"];
     foreach ($a['links'] as $key => $value) {
         $this->assertEquals($compare[$key], $value);
     }
 }