/**
  * Test for methods _addAttributeValuesToRow()
  *
  * @covers \Magento\ImportExport\Model\Export\Entity\AbstractEav::_initAttributeValues
  * @covers \Magento\ImportExport\Model\Export\Entity\AbstractEav::_addAttributeValuesToRow
  */
 public function testAddAttributeValuesToRow()
 {
     $testAttributeCode = 'lastname';
     $testAttributeValue = 'value';
     $testAttributeOptions = ['value' => 'option'];
     /** @var $testAttribute \Magento\Eav\Model\Entity\Attribute */
     $testAttribute = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], '', false, false, false, ['__wakeup']);
     $testAttribute->setAttributeCode($testAttributeCode);
     $this->_model->expects($this->any())->method('getAttributeCollection')->will($this->returnValue([$testAttribute]));
     $this->_model->expects($this->any())->method('getAttributeOptions')->will($this->returnValue($testAttributeOptions));
     /** @var $item \Magento\Framework\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject */
     $item = $this->getMockForAbstractClass('Magento\\Framework\\Model\\AbstractModel', [], '', false, true, true, ['getData', '__wakeup']);
     $item->expects($this->any())->method('getData')->will($this->returnValue($testAttributeValue));
     $method = new \ReflectionMethod($this->_model, '_initAttributeValues');
     $method->setAccessible(true);
     $method->invoke($this->_model);
     $method = new \ReflectionMethod($this->_model, '_addAttributeValuesToRow');
     $method->setAccessible(true);
     $row = $method->invoke($this->_model, $item);
     /**
      *  Prepare expected data
      */
     $expected = [];
     foreach ($this->_expectedAttributes as $code) {
         $expected[$code] = $testAttributeValue;
         if ($code == $testAttributeCode) {
             $expected[$code] = $testAttributeOptions[$expected[$code]];
         }
     }
     $this->assertEquals($expected, $row, 'Attributes were not added to result row');
 }
Ejemplo n.º 2
0
 protected function setUp()
 {
     /** @var \Magento\TestFramework\ObjectManager  $objectManager */
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $customerAttributes = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Resource\\Attribute\\Collection');
     $this->_model = $this->getMockForAbstractClass('Magento\\ImportExport\\Model\\Export\\Entity\\AbstractEav', array(), '', false);
     $this->_model->expects($this->any())->method('getEntityTypeCode')->will($this->returnValue($this->_entityCode));
     $this->_model->expects($this->any())->method('getAttributeCollection')->will($this->returnValue($customerAttributes));
     $this->_model->__construct($objectManager->get('Magento\\Framework\\App\\Config\\ScopeConfigInterface'), $objectManager->get('Magento\\Store\\Model\\StoreManager'), $objectManager->get('Magento\\ImportExport\\Model\\Export\\Factory'), $objectManager->get('Magento\\ImportExport\\Model\\Resource\\CollectionByPagesIteratorFactory'), $objectManager->get('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface'), $objectManager->get('Magento\\Eav\\Model\\Config'));
 }