/** * @param QuoteProductRequest $inputData * @param array $expectedData * * @dataProvider preSetDataProvider */ public function testPreSetData(QuoteProductRequest $inputData = null, array $expectedData = []) { $form = $this->factory->create($this->formType); $unitCode = $inputData ? $inputData->getProductUnitCode() : ''; $this->translator->expects($expectedData['empty_value'] ? $this->once() : $this->never())->method('trans')->with($expectedData['empty_value'], ['{title}' => $unitCode])->will($this->returnValue($expectedData['empty_value'])); $this->formType->preSetData(new FormEvent($form, $inputData)); $this->assertTrue($form->has('productUnit')); $config = $form->get('productUnit')->getConfig(); $this->assertEquals(ProductUnitSelectionType::NAME, $config->getType()->getName()); $options = $form->get('productUnit')->getConfig()->getOptions(); foreach ($expectedData as $key => $value) { $this->assertEquals($value, $options[$key], $key); } }