public function setUp()
 {
     $contractor = $this->getMock('Sonata\\AdminBundle\\Builder\\FormContractorInterface');
     $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $this->eventDispatcher = new EventDispatcher();
     $formBuilder = new FormBuilder('form', null, $this->eventDispatcher, $formFactory);
     $this->modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\LockInterface');
     $this->admin = $this->getMockBuilder('Sonata\\AdminBundle\\Admin\\AbstractAdmin')->disableOriginalConstructor()->getMock();
     $this->admin->expects($this->any())->method('getModelManager')->will($this->returnValue($this->modelManager));
     $this->request = new Request();
     $this->admin->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->admin->expects($this->any())->method('hasRequest')->will($this->returnValue(true));
     $formMapper = new FormMapper($contractor, $formBuilder, $this->admin);
     $this->object = new \StdClass();
     $this->form = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $this->form->expects($this->any())->method('getData')->will($this->returnValue($this->object));
     $this->lockExtension = new LockExtension();
     $this->lockExtension->configureFormFields($formMapper);
 }
 public function testConfigureFormFieldsWhenModelManagerHasNoLockedVersion()
 {
     $modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\ModelManagerInterface');
     $formMapper = $this->configureFormMapper();
     $form = $this->configureForm();
     $event = new FormEvent($form, array());
     $this->admin->expects($this->any())->method('getModelManager')->will($this->returnValue($this->modelManager));
     $this->modelManager->expects($this->once())->method('getLockVersion')->will($this->returnValue(null));
     $form->expects($this->never())->method('add');
     $this->lockExtension->configureFormFields($formMapper);
     $this->eventDispatcher->dispatch(FormEvents::PRE_SET_DATA, $event);
 }