/** * @param TypeGuess|null $expected * @param Attribute $attribute * @param array $formMapping * @param array $formConfig * @dataProvider guessAttributeFormDataProvider */ public function testGuessAttributeForm($expected, Attribute $attribute, array $formMapping = array(), array $formConfig = array()) { foreach ($formMapping as $mapping) { $this->guesser->addFormTypeMapping($mapping['attributeType'], $mapping['formType'], $mapping['formOptions']); } if ($formConfig) { $formConfigId = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\Id\\FieldConfigId')->disableOriginalConstructor()->getMock(); $formConfigObject = new Config($formConfigId, $formConfig); $this->formConfigProvider->expects($this->once())->method('hasConfig')->with($formConfig['entity'])->will($this->returnValue(true)); $this->formConfigProvider->expects($this->once())->method('getConfig')->with($formConfig['entity'])->will($this->returnValue($formConfigObject)); } $this->assertEquals($expected, $this->guesser->guessAttributeForm($attribute)); }
/** * @param TypeGuess|null $expected * @param Attribute $attribute * @param array $formMapping * @param array $formConfig * @dataProvider guessAttributeFormDataProvider */ public function testGuessAttributeForm($expected, Attribute $attribute, array $formMapping = array(), array $formConfig = array()) { foreach ($formMapping as $mapping) { $this->guesser->addFormTypeMapping($mapping['attributeType'], $mapping['formType'], $mapping['formOptions']); } if ($formConfig) { $this->formConfigProvider->expects($this->once())->method('hasConfig')->with($formConfig['entity'])->will($this->returnValue(true)); $formConfigObject = $this->getMockForAbstractClass('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface'); $formConfigObject->expects($this->at(0))->method('has')->with('form_type')->will($this->returnValue(true)); $formConfigObject->expects($this->at(1))->method('get')->with('form_type')->will($this->returnValue($formConfig['form_type'])); $formConfigObject->expects($this->at(2))->method('has')->with('form_options')->will($this->returnValue(true)); $formConfigObject->expects($this->at(3))->method('get')->with('form_options')->will($this->returnValue($formConfig['form_options'])); $this->formConfigProvider->expects($this->once())->method('getConfig')->with($formConfig['entity'])->will($this->returnValue($formConfigObject)); } $this->assertEquals($expected, $this->guesser->guessAttributeForm($attribute)); }