예제 #1
0
 /**
  * Test delete action.
  */
 public function testSyncStorageDeleteItem()
 {
     $valueMap = [[123, [1], null], [123, [1, 2], null], [0, null, null]];
     $this->storageManager->expects($this->exactly(count($valueMap) - 1))->method('removeRecord')->will($this->returnValueMap($valueMap));
     foreach ($valueMap as $item) {
         $this->service->deleteItem($item[0], $item[1]);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function persistDocument()
 {
     switch ($this->syncStorageData['type']) {
         case ActionTypes::CREATE:
             $this->manager->persist($this->importItem->getDocument());
             break;
         case ActionTypes::UPDATE:
             $this->manager->persist($this->importItem->getDocument());
             break;
         case ActionTypes::DELETE:
             $this->manager->getRepository($this->documentType)->remove($this->importItem->getDocument()->getId());
             break;
         default:
             $this->log(sprintf('Failed to update document of type  %s id: %s: no valid operation type defined', get_class($this->importItem->getDocument()), $this->importItem->getDocument()->getId()));
             return false;
     }
     $this->syncStorage->deleteItem($this->syncStorageData['id'], [$this->syncStorageData['shop_id']]);
     return true;
 }