コード例 #1
0
 /**
  * Test if extraction for "update" item works.
  */
 public function testCreatingUpdateItem()
 {
     $category = 'product';
     $id = 123;
     $timestamp = new \DateTime('-1 hour');
     $diffItem = new UpdateDiffItem();
     $diffItem->setCategory($category);
     $diffItem->setTimestamp($timestamp);
     $diffItem->setItemId($id);
     $this->storage->expects($this->once())->method('save')->with(ActionTypes::UPDATE, $category, $id, $timestamp);
     $this->service->extract($diffItem);
 }
コード例 #2
0
 /**
  * Test if extract is able to add data to the storage for item update action.
  */
 public function testExtractForUpdateItem()
 {
     $category = 'product';
     $id = 123;
     $timestamp = new DateTime('-1 hour 20 minutes');
     $updateDiffItem = new UpdateDiffItem();
     $updateDiffItem->setCategory($category);
     $updateDiffItem->setItemId($id);
     $updateDiffItem->setTimestamp($timestamp);
     $this->extractor->extract($updateDiffItem);
     foreach ($this->shopIds as $shopId) {
         $actual = (object) $this->getConnection()->fetchAssoc('SELECT * FROM ' . $this->storageManager->getTableName($shopId) . ' WHERE
                 `type` = :operationType
                 AND `document_type` = :documentType
                 AND `document_id` = :documentId
                 AND `status` = :status', ['operationType' => ActionTypes::UPDATE, 'documentType' => $category, 'documentId' => $id, 'status' => 0]);
         $this->assertTrue(!empty($actual->id));
         $this->assertEquals(ActionTypes::UPDATE, $actual->type);
         $this->assertEquals($category, $actual->document_type);
         $this->assertEquals($id, $actual->document_id);
         $this->assertEquals($timestamp, new DateTime($actual->timestamp));
     }
 }