public function testbuildViewWithWithSonataAdmin()
 {
     $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin->expects($this->once())->method('getCode')->will($this->returnValue('my.admin.reference'));
     $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $formView = new FormView();
     $options = array();
     $config = new FormConfigBuilder('test', 'stdClass', $eventDispatcher, $options);
     $config->setAttribute('sonata_admin', array('admin' => $admin, 'name' => 'name'));
     $config->setAttribute('sonata_admin_enabled', true);
     $form = new Form($config);
     $formView->vars['block_prefixes'] = array('form', 'field', 'text', '_s50b26aa76cb96_username');
     $extension = new FormTypeFieldExtension();
     $extension->buildView($formView, $form, array());
     $this->assertArrayHasKey('block_prefixes', $formView->vars);
     $this->assertArrayHasKey('sonata_admin_enabled', $formView->vars);
     $this->assertArrayHasKey('sonata_admin', $formView->vars);
     $expected = array('form', 'field', 'text', 'my_admin_reference_text', 'my_admin_reference_name_text', 'my_admin_reference_name_text_username');
     $this->assertEquals($expected, $formView->vars['block_prefixes']);
     $this->assertTrue($formView->vars['sonata_admin_enabled']);
 }
 public function testbuildViewWithNestedForm()
 {
     $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $formView = new FormView();
     $formView->vars['name'] = 'format';
     $options = array();
     $config = new FormConfigBuilder('test', 'stdClass', $eventDispatcher, $options);
     $config->setAttribute('sonata_admin', array('admin' => false));
     $form = new Form($config);
     $formView->parent = new FormView();
     $formView->parent->vars['sonata_admin_enabled'] = true;
     $formView->parent->vars['sonata_admin_code'] = 'parent_code';
     $formView->parent->vars['name'] = 'settings';
     $formView->vars['block_prefixes'] = array('form', 'field', 'text', '_s50b26aa76cb96_settings_format');
     $extension = new FormTypeFieldExtension(array(), array());
     $extension->buildView($formView, $form, array('sonata_help' => 'help text'));
     $this->assertArrayHasKey('block_prefixes', $formView->vars);
     $this->assertArrayHasKey('sonata_admin_enabled', $formView->vars);
     $this->assertArrayHasKey('sonata_admin', $formView->vars);
     $expected = array('value' => null, 'attr' => array(), 'name' => 'format', 'block_prefixes' => array('form', 'field', 'text', 'parent_code_text', 'parent_code_text_settings_format', 'parent_code_text_settings_settings_format'), 'sonata_admin_enabled' => true, 'sonata_admin' => array('admin' => false, 'field_description' => false, 'name' => false, 'edit' => 'standard', 'inline' => 'natural', 'block_name' => false, 'class' => false, 'options' => array()), 'sonata_admin_code' => 'parent_code');
     $this->assertEquals($expected, $formView->vars);
 }