Exemplo n.º 1
0
 /**
  * @expectedException        \Symfony\Component\Form\Exception\UnexpectedTypeException
  * @expectedExceptionMessage Expected argument of type "FieldDescriptionInterface", "array" given
  */
 public function testBuildPagerWithException()
 {
     $filter = $this->getMock('Sonata\\AdminBundle\\Filter\\FilterInterface');
     $filter->expects($this->once())->method('getName')->will($this->returnValue('foo'));
     $filter->expects($this->any())->method('isActive')->will($this->returnValue(false));
     $filter->expects($this->any())->method('getRenderSettings')->will($this->returnValue(array('foo', array('bar' => 'baz'))));
     $this->datagrid->addFilter($filter);
     $this->datagrid->setValue('_sort_by', 'foo', 'baz');
     $this->datagrid->buildPager();
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getBuildPagerWithPage2Tests
  */
 public function testBuildPagerWithPage2($page, $perPage)
 {
     $this->pager->expects($this->once())->method('setMaxPerPage')->with($this->equalTo('50'))->will($this->returnValue(null));
     $this->pager->expects($this->once())->method('setPage')->with($this->equalTo('3'))->will($this->returnValue(null));
     $this->datagrid = new Datagrid($this->query, $this->columns, $this->pager, $this->formBuilder, array());
     $this->datagrid->setValue('_per_page', null, $perPage);
     $this->datagrid->setValue('_page', null, $page);
     $this->datagrid->buildPager();
     $this->assertSame(array('_per_page' => array('type' => null, 'value' => $perPage), '_page' => array('type' => null, 'value' => $page)), $this->datagrid->getValues());
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_sort_by'));
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_sort_order'));
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_page'));
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_per_page'));
 }