Example #1
0
 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);
 }
 /**
  * @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]);
 }