/**
  * @dataProvider provideChangeExists
  */
 public function testChangeExists($expected, array $changeData)
 {
     $connectionManager = new ConsistentReadConnectionManager(wfGetLB());
     $detector = new RecentChangesDuplicateDetector($connectionManager);
     $this->initRecentChanges();
     $change = $this->newChange($changeData);
     $this->assertEquals($expected, $detector->changeExists($change), 'changeExists()');
 }
 /**
  * Injects an RC entry into the recentchanges, using the the given title and attribs
  *
  * @param Title[] $titles
  * @param EntityChange $change
  */
 public function injectRCRecords(array $titles, EntityChange $change)
 {
     $rcAttribs = $this->recentChangeFactory->prepareChangeAttributes($change);
     // TODO: do this via the job queue, in batches, see T107722
     foreach ($titles as $title) {
         if (!$title->exists()) {
             continue;
         }
         $rc = $this->recentChangeFactory->newRecentChange($change, $title, $rcAttribs);
         if ($this->recentChangesDuplicateDetector && $this->recentChangesDuplicateDetector->changeExists($rc)) {
             wfDebugLog(__CLASS__, __FUNCTION__ . ": skipping duplicate RC entry for " . $title->getFullText());
         } else {
             wfDebugLog(__CLASS__, __FUNCTION__ . ": saving RC entry for " . $title->getFullText());
             $rc->save();
         }
     }
 }