本文整理汇总了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();
示例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());
}