Esempio n. 1
0
 protected function AddGroup()
 {
     $groupName = $this->page->GetGroupName();
     Log::Debug('Adding new group with name: %s', $groupName);
     $group = new Group(0, $groupName);
     $this->groupRepository->Add($group);
 }
Esempio n. 2
0
 public function testCanAddNewGroup()
 {
     $newId = 40298;
     $name = 'gn';
     $group = new Group(0, $name);
     $this->db->_ExpectedInsertId = $newId;
     $this->repository->Add($group);
     $addGroupCommand = new AddGroupCommand($name);
     $this->assertTrue($this->db->ContainsCommand($addGroupCommand));
     $this->assertEquals($newId, $group->Id());
 }
Esempio n. 3
0
 private function MigrateGroups(Database $legacyDatabase, Database $currentDatabase)
 {
     $groupsMigrated = MigrationSession::GetLastGroupRow();
     Log::Debug('Start migrating groups. Starting at row %s', $groupsMigrated);
     $groupRepo = new GroupRepository();
     $getExisting = new AdHocCommand('select legacyid from groups');
     $reader = $currentDatabase->Query($getExisting);
     $knownIds = array();
     while ($row = $reader->GetRow()) {
         $knownIds[] = $row['legacyid'];
     }
     $getGroups = new AdHocCommand("select groupid, group_name from groups order by groupid limit {$groupsMigrated}, 500");
     $reader = $legacyDatabase->Query($getGroups);
     while ($row = $reader->GetRow()) {
         if (in_array($row['groupid'], $knownIds)) {
             continue;
         }
         $newId = $groupRepo->Add(new Group(null, $row['group_name']));
         $currentDatabase->Execute(new AdHocCommand("update groups set legacyid = \"{$row['groupid']}\" where group_id = {$newId}"));
         $groupsMigrated++;
         MigrationSession::SetLastGroupRow($groupsMigrated);
     }
     Log::Debug('Done migrating groups (%s groups)', $groupsMigrated);
     $getLegacyCount = new AdHocCommand('select count(*) as count from groups');
     $getMigratedCount = new AdHocCommand('select count(*) as count from groups where legacyid is not null');
     $progressCounts = $this->GetProgressCounts($getLegacyCount, $getMigratedCount);
     $this->page->SetProgress($progressCounts);
     $this->page->SetGroupsMigrated($progressCounts->MigratedCount);
     MigrationSession::SetLastGroupRow($progressCounts->MigratedCount);
 }