public function testExecuteEmptyValidator()
 {
     if (interface_exists('Symfony\\Component\\Validator\\Mapping\\MetadataInterface')) {
         //sf2.5+
         $metadata = $this->getMock('Symfony\\Component\\Validator\\Mapping\\MetadataInterface');
     } else {
         $metadata = $this->getMock('Symfony\\Component\\Validator\\MetadataInterface');
     }
     $this->validatorFactory->expects($this->once())->method('getMetadataFor')->with($this->equalTo('Acme\\Entity\\Foo'))->will($this->returnValue($metadata));
     $metadata->properties = array();
     $metadata->getters = array();
     $modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\ModelManagerInterface');
     $this->admin->expects($this->any())->method('getModelManager')->will($this->returnValue($modelManager));
     // @todo Mock of \Traversable is available since Phpunit 3.8. This should be completed after stable release of Phpunit 3.8.
     // @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
     // $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
     //
     // $this->admin->expects($this->any())
     //     ->method('getFormBuilder')
     //     ->will($this->returnValue($formBuilder));
     $datagridBuilder = $this->getMock('\\Sonata\\AdminBundle\\Builder\\DatagridBuilderInterface');
     $this->admin->expects($this->any())->method('getDatagridBuilder')->will($this->returnValue($datagridBuilder));
     $listBuilder = $this->getMock('Sonata\\AdminBundle\\Builder\\ListBuilderInterface');
     $this->admin->expects($this->any())->method('getListBuilder')->will($this->returnValue($listBuilder));
     $command = $this->application->find('sonata:admin:explain');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'admin' => 'acme.admin.foo'));
     $this->assertSame(sprintf(str_replace("\n", PHP_EOL, file_get_contents(__DIR__ . '/../Fixtures/Command/explain_admin_empty_validator.txt')), get_class($this->admin), get_class($modelManager), get_class($datagridBuilder), get_class($listBuilder)), $commandTester->getDisplay());
 }
Exemplo n.º 2
0
 private function configureAdminRequest()
 {
     $this->admin->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->admin->expects($this->once())->method('hasRequest')->will($this->returnValue(true));
 }