コード例 #1
0
 public function testAddException2()
 {
     try {
         $this->datagridMapper->getAdmin()->expects($this->any())->method('hasFilterFieldDescription')->will($this->returnValue(true));
         $this->datagridMapper->add('field');
     } catch (\RuntimeException $e) {
         $this->assertContains('The field "field" is already defined', $e->getMessage());
         return;
     }
     $this->fail('Failed asserting that exception of type "\\RuntimeException" is thrown.');
 }
コード例 #2
0
 public function testAddDuplicateNameException()
 {
     $tmpNames = array();
     $this->datagridMapper->getAdmin()->expects($this->exactly(2))->method('hasFilterFieldDescription')->will($this->returnCallback(function ($name) use(&$tmpNames) {
         if (isset($tmpNames[$name])) {
             return true;
         }
         $tmpNames[$name] = $name;
         return false;
     }));
     try {
         $this->datagridMapper->add('fooName');
         $this->datagridMapper->add('fooName');
     } catch (\RuntimeException $e) {
         $this->assertContains('Duplicate field name "fooName" in datagrid mapper. Names should be unique.', $e->getMessage());
         return;
     }
     $this->fail('Failed asserting that exception of type "\\RuntimeException" is thrown.');
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function configureDatagridFilters(DatagridMapper $filter)
 {
     $this->eventDispatcher->dispatch('sonata.admin.event.configure.datagrid', new ConfigureEvent($filter->getAdmin(), $filter, ConfigureEvent::TYPE_DATAGRID));
 }