public function testGetResults()
 {
     $query = $this->getMockBuilder('\\Sonata\\PropelAdminBundle\\Datagrid\\ProxyQuery', array('execute'))->disableOriginalConstructor()->getMock();
     $query->expects($this->once())->method('execute')->will($this->returnValue(42));
     $pager = new Pager();
     $pager->setQuery($query);
     $this->assertSame(42, $pager->getResults());
 }
 /**
  * Create a new Datagrid.
  *
  * @param AdminInterface $admin
  * @param array          $values
  *
  * @return DatagridInterface
  */
 public function getBaseDatagrid(AdminInterface $admin, array $values = array())
 {
     $pager = new Pager();
     $pager->setCountColumn($admin->getModelManager()->getIdentifierFieldNames($admin->getClass()));
     $defaultOptions = array();
     if ($this->csrfTokenEnabled) {
         $defaultOptions['csrf_protection'] = false;
     }
     $formBuilder = $this->formFactory->createNamedBuilder('filter', 'form', array(), $defaultOptions);
     return new Datagrid($admin->createQuery('list'), $admin->getList(), $pager, $formBuilder, $values);
 }