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'); } }
public function testMaxResults() { $dataGrid = m::mock('Cartalyst\\DataGrid\\DataGrid'); $dataGrid->shouldReceive('getData')->andReturn($this->getData()); $dataGrid->shouldReceive('getEnvironment')->andReturn($environment = m::mock('Cartalyst\\DataGrid\\Environment')); $environment->shouldReceive('getRequestProvider')->andReturn($requestProvider = m::mock('Cartalyst\\DataGrid\\RequestProviders\\ProviderInterface')); $requestProvider->shouldReceive('getFilters')->once()->andReturn(array()); $requestProvider->shouldReceive('getSort')->once()->andReturn('first_name'); $requestProvider->shouldReceive('getDirection')->once()->andReturn('asc'); $columns = array('first_name', 'gender' => 'sex', 'sortable', 'age'); $dataGrid->shouldReceive('getColumns')->andReturn($columns); $handler = new Handler($dataGrid); $handler->setUpDataHandlerContext(false, 1); $this->assertCount(1, $handler->getResults()); }