/**
  * Test record removal functionality.
  */
 public function testRemoveRecord()
 {
     $shopIds = [0, 1, 12345];
     $records = [(object) ['operationType' => ActionTypes::CREATE, 'documentType' => 'product', 'documentId' => 111, 'dateTime' => new DateTime('NOW -30 minutes'), 'shopIds' => $shopIds], (object) ['operationType' => ActionTypes::CREATE, 'documentType' => 'product', 'documentId' => 112, 'dateTime' => new DateTime('NOW -10 minutes'), 'shopIds' => $shopIds], (object) ['operationType' => ActionTypes::CREATE, 'documentType' => 'product', 'documentId' => 113, 'dateTime' => new DateTime('NOW -20 minutes'), 'shopIds' => $shopIds], (object) ['operationType' => ActionTypes::UPDATE, 'documentType' => 'product', 'documentId' => 114, 'dateTime' => new DateTime('NOW -5 minutes'), 'shopIds' => $shopIds]];
     foreach ($shopIds as $shopId) {
         $this->service->createStorage($shopId);
     }
     $this->addRecords($records);
     foreach ($shopIds as $shopId) {
         $tableName = self::TABLE_NAME . '_' . $shopId;
         $records = $this->getConnection()->fetchAll('SELECT id FROM `' . $tableName . '` WHERE `status` = :status', ['status' => 0]);
         $recordId = $records[rand(0, count($records) - 1)]['id'];
         $this->service->removeRecord($recordId, [$shopId]);
         $records = $this->getConnection()->fetchAll('SELECT id FROM `' . $tableName . '` WHERE `status` = :status', ['status' => 0]);
         $actualIds = [];
         foreach ($records as $rec) {
             $actualIds[] = $rec['id'];
         }
         $this->assertNotContains($recordId, $actualIds);
     }
 }
 /**
  * Test record removal while connection is malfunctioning.
  */
 public function testRemoveRecordWhileConnectionIsMalfunctioning()
 {
     $testRecordId = 123;
     $this->connection->expects($this->once())->method('delete')->with(self::TABLE_NAME . '_0', ['id' => $testRecordId])->will($this->throwException(new \Exception('Connection is not working')));
     $this->service->removeRecord($testRecordId);
 }