當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserRepository::Add方法代碼示例

本文整理匯總了PHP中UserRepository::Add方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserRepository::Add方法的具體用法?PHP UserRepository::Add怎麽用?PHP UserRepository::Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserRepository的用法示例。


在下文中一共展示了UserRepository::Add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: StopWatch

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();
開發者ID:utn-frm-si,項目名稱:booked,代碼行數:31,代碼來源:load_test.php

示例2: testAddsUser

 public function testAddsUser()
 {
     $expectedId = 999;
     $firstName = 'f';
     $lastName = 'l';
     $emailAddress = 'e';
     $userName = 'u';
     $language = 'la';
     $timezone = 't';
     $password = 'p';
     $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());
 }
開發者ID:utn-frm-si,項目名稱:booked,代碼行數:38,代碼來源:UserRepositoryTests.php


注:本文中的UserRepository::Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。