public function testWithFieldsCascadeTranslationDomain() { $this->admin->setModelManager($this->modelManager); $this->modelManager->expects($this->once())->method('getNewFieldDescriptionInstance')->with('class', 'foo', array('translation_domain' => 'Foobar', 'type' => 'bar'))->will($this->returnValue($this->fieldDescription)); $this->contractor->expects($this->once())->method('getDefaultOptions')->will($this->returnValue(array())); $this->admin->setLabelTranslatorStrategy($this->labelTranslatorStrategy); $this->formMapper->with('foobar', array('translation_domain' => 'Foobar'))->add('foo', 'bar')->end(); $this->assertSame(array('default' => array('collapsed' => false, 'class' => false, 'description' => false, 'translation_domain' => 'Foobar', 'name' => 'default', 'auto_created' => true, 'groups' => array('foobar'), 'tab' => true)), $this->admin->getFormTabs()); $this->assertSame(array('foobar' => array('collapsed' => false, 'class' => false, 'description' => false, 'translation_domain' => 'Foobar', 'name' => 'foobar', 'fields' => array('foo' => 'foo'))), $this->admin->getFormGroups()); }
public function setUp() { $this->contractor = $this->getMock('Sonata\\AdminBundle\\Builder\\FormContractorInterface'); $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface'); $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $formBuilder = new FormBuilder('test', 'stdClass', $eventDispatcher, $formFactory); $this->admin = new CleanAdmin('code', 'class', 'controller'); $this->modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\ModelManagerInterface'); // php 5.3 BC $fieldDescription = $this->getFieldDescriptionMock(); $this->modelManager->expects($this->any())->method('getNewFieldDescriptionInstance')->will($this->returnCallback(function ($class, $name, array $options = array()) use($fieldDescription) { $fieldDescriptionClone = clone $fieldDescription; $fieldDescriptionClone->setName($name); $fieldDescriptionClone->setOptions($options); return $fieldDescriptionClone; })); $this->admin->setModelManager($this->modelManager); $labelTranslatorStrategy = $this->getMock('Sonata\\AdminBundle\\Translator\\LabelTranslatorStrategyInterface'); $this->admin->setLabelTranslatorStrategy($labelTranslatorStrategy); $this->formMapper = new FormMapper($this->contractor, $formBuilder, $this->admin); }