Beispiel #1
0
 /**
  * @test
  */
 public function resultIsJsonSerializable()
 {
     $data = ['one', 2, '3'];
     $page = new Page(3, 4);
     $total = 322;
     $result = new Result($data, $page, $total);
     $stringified = (string) $result;
     $this->assertEquals(json_encode(['meta' => ['offset' => $page->getOffset(), 'limit' => $page->getLimit(), 'total' => $total], 'data' => $data]), $stringified);
 }
Beispiel #2
0
 /**
  * @test
  */
 public function staticSetter()
 {
     $mockRequest = $this->getMockBuilder('\\Slim\\Http\\Request')->disableOriginalConstructor()->getMock();
     $offset = 3;
     $limit = 16;
     $mockRequest->expects($this->exactly(2))->method('get')->willReturnMap([['offset', null, $offset], ['limit', 10, $limit]]);
     $page = Page::createFromRequest($mockRequest);
     $this->assertEquals($offset, $page->getOffset());
     $this->assertEquals($limit, $page->getLimit());
 }