/** * Test data binding * It should validate required translations * * @param array $options * * @dataProvider bindDataProvider */ public function testBindData(array $options) { $target = $this->getTargetedClass($options); $translatableEntity = $this->getTranslatableEntityMock(); $locales = $options['locales']; foreach ($locales as $index => $locale) { $this->form->expects($this->at($index))->method('get')->with($locale)->will($this->returnValue($defaultField = $this->getFormMock())); $defaultField->expects($this->any())->method('getData')->will($this->returnValue(null)); } $event = $this->getEventMock($this->form, $translatableEntity, []); $target->submit($event); }
protected function assertProcessSegment() { $formData = ['definition' => 'test']; $this->form->expects($this->once())->method('getName')->will($this->returnValue('test_form')); $this->request->request->set('test_form', $formData); $businessUnit = $this->getMockBuilder('Oro\\Bundle\\OrganizationBundle\\Entity\\BusinessUnit')->disableOriginalConstructor()->getMock(); /** @var \PHPUnit_Framework_MockObject_MockObject|User $owner */ $owner = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\User')->disableOriginalConstructor()->getMock(); $owner->expects($this->atLeastOnce())->method('getOwner')->will($this->returnValue($businessUnit)); $this->testEntity->setName('test')->setDescription('description')->setType(new MarketingListType(MarketingListType::TYPE_DYNAMIC))->setOwner($owner); $segmentType = new SegmentType(SegmentType::TYPE_DYNAMIC); $this->manager->expects($this->once())->method('find')->with('OroSegmentBundle:SegmentType', MarketingListType::TYPE_DYNAMIC)->will($this->returnValue($segmentType)); }
public function testInvalidData() { $this->formField->expects($this->any())->method('getData')->will($this->returnValue($this->dateTimeStart)); $this->context->expects($this->once())->method('addViolation')->with($this->equalTo($this->constraint->message), $this->equalTo(array('{{ ' . $this->constraint->getDefaultOption() . ' }}' => $this->constraint->field))); $this->validator->validate($this->dateTimeEnd, $this->constraint); }
/** * @param \PHPUnit_Framework_MockObject_MockObject|Form $form * @param object $entity * @param string $wid * @return array */ protected function assertSaveData($form, $entity, $wid = 'WID') { $this->request->expects($this->atLeastOnce())->method('get')->with('_wid', false)->will($this->returnValue($wid)); $formView = $this->getMockBuilder('Symfony\\Component\\Form\\FormView')->disableOriginalConstructor()->getMock(); $form->expects($this->any())->method('createView')->will($this->returnValue($formView)); return ['entity' => $entity, 'form' => $formView, 'isWidgetContext' => true]; }