public function testCanDelete()
 {
     $accessoryId = 100;
     $command = new DeleteAccessoryCommand($accessoryId);
     $this->repository->Delete($accessoryId);
     $this->assertEquals($command, $this->db->_LastCommand);
 }
示例#2
0
 private function MigrateAccessories(Database $legacyDatabase, Database $currentDatabase)
 {
     $accessoriesMigrated = MigrationSession::GetLastAccessoryRow();
     Log::Debug('Start migrating accessories. Starting at row %s', $accessoriesMigrated);
     $accessoryRepo = new AccessoryRepository();
     $getExisting = new AdHocCommand('select legacyid from accessories');
     $reader = $currentDatabase->Query($getExisting);
     $knownIds = array();
     while ($row = $reader->GetRow()) {
         $knownIds[] = $row['legacyid'];
     }
     $getAccessories = new AdHocCommand("select resourceid, name, number_available from additional_resources\n\t\t order by resourceid limit {$accessoriesMigrated}, 500");
     $reader = $legacyDatabase->Query($getAccessories);
     while ($row = $reader->GetRow()) {
         if (in_array($row['resourceid'], $knownIds)) {
             continue;
         }
         $newId = $accessoryRepo->Add(new Accessory(null, $row['name'], $row['number_available']));
         $currentDatabase->Execute(new AdHocCommand("update accessories set legacyid = \"{$row['resourceid']}\" where accessory_id = {$newId}"));
         $accessoriesMigrated++;
         MigrationSession::SetLastAccessoryRow($accessoriesMigrated);
     }
     Log::Debug('Done migrating accessories (%s accessories)', $accessoriesMigrated);
     $getLegacyCount = new AdHocCommand('select count(*) as count from additional_resources');
     $getMigratedCount = new AdHocCommand('select count(*) as count from accessories where legacyid is not null');
     $progressCounts = $this->GetProgressCounts($getLegacyCount, $getMigratedCount);
     $this->page->SetProgress($progressCounts);
     $this->page->SetAccessoriesMigrated($progressCounts->MigratedCount);
     MigrationSession::SetLastAccessoryRow($progressCounts->MigratedCount);
 }
示例#3
0
    $userId = $userRepo->Add($user);
    $users[] = $user;
}
echo "Loaded {$numberOfUsers} users<br/>";
// RESOURCES
$db->Execute(new AdHocCommand("delete from resources where name like 'load%'"));
$resourceRepo = new ResourceRepository();
for ($i = 0; $i < $numberOfResources; $i++) {
    $resource = BookableResource::CreateNew("load{$i}", 1);
    $resourceId = $resourceRepo->Add($resource);
    $resources[] = $resource;
}
echo "Loaded {$numberOfResources} resources<br/>";
// ACCESSORIES
$db->Execute(new AdHocCommand("delete from accessories where accessory_name like 'load%'"));
$accessoryRepo = new AccessoryRepository();
for ($i = 0; $i < $numberOfAccessories; $i++) {
    $accessory = new Accessory(0, "Load {$i}", 10);
    $id = $accessoryRepo->Add($accessory);
}
echo "Loaded {$numberOfAccessories} accessories<br/>";
// RESERVATIONS
$db->Execute(new AdHocCommand("delete from reservation_series where title like 'load%'"));
$scheduleRepo = new ScheduleRepository();
$layout = $scheduleRepo->GetLayout(1, new ScheduleLayoutFactory('America/Chicago'));
$reservationRepo = new ReservationRepository();
$bookedBy = new UserSession(1);
$bookedBy->Timezone = 'America/Chicago';
$currentDate = Date::Now();
$i = 0;
while ($i < $numberOfReservations) {