/** * Test for validation of ambiguous data * * @param array $rowData * @param array $errors * @param string|null $behavior * @param int $numberOfValidations * * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::validateAmbiguousData * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findOldOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOldOptionsTypeMismatch * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_saveNewOptionData * @dataProvider validateAmbiguousDataDataProvider */ public function testValidateAmbiguousData(array $rowData, array $errors, $behavior = null, $numberOfValidations = 1) { if ($behavior) { $this->_model->setParameters(array('behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND)); } for ($i = 0; $i < $numberOfValidations; $i++) { $this->_model->validateRow($rowData, $i); } if (empty($errors)) { $this->assertTrue($this->_model->validateAmbiguousData()); } else { $this->assertFalse($this->_model->validateAmbiguousData()); } $this->assertAttributeEquals($errors, '_errors', $this->_productEntity); }
/** * Test for validation of ambiguous data * * @param array $rowData * @param array $errors * @param string|null $behavior * @param int $numberOfValidations * * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::validateAmbiguousData * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findOldOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOldOptionsTypeMismatch * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_saveNewOptionData * @dataProvider validateAmbiguousDataDataProvider */ public function testValidateAmbiguousData(array $rowData, array $errors, $behavior = null, $numberOfValidations = 1) { $this->_testStores = ['admin' => 0]; $this->setUp(); if ($behavior) { $this->_modelMock->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND]); } $this->_bypassModelMethodGetMultiRowFormat($rowData); for ($i = 0; $i < $numberOfValidations; $i++) { $this->_modelMock->validateRow($rowData, $i); } if (empty($errors)) { $this->assertTrue($this->_modelMock->validateAmbiguousData()); } else { $this->assertFalse($this->_modelMock->validateAmbiguousData()); } $this->assertAttributeEquals($errors, '_errors', $this->_productEntity); }
/** * Test for validation of ambiguous data * * @param array $rowData * @param array $errors * @param string|null $behavior * @param int $numberOfValidations * * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::validateAmbiguousData * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findOldOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOldOptionsTypeMismatch * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_saveNewOptionData * @dataProvider validateAmbiguousDataDataProvider */ public function testValidateAmbiguousData(array $rowData, array $errors, $behavior = null, $numberOfValidations = 1) { $this->_testStores = ['admin' => 0]; $this->setUp(); if ($behavior) { $this->modelMock->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND]); } $this->_bypassModelMethodGetMultiRowFormat($rowData); for ($i = 0; $i < $numberOfValidations; $i++) { $this->modelMock->validateRow($rowData, $i); } if (empty($errors)) { $this->assertTrue($this->modelMock->validateAmbiguousData()); } else { $this->assertFalse($this->modelMock->validateAmbiguousData()); } $resultErrors = $this->productEntity->getErrorAggregator()->getRowsGroupedByErrorCode([], [], false); $this->assertEquals($errors, $resultErrors); }