public function testCalculatePages() { $handler = new Handler($dataGrid = $this->getMockDataGrid()); $handler->setUpDataHandlerContext(); $handler->setSort('first_name'); $handler->setDirection('asc'); $handler->setDefaultColumn('age'); $handler->setTransformer(function ($el) { $el['first_name'] = 'Name'; }); $pages = $handler->calculatePages(19, 6, 9); $this->assertEquals($pages[0], 6); $this->assertEquals($pages[1], 3); $this->assertNull($pages[2]); }
public function testTransform() { $handler = new Handler($dataGrid = $this->getMockDataGrid()); $handler->setTransformer(function ($el) { $el['first_name'] = 'foobar'; return $el; }); $handler->hydrate(); $expected = $this->getValidatedData(); $this->assertCount(count($expected), $data = $handler->getResults()); foreach ($data as $item) { $this->assertEquals($item['first_name'], 'foobar'); } }