/** * 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); }
/** * Test importSource with expected exception * */ 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->any())->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->any())->method('importData')->will($this->throwException($exceptionMock)); $this->import->expects($this->any())->method('_getEntityAdapter')->will($this->returnValue($this->_entityAdapter)); $importOnceMethodsReturnNull = ['getBehavior']; foreach ($importOnceMethodsReturnNull as $method) { $this->import->expects($this->once())->method($method)->will($this->returnValue(null)); } $this->import->importSource(); }