/**
  * Test for method validateData() for delete behaviour
  *
  * @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::validateData
  */
 public function testValidateDataColumnNameWithWhitespacesForDeleteBehaviour()
 {
     $this->_createSourceAdapterMock(['  ']);
     $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE]);
     $errorAggregator = $this->_model->validateData();
     $this->assertEquals(0, $errorAggregator->getErrorsCount());
 }
 /**
  * Test whether correct methods are invoked in case of custom behaviour for each row in action column
  */
 public function testImportDataWithCustomBehaviour()
 {
     $this->_model = $this->_getModelMockForTestImportDataWithCustomBehaviour();
     $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_CUSTOM]);
     // validation in validateSaveCustomerEntities and validateDeleteCustomerEntities
     $this->_model->importData();
 }
Example #3
0
 /**
  * Test if correct methods are invoked according to different custom behaviours
  *
  * @covers Mage_ImportExport_Model_Import_Entity_Eav_Customer_Address::_importData
  */
 public function testImportDataWithCustomBehaviour()
 {
     $this->_model = $this->_getModelMockForTestImportDataWithCustomBehaviour();
     $this->_model->setParameters(array('behavior' => Mage_ImportExport_Model_Import::BEHAVIOR_CUSTOM));
     // validation in validateSaveAddressEntities and validateDeleteAddressEntities
     $this->_model->importData();
 }
 public function testValidateEmailForDeleteBehavior()
 {
     $this->_customerData[Customer::COLUMN_EMAIL] = '*****@*****.**';
     $this->_model->setParameters(['behavior' => Import::BEHAVIOR_DELETE]);
     $this->_model->validateRow($this->_customerData, 0);
     $this->assertGreaterThan(0, $this->_model->getErrorsCount());
     $this->assertArrayHasKey(Customer::ERROR_CUSTOMER_NOT_FOUND, $this->_model->getErrorMessages());
 }
 public function testValidateEmailForDeleteBehavior()
 {
     $this->_model->getErrorAggregator()->clear();
     $this->_customerData[Customer::COLUMN_EMAIL] = '*****@*****.**';
     $this->_model->setParameters(['behavior' => Import::BEHAVIOR_DELETE]);
     $this->_model->validateRow($this->_customerData, 0);
     $this->assertGreaterThan(0, $this->_model->getErrorAggregator()->getErrorsCount());
     $this->assertNotEmpty($this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_CUSTOMER_NOT_FOUND]));
 }
Example #6
0
 /**
  * Test for method getBehavior() with $rowData argument = null
  *
  * @covers Mage_ImportExport_Model_Import_EntityAbstract::getBehavior
  *
  * @dataProvider dataProviderForTestGetBehaviorWithRowData
  * @param $inputBehavior
  * @param $rowData
  * @param $expectedBehavior
  * @param null $availableBehaviors
  */
 public function testGetBehaviorWithRowData($inputBehavior, $rowData, $expectedBehavior, $availableBehaviors = null)
 {
     $property = new ReflectionProperty($this->_model, '_availableBehaviors');
     $property->setAccessible(true);
     if (isset($availableBehaviors)) {
         $property->setValue($this->_model, $availableBehaviors);
     } else {
         $property->setValue($this->_model, $this->_availableBehaviors);
     }
     $this->_model->setParameters(array('behavior' => $inputBehavior));
     $this->assertSame($expectedBehavior, $this->_model->getBehavior($rowData));
 }
 public function testValidateRowForDelete()
 {
     // _validateRowForDelete should be called only once
     $this->_model->expects($this->once())->method('_validateRowForDelete');
     // delete action
     $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE]);
     $this->_clearValidatedRows();
     $this->assertAttributeEquals([], '_validatedRows', $this->_model);
     $this->assertTrue($this->_model->validateRow([], 2));
     $this->assertAttributeEquals([2 => true], '_validatedRows', $this->_model);
     $this->assertAttributeEquals(1, '_processedEntitiesCount', $this->_model);
     $this->assertTrue($this->_model->validateRow([], 2));
 }
Example #8
0
 /**
  * Test for method validateData() for delete behaviour
  *
  * @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::validateData
  */
 public function testValidateDataColumnNameWithWhitespacesForDeleteBehaviour()
 {
     $this->_createSourceAdapterMock(['  ']);
     $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE]);
     $this->_model->validateData();
 }