本文整理汇总了PHP中UserTestHelper::createBasicUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserTestHelper::createBasicUser方法的具体用法?PHP UserTestHelper::createBasicUser怎么用?PHP UserTestHelper::createBasicUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserTestHelper
的用法示例。
在下文中一共展示了UserTestHelper::createBasicUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateAndGetTaskById
/**
* @depends testCreateTaskWithZerosStampAndEditAgain
*/
public function testCreateAndGetTaskById()
{
Yii::app()->user->userModel = User::getByUsername('super');
$accounts = Account::getByName('anAccount');
$user = UserTestHelper::createBasicUser('Billy');
$dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
$task = new Task();
$task->name = 'MyTask';
$task->owner = $user;
$task->requestedByUser = $user;
$task->dueDateTime = $dueStamp;
$task->status = Task::STATUS_COMPLETED;
$task->description = 'my test description';
$taskCheckListItem = new TaskCheckListItem();
$taskCheckListItem->name = 'Test Check List Item';
$task->checkListItems->add($taskCheckListItem);
$task->activityItems->add($accounts[0]);
$this->assertTrue($task->save());
$id = $task->id;
unset($task);
$task = Task::getById($id);
$this->assertEquals('MyTask', $task->name);
$this->assertEquals($dueStamp, $task->dueDateTime);
$this->assertNotNull($task->completedDateTime);
$this->assertEquals('my test description', $task->description);
$this->assertEquals($user, $task->owner);
$this->assertEquals($user, $task->requestedByUser);
$this->assertEquals(1, $task->activityItems->count());
$this->assertEquals($accounts[0], $task->activityItems->offsetGet(0));
$this->assertEquals($taskCheckListItem, $task->checkListItems->offsetGet(0));
foreach ($task->activityItems as $existingItem) {
$castedDownModel = $existingItem->castDown(array('Account'));
//this should not fail
}
}
示例2: testCreateAndGetMeetingById
public function testCreateAndGetMeetingById()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$accounts = Account::getByName('anAccount');
$contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $accounts[0]);
$contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact2', $super, $accounts[0]);
$contact3 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact3', $super, $accounts[0]);
$user = UserTestHelper::createBasicUser('Billy');
$startStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
$endStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 11000);
$meeting = new Meeting();
$meeting->name = 'MyMeeting';
$meeting->owner = $user;
$meeting->location = 'my location';
$meeting->category->value = 'Call';
$meeting->startDateTime = $startStamp;
$meeting->endDateTime = $endStamp;
$meeting->description = 'my test description';
$meeting->activityItems->add($accounts[0]);
$meeting->activityItems->add($contact1);
$meeting->activityItems->add($contact2);
$meeting->activityItems->add($contact3);
$this->assertTrue($meeting->save());
$id = $meeting->id;
unset($meeting);
$meeting = Meeting::getById($id);
$this->assertEquals('MyMeeting', $meeting->name);
$this->assertEquals($startStamp, $meeting->startDateTime);
$this->assertEquals($endStamp, $meeting->endDateTime);
$this->assertEquals('my test description', $meeting->description);
$this->assertEquals($user, $meeting->owner);
$this->assertEquals(4, $meeting->activityItems->count());
$this->assertEquals($accounts[0], $meeting->activityItems->offsetGet(0));
}
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
UserTestHelper::createBasicUser('billy');
UserTestHelper::createBasicUser('sally');
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
self::$emailHelperSendEmailThroughTransport = Yii::app()->emailHelper->sendEmailThroughTransport;
static::$userpsg = UserTestHelper::createBasicUser('userpsg');
static::$usercstmsmtp = UserTestHelper::createBasicUser('usercstmsmtp');
static::$basicuser = UserTestHelper::createBasicUser('basicuser');
static::$bothSGandCstmUser = UserTestHelper::createBasicUser('bothSGandCstmUser');
$someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
$group = Group::getByName('Super Administrators');
$group->users->add($someoneSuper);
$saved = $group->save();
assert($saved);
// Not Coding Standard
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
if (EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$usercstmsmtp);
EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$bothSGandCstmUser);
}
SendGrid::register_autoloader();
Smtpapi::register_autoloader();
if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
SendGridTestHelper::createSendGridEmailAccount(static::$userpsg);
SendGridTestHelper::createSendGridEmailAccount(static::$bothSGandCstmUser);
Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
Yii::app()->sendGridEmailHelper->setApiSettings();
Yii::app()->sendGridEmailHelper->init();
}
// Delete item from jobQueue, that is created when new user is created
Yii::app()->jobQueue->deleteAll();
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
UserTestHelper::createBasicUser('billy');
UserTestHelper::createBasicUser('jane');
$someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
$group = Group::getByName('Super Administrators');
$group->users->add($someoneSuper);
$saved = $group->save();
assert($saved);
// Not Coding Standard
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
SendGrid::register_autoloader();
Smtpapi::register_autoloader();
if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
Yii::app()->sendGridEmailHelper->setApiSettings();
Yii::app()->sendGridEmailHelper->init();
static::$testEmailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
}
// Delete item from jobQueue, that is created when new user is created
Yii::app()->jobQueue->deleteAll();
}
示例6: testCreateAndGetSocialItemById
public function testCreateAndGetSocialItemById()
{
$super = User::getByUsername('super');
$fileModel = ZurmoTestHelper::createFileModel();
$accounts = Account::getByName('anAccount');
$steven = UserTestHelper::createBasicUser('steven');
$note = NoteTestHelper::createNoteWithOwnerAndRelatedAccount('aNote', $super, $accounts[0]);
$socialItem = new SocialItem();
$socialItem->owner = $super;
$socialItem->description = 'My test description';
$socialItem->note = $note;
$socialItem->files->add($fileModel);
$socialItem->toUser = $steven;
$saved = $socialItem->save();
$this->assertTrue($saved);
$id = $socialItem->id;
$socialItem->forget();
unset($socialItem);
$socialItem = SocialItem::getById($id);
$this->assertEquals($super, $socialItem->owner);
$this->assertEquals('My test description', $socialItem->description);
$this->assertEquals($super, $socialItem->createdByUser);
$this->assertEquals($note, $socialItem->note);
$this->assertEquals(1, $socialItem->files->count());
$this->assertEquals($fileModel, $socialItem->files->offsetGet(0));
$this->assertEquals($steven, $socialItem->toUser);
}
示例7: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$user = UserTestHelper::createBasicUser('steve');
$user->primaryEmail->emailAddress = 'steve@example.com';
$user->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
assert($user->save());
// Not Coding Standard
$contact1 = ContactTestHelper::createContactByNameForOwner('peter', $user);
$contact1->primaryEmail->emailAddress = 'peter@example.com';
$contact1->secondaryEmail->emailAddress = 'peter2@example.com';
assert($contact1->save());
// Not Coding Standard
$contactsOrLeads = ContactSearch::getContactsByAnyEmailAddress('peter@example.com', null, null);
$contact2 = ContactTestHelper::createContactByNameForOwner('jim', $user);
$contact2->primaryEmail->emailAddress = 'jim@example.com';
assert($contact2->save());
// Not Coding Standard
$nonExistingUserEmail = 'jill@example.com';
self::$user = $user;
self::$contact1 = $contact1;
self::$contact2 = $contact2;
self::$nonExistingUserEmail = $nonExistingUserEmail;
Yii::app()->imap->imapUsername = 'dropbox@example.com';
}
示例8: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = User::getByUsername('super');
$bobby = UserTestHelper::createBasicUser('bobby');
$sarah = UserTestHelper::createBasicUser('sarah');
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
$currency = Currency::makeBaseCurrency();
assert($currency->code == 'USD');
// Not Coding Standard
self::$baseCurrencyId = $currency->id;
$currency = new Currency();
$currency->code = 'EUR';
$currency->rateToBase = 2;
assert($currency->save());
// Not Coding Standard
self::$eurCurrencyId = $currency->id;
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestRadioDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestMultiDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestTagCloud');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$loaded = ContactsModule::loadStartingData();
assert($loaded);
// Not Coding Standard
$contactStates = ContactState::getByName('New');
self::$newState = $contactStates[0];
$contactStates = ContactState::getByName('In progress');
self::$inProgressState = $contactStates[0];
self::$groupTest = new Group();
self::$groupTest->name = 'test';
$saved = self::$groupTest->save();
assert($saved);
// Not Coding Standard
$group = Group::getByName(Group::EVERYONE_GROUP_NAME);
$saved = $group->save();
assert($saved);
// Not Coding Standard
}
示例9: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
AllPermissionsOptimizationUtil::rebuild();
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$everyoneGroup->save();
$super = User::getByUsername('super');
//Steven have access to missions module
$steven = UserTestHelper::createBasicUser('steven');
$steven->setRight('MissionsModule', MissionsModule::RIGHT_ACCESS_MISSIONS);
$steven->save();
//Jack dont have acess to missions module
$jack = UserTestHelper::createBasicUser('jack');
$mission = new Mission();
$mission->owner = $super;
$mission->takenByUser = $steven;
$mission->description = 'My test description';
$mission->reward = 'My test reward';
$mission->status = Mission::STATUS_AVAILABLE;
$mission->addPermissions($everyoneGroup, Permission::READ_WRITE);
assert($mission->save());
// Not Coding Standard
AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, $everyoneGroup);
}
示例10: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
SecurityTestHelper::createUsers();
// set up data owned by super
Yii::app()->user->userModel = User::getByUsername('super');
$account1 = AccountTestHelper::createAccountByNameForOwner('account1', Yii::app()->user->userModel);
$contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('contact1', Yii::app()->user->userModel, $account1);
$contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('contact2', Yii::app()->user->userModel, $account1);
$contact3 = ContactTestHelper::createContactWithAccountByNameForOwner('contact3', Yii::app()->user->userModel, $account1);
$marketingList1 = MarketingListTestHelper::createMarketingListByName('MarketingList1');
MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact1);
MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList1, $contact2);
$member1 = MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact3);
static::$superUserMarketingListId = $marketingList1->id;
static::$superUserMemberId = $member1->id;
// set up data owned by nobody
Yii::app()->user->userModel = UserTestHelper::createBasicUser('nobody');
$account2 = AccountTestHelper::createAccountByNameForOwner('account2', Yii::app()->user->userModel);
$contact4 = ContactTestHelper::createContactWithAccountByNameForOwner('contact4', Yii::app()->user->userModel, $account2);
$contact5 = ContactTestHelper::createContactWithAccountByNameForOwner('contact5', Yii::app()->user->userModel, $account2);
$contact6 = ContactTestHelper::createContactWithAccountByNameForOwner('contact6', Yii::app()->user->userModel, $account2);
$marketingList2 = MarketingListTestHelper::createMarketingListByName('MarketingList2');
MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList2, $contact4);
$member2 = MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList2, $contact5);
MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList2, $contact6);
static::$regularUserMarketingListId = $marketingList2->id;
static::$regularUserMemberId = $member2->id;
ReadPermissionsOptimizationUtil::rebuild();
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:31,代码来源:MarketingListDefaultPortletControllerRegularUserWalkthroughTest.php
示例11: testRebuildDatabaseWithNonSuperAdminUser
public function testRebuildDatabaseWithNonSuperAdminUser()
{
$steven = UserTestHelper::createBasicUser('Steven');
Yii::app()->user->userModel = $steven;
$item = NamedSecurableItem::getByName('AccountsModule');
$this->assertEquals(Permission::NONE, $item->getEffectivePermissions($steven));
$accounts = Account::getAll();
$users = User::getAll();
$this->assertEquals(0, count($accounts));
$this->assertEquals(2, count($users));
$adapter = new ModelAttributesAdapter(new Account());
$adapter->resolveDatabaseSchemaForModel('Account');
//Confirm the counts of data are still correct
$accounts = Account::getAll();
$users = User::getAll();
$this->assertEquals(0, count($accounts));
$this->assertEquals(2, count($users));
//Explicitly deny read, write, and deny
Yii::app()->user->userModel = User::getByUsername('super');
$item->addPermissions($steven, Permission::READ_WRITE_DELETE, Permission::DENY);
$this->assertTrue($item->save());
//Make sure steven has explicit deny
$item = NamedSecurableItem::getByName('AccountsModule');
$this->assertEquals(Permission::NONE, $item->getEffectivePermissions($steven));
Yii::app()->user->userModel = $steven;
$adapter = new ModelAttributesAdapter(new Account());
$adapter->resolveDatabaseSchemaForModel('Account');
//Confirm the counts of data are still correct
$accounts = Account::getAll();
$users = User::getAll();
$this->assertEquals(0, count($accounts));
$this->assertEquals(2, count($users));
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$billy = UserTestHelper::createBasicUser('billy');
EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
}
示例13: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $super;
$jim = UserTestHelper::createBasicUser('jim');
$values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
$customFieldData = CustomFieldData::getByName('ImportTestDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Multi 1', 'Multi 2', 'Multi 3');
$customFieldData = CustomFieldData::getByName('ImportTestMultiDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Cloud 1', 'Cloud 2', 'Cloud 3');
$customFieldData = CustomFieldData::getByName('ImportTestTagCloud');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
//Ensure the external system id column is present.
$userTableName = User::getTableName();
ExternalSystemIdUtil::addExternalIdColumnIfMissing($userTableName);
ExternalSystemIdUtil::updateByModel($super, 'A');
ExternalSystemIdUtil::updateByModel($jim, 'B');
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem2::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem3::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem4::getTableName());
}
示例14: testCreateAndGetGamePointById
public function testCreateAndGetGamePointById()
{
$user = UserTestHelper::createBasicUser('Steven');
$gamePoint = new GamePoint();
$gamePoint->person = $user;
$gamePoint->type = 'SomeType';
$gamePoint->addValue(10);
$this->assertTrue($gamePoint->save());
$id = $gamePoint->id;
unset($gamePoint);
$gamePoint = GamePoint::getById($id);
$this->assertEquals('SomeType', $gamePoint->type);
$this->assertEquals(10, $gamePoint->value);
$this->assertEquals($user, $gamePoint->person);
$this->assertEquals(1, $gamePoint->transactions->count());
$gamePoint->addValue(50, false);
$this->assertTrue($gamePoint->save());
GamePointTransaction::addTransactionResolvedForOptimization($gamePoint, 50);
$this->assertEquals(60, $gamePoint->value);
$gamePoint::forgetAll();
$gamePoint = GamePoint::getById($id);
$this->assertEquals(60, $gamePoint->value);
$this->assertEquals(2, $gamePoint->transactions->count());
$this->assertEquals(10, $gamePoint->transactions[0]->value);
$this->assertEquals(50, $gamePoint->transactions[1]->value);
}
示例15: testKanbanItemSave
public function testKanbanItemSave()
{
$accounts = Account::getByName('anAccount');
$user = UserTestHelper::createBasicUser('Billy');
$task = new Task();
$task->name = 'MyTask';
$task->owner = $user;
$task->requestedByUser = $user;
$task->description = 'my test description';
$taskCheckListItem = new TaskCheckListItem();
$taskCheckListItem->name = 'Test Check List Item';
$task->checkListItems->add($taskCheckListItem);
$task->activityItems->add($accounts[0]);
$task->status = Task::STATUS_IN_PROGRESS;
$this->assertTrue($task->save());
$this->assertEquals(1, KanbanItem::getCount());
$id = $task->id;
unset($task);
$task = Task::getById($id);
//KanbanItem is created after saving Task
$kanbanItems = KanbanItem::getAll();
$this->assertCount(1, $kanbanItems);
$kanbanItem = $kanbanItems[0];
$this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem->type);
}