Ejemplo n.º 1
0
 /**
  * Test method deleteAdvancedPricing() whether _cachedSkuToDelete property is set to null.
  */
 public function testDeleteAdvancedPricingResetCachedSkuToDelete()
 {
     $this->setPropertyValue($this->advancedPricing, '_cachedSkuToDelete', 'some value');
     $this->dataSourceModel->expects($this->at(0))->method('getNextBunch')->willReturn([]);
     $this->advancedPricing->deleteAdvancedPricing();
     $cachedSkuToDelete = $this->getPropertyValue($this->advancedPricing, '_cachedSkuToDelete');
     $this->assertNull($cachedSkuToDelete);
 }
Ejemplo n.º 2
0
 public function testGetAffectedProducts()
 {
     $testProduct = 'test_product';
     $rowData = ['data'];
     $rowNum = 666;
     $importProduct = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Product')->disableOriginalConstructor()->setMethods(['isRowAllowedToImport', '_populateToUrlGeneration'])->getMock();
     $this->_dataSourceModel->expects($this->exactly(2))->method('getNextBunch')->willReturnOnConsecutiveCalls([$rowNum => $rowData], null);
     $this->setPropertyValue($importProduct, '_dataSourceModel', $this->_dataSourceModel);
     $importProduct->expects($this->once())->method('isRowAllowedToImport')->with($rowData, $rowNum)->willReturn(true);
     $importProduct->expects($this->once())->method('_populateToUrlGeneration')->with($rowData)->willReturn($testProduct);
     $this->assertEquals([$testProduct], $importProduct->getAffectedProducts());
 }
Ejemplo n.º 3
0
 public function testImportSource()
 {
     $entityTypeCode = 'code';
     $this->_importData->expects($this->any())->method('getEntityTypeCode')->will($this->returnValue($entityTypeCode));
     $behaviour = 'behaviour';
     $this->_importData->expects($this->once())->method('getBehavior')->will($this->returnValue($behaviour));
     $this->import->expects($this->any())->method('getDataSourceModel')->will($this->returnValue($this->_importData));
     $this->import->expects($this->any())->method('setData')->withConsecutive(['entity', $entityTypeCode], ['behavior', $behaviour]);
     $phraseClass = '\\Magento\\Framework\\Phrase';
     $this->import->expects($this->any())->method('addLogComment')->with($this->isInstanceOf($phraseClass));
     $this->_entityAdapter->expects($this->once())->method('importData')->will($this->returnSelf());
     $this->import->expects($this->once())->method('_getEntityAdapter')->will($this->returnValue($this->_entityAdapter));
     $importOnceMethodsReturnNull = ['getEntity', 'getBehavior', 'getProcessedRowsCount', 'getProcessedEntitiesCount', 'getInvalidRowsCount', 'getErrorsCount'];
     foreach ($importOnceMethodsReturnNull as $method) {
         $this->import->expects($this->once())->method($method)->will($this->returnValue(null));
     }
     $this->import->importSource();
 }
Ejemplo n.º 4
0
 /**
  * Test importSource with expected exception
  *
  * @expectedException \Magento\Framework\Exception\AlreadyExistsException
  * @expectedExceptionMessage URL key for specified store already exists.
  */
 public function testImportSourceException()
 {
     $exceptionMock = new \Magento\Framework\Exception\AlreadyExistsException(__('URL key for specified store already exists.'));
     $entityTypeCode = 'code';
     $this->_importData->expects($this->any())->method('getEntityTypeCode')->will($this->returnValue($entityTypeCode));
     $behaviour = 'behaviour';
     $this->_importData->expects($this->once())->method('getBehavior')->will($this->returnValue($behaviour));
     $this->import->expects($this->any())->method('getDataSourceModel')->will($this->returnValue($this->_importData));
     $this->import->expects($this->any())->method('setData')->withConsecutive(['entity', $entityTypeCode], ['behavior', $behaviour]);
     $phraseClass = '\\Magento\\Framework\\Phrase';
     $this->import->expects($this->any())->method('addLogComment')->with($this->isInstanceOf($phraseClass));
     $this->_entityAdapter->expects($this->once())->method('importData')->will($this->throwException($exceptionMock));
     $this->import->expects($this->once())->method('_getEntityAdapter')->will($this->returnValue($this->_entityAdapter));
     $importOnceMethodsReturnNull = ['getEntity', 'getBehavior'];
     foreach ($importOnceMethodsReturnNull as $method) {
         $this->import->expects($this->once())->method($method)->will($this->returnValue(null));
     }
     $this->import->importSource();
 }