Пример #1
0
echo "<h1>Booked Scheduler Data Load</h1>";
$stopWatch = new StopWatch();
$stopWatch->Start();
$numberOfResources = 10;
$numberOfUsers = 1000;
$numberOfReservations = 5000;
$numberOfAccessories = 20;
$users = array();
$resources = array();
$db = ServiceLocator::GetDatabase();
// USERS
$db->Execute(new AdHocCommand("delete from users where fname ='load' and lname = 'test'"));
$userRepo = new UserRepository();
for ($i = 0; $i < $numberOfUsers; $i++) {
    $user = User::Create("load{$i}", "test{$i}", "email {$i}", "username {$i}", "en_us", "America/Chicago", "7b6aec38ff9b7650d64d0374194307bdde711425", "3b3dbb9b");
    $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();
Пример #2
0
 public function testAddsUser()
 {
     $expectedId = 999;
     $firstName = 'f';
     $lastName = 'l';
     $emailAddress = 'e';
     $userName = '******';
     $language = 'la';
     $timezone = 't';
     $password = '******';
     $passwordSalt = 'ps';
     $phone = 'ph';
     $organization = 'o';
     $position = 'po';
     $scheduleId = 123232;
     $attr1 = new AttributeValue(3, 'value');
     $attr2 = new AttributeValue(4, 'value');
     $user = User::Create($firstName, $lastName, $emailAddress, $userName, $language, $timezone, $password, $passwordSalt);
     $user->ChangeAttributes($phone, $organization, $position);
     $user->ChangeCustomAttributes(array($attr1, $attr2));
     $user->ChangeEmailPreference(new ReservationApprovedEvent(), true);
     $user->EnablePublicProfile();
     $user->ChangeDefaultSchedule($scheduleId);
     $publicId = $user->GetPublicId();
     $this->db->_ExpectedInsertId = $expectedId;
     $repo = new UserRepository();
     $newId = $repo->Add($user);
     $command = new RegisterUserCommand($userName, $emailAddress, $firstName, $lastName, $password, $passwordSalt, $timezone, $language, Pages::DEFAULT_HOMEPAGE_ID, $phone, $organization, $position, AccountStatus::ACTIVE, $publicId, $scheduleId);
     $addAttr1Command = new AddAttributeValueCommand($attr1->AttributeId, $attr1->Value, $expectedId, CustomAttributeCategory::USER);
     $addAttr2Command = new AddAttributeValueCommand($attr2->AttributeId, $attr2->Value, $expectedId, CustomAttributeCategory::USER);
     $addEmailPreferenceCommand = new AddEmailPreferenceCommand($expectedId, EventCategory::Reservation, ReservationEvent::Approved);
     $this->assertTrue($this->db->ContainsCommand($command));
     $this->assertTrue($this->db->ContainsCommand($addAttr1Command));
     $this->assertTrue($this->db->ContainsCommand($addAttr2Command));
     $this->assertTrue($this->db->ContainsCommand($addEmailPreferenceCommand));
     $this->assertEquals($expectedId, $newId);
     $this->assertEquals($expectedId, $user->Id());
 }