public function testCheckSynchronizationOperations() { $this->flag->expects($this->once())->method('loadSelf')->will($this->returnSelf()); $this->flag->expects($this->once())->method('isExpired')->will($this->returnValue(true)); $observer = $this->objectManagerHelper->getObject('Magento\\Framework\\Event\\Observer'); $this->notificationInterface->expects($this->once())->method('addMajor')->with('Google Shopping operation has expired.', 'One or more google shopping synchronization operations failed because of timeout.')->will($this->returnSelf()); $this->observer->checkSynchronizationOperations($observer); }
/** * Provides general error information * * @return void */ protected function _addGeneralError() { if (!$this->_hasError) { $this->_notifier->addMajor(__('Google Shopping Error'), $this->_gleShoppingCategory->getMessage()); $this->_hasError = true; } }
/** * Check if synchronize process is finished and generate notification message * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function checkSynchronizationOperations(\Magento\Framework\Event\Observer $observer) { $this->_flag->loadSelf(); if ($this->_flag->isExpired()) { $this->_notifier->addMajor(__('Google Shopping operation has expired.'), __('One or more google shopping synchronization operations failed because of timeout.')); $this->_flag->unlock(); } return $this; }
/** * @return void */ public function testDeleteItemsWitException() { $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getName', '__sleep', '__wakeup'])->getMock(); $product->expects($this->once())->method('getName')->will($this->returnValue('Product Name')); $item = $this->getMockBuilder('Magento\\GoogleShopping\\Model\\Item')->disableOriginalConstructor()->getMock(); $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); $item->expects($this->once())->method('deleteItem')->will($this->throwException(new \Exception('Test exception'))); $collection = $this->getMockBuilder('Magento\\GoogleShopping\\Model\\Resource\\Item\\Collection')->disableOriginalConstructor()->setMethods(['count', 'addFieldToFilter', 'getIterator'])->getMock(); $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); $collection->expects($this->once())->method('count')->will($this->returnValue(1)); $collection->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$item]))); $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection)); $this->notificationInterface->expects($this->once())->method('addMajor')->with('Errors happened while deleting items from Google Shopping', ['The item "Product Name" hasn\'t been deleted.'])->will($this->returnSelf()); $this->massOperations->deleteItems([1]); }