public function test_migrateVisits() { $visit = array('idvisit' => 123, 'idsite' => 2, 'visit_exit_idaction_url' => 4, 'visit_exit_idaction_name' => 6, 'visit_entry_idaction_url' => 8, 'visit_entry_idaction_name' => 10); $batchProvider = new \ArrayIterator(array($visit)); $this->toDbHelper->expects($this->once())->method('executeInsert')->with('log_visit', $this->anything()); $this->toDbHelper->expects($this->once())->method('lastInsertId')->will($this->returnValue(321)); $this->siteMigrator->expects($this->once())->method('getNewId')->with(2)->will($this->returnValue(3)); $this->actionMigrator->expects($this->exactly(4))->method('getNewId')->will($this->onConsecutiveCalls(5, 7, 9, 11)); $this->visitMigrator->migrate($batchProvider); $this->assertEquals(321, $this->visitMigrator->getNewId(123)); }
protected function translateRow(&$row) { $row['idsite'] = $this->siteMigrator->getNewId($row['idsite']); $row['idvisit'] = $this->visitMigrator->getNewId($row['idvisit']); foreach ($this->actionsToTranslate as $translationKey) { if ($row[$translationKey] == 0) { continue; } $row[$translationKey] = $this->actionMigrator->getNewId($row[$translationKey]); } }
protected function translateRow(&$row) { $row['idsite'] = $this->siteMigrator->getNewId($row['idsite']); $row['idvisit'] = $this->visitMigrator->getNewId($row['idvisit']); if ($row['idlink_va']) { $row['idlink_va'] = $this->linkVisitActionMigrator->getNewId($row['idlink_va']); } if ($row['idaction_url']) { $row['idaction_url'] = $this->actionMigrator->getNewId($row['idaction_url']); } else { $row['idaction_url'] = 0; } }
private function getLogVisitQueriesFor($table) { $visitIdRanges = $this->visitMigrator->getIdRanges(); if (count($visitIdRanges) > 0) { $baseQuery = "SELECT * FROM " . $this->sourceDbHelper->prefixTable($table) . ' WHERE idvisit IN '; $queries = array(); foreach ($visitIdRanges as $range) { $queries[] = $baseQuery . ' (' . implode(', ', $range) . ')'; } return $queries; } else { return array(); } }