public function testAttributeEmptyDataModelClass() { $this->_attributeMetadata->expects($this->once())->method('getDataModel')->will($this->returnValue('')); $this->_attributeMetadata->expects($this->once())->method('getFrontendInput')->will($this->returnValue('text')); $dataModel = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form\\Text', array(), array(), '', false); $params = array('entityTypeCode' => $this->_entityTypeCode, 'value' => 'Some Text', 'isAjax' => false, 'attribute' => $this->_attributeMetadata); $this->_objectManager->expects($this->once())->method('create')->with('Magento\\Customer\\Model\\Metadata\\Form\\Text', $params)->will($this->returnValue($dataModel)); $actual = $this->_elementFactory->create($this->_attributeMetadata, 'Some Text', $this->_entityTypeCode); $this->assertSame($dataModel, $actual); }
/** * @covers Xoops\Form\ElementFactory::create * @covers Xoops\Form\ElementFactory::setContainer * @covers Xoops\Form\ElementFactory::validateSpec */ public function testSetContainer() { $container = new ElementTray([]); $this->object->setContainer($container); $spec = new \ArrayObject([ElementFactory::CLASS_KEY => 'Raw', 'value' => 'myvalue']); $actual = $this->object->create($spec); $this->assertInstanceOf('\\Xoops\\Form\\Raw', $actual); $this->assertArrayHasKey(ElementFactory::FORM_KEY, $spec); $this->assertSame($container, $spec[ElementFactory::FORM_KEY]); }
/** * Return attribute data model by attribute * * @param \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata $attribute * @return \Magento\Eav\Model\Attribute\Data\AbstractData */ protected function _getAttributeDataModel($attribute) { $dataModel = $this->_elementFactory->create($attribute, isset($this->_attributeValues[$attribute->getAttributeCode()]) ? $this->_attributeValues[$attribute->getAttributeCode()] : null, $this->_entityType, $this->_isAjax); return $dataModel; }