本文整理汇总了PHP中UserTestHelper类的典型用法代码示例。如果您正苦于以下问题:PHP UserTestHelper类的具体用法?PHP UserTestHelper怎么用?PHP UserTestHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserTestHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateAndGetMissionById
public function testCreateAndGetMissionById()
{
$super = User::getByUsername('super');
$fileModel = ZurmoTestHelper::createFileModel();
$steven = UserTestHelper::createBasicUserWithEmailAddress('steven');
$steven->setRight('MissionsModule', MissionsModule::RIGHT_ACCESS_MISSIONS);
$steven->save();
$dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
$mission = new Mission();
$mission->owner = $super;
$mission->takenByUser = $steven;
$mission->dueDateTime = $dueStamp;
$mission->description = 'My test description';
$mission->reward = 'My test reward';
$mission->status = Mission::STATUS_AVAILABLE;
$mission->files->add($fileModel);
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$mission->addPermissions($everyoneGroup, Permission::READ_WRITE);
$this->assertTrue($mission->save());
AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, $everyoneGroup);
$id = $mission->id;
$mission->forget();
unset($mission);
$mission = Mission::getById($id);
$this->assertEquals('My test description', $mission->description);
$this->assertEquals('My test reward', $mission->reward);
$this->assertEquals(Mission::STATUS_AVAILABLE, $mission->status);
$this->assertEquals($super, $mission->owner);
$this->assertEquals($steven, $mission->takenByUser);
$this->assertEquals(1, $mission->files->count());
$this->assertEquals($fileModel, $mission->files->offsetGet(0));
$this->assertEquals($dueStamp, $mission->dueDateTime);
$this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super));
$this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
ContactsModule::loadStartingData();
SecurityTestHelper::createSuperAdmin();
$sally = UserTestHelper::createBasicUser('sally');
$sally->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
$sally->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
$sally->setRight('MeetingsModule', MeetingsModule::RIGHT_ACCESS_MEETINGS);
$sally->setRight('OpportunitiesModule', OpportunitiesModule::RIGHT_ACCESS_OPPORTUNITIES);
$sally->setRight('ReportsTestModule', ReportsTestModule::RIGHT_ACCESS_REPORTS_TESTS);
if (!$sally->save()) {
throw new FailedToSaveModelException();
}
$sarah = UserTestHelper::createBasicUser('sarah');
$sarah->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
$sarah->setRight('LeadsModule', LeadsModule::RIGHT_ACCESS_LEADS);
$sarah->setRight('MeetingsModule', MeetingsModule::RIGHT_ACCESS_MEETINGS);
$sarah->setRight('OpportunitiesModule', OpportunitiesModule::RIGHT_ACCESS_OPPORTUNITIES);
$sarah->setRight('ReportsTestModule', ReportsTestModule::RIGHT_ACCESS_REPORTS_TESTS);
if (!$sarah->save()) {
throw new FailedToSaveModelException();
}
$nobody = UserTestHelper::createBasicUser('nobody');
if (!$nobody->save()) {
throw new FailedToSaveModelException();
}
}
示例3: testPasswordExpiresPolicyRules
public function testPasswordExpiresPolicyRules()
{
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$everyoneGroup->save();
$user = UserTestHelper::createBasicUser('Bobby');
$id = $user->id;
unset($user);
$user = User::getById($id);
$adapter = new UserGroupMembershipToViewAdapter($user);
$viewData = $adapter->getViewData();
$compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false));
$this->assertEquals($compareData, $viewData);
$a = new Group();
$a->name = 'AAA';
$this->assertTrue($a->save());
$a->users->add($user);
$this->assertTrue($a->save());
$user->forget();
$groupId = $a->id;
$a->forget();
unset($a);
$user = User::getById($id);
$adapter = new UserGroupMembershipToViewAdapter($user);
$viewData = $adapter->getViewData();
$compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false), $groupId => array('displayName' => 'AAA', 'canRemoveFrom' => true));
$this->assertEquals($compareData, $viewData);
$user->forget();
unset($user);
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = User::getByUsername('super');
$billy = UserTestHelper::createBasicUser('billy');
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = User::getByUsername('super');
$super = User::getByUsername('super');
$super->primaryEmail = new Email();
$super->primaryEmail->emailAddress = 'super@zurmo.com';
assert($super->save());
// Not Coding Standard
$bobby = UserTestHelper::createBasicUserWithEmailAddress('bobby');
$sarah = UserTestHelper::createBasicUserWithEmailAddress('sarah');
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
$emailTemplate = new EmailTemplate();
$emailTemplate->modelClassName = 'WorkflowModelTestItem';
$emailTemplate->type = 1;
$emailTemplate->name = 'some template';
$emailTemplate->subject = 'some subject [[LAST^NAME]]';
$emailTemplate->htmlContent = 'html content [[STRING]]';
$emailTemplate->textContent = 'text content [[PHONE]]';
$saved = $emailTemplate->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
self::$emailTemplate = $emailTemplate;
}
示例6: 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
}
示例7: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
ContactsModule::loadStartingData();
$bobbyBoss = UserTestHelper::createBasicUserWithEmailAddress('bobbyBoss');
$sarahBoss = UserTestHelper::createBasicUserWithEmailAddress('sarahBoss');
$superBoss = UserTestHelper::createBasicUserWithEmailAddress('superBoss');
$super = User::getByUsername('super');
$super->primaryEmail = new Email();
$super->primaryEmail->emailAddress = 'super@zurmo.com';
$super->manager = $superBoss;
assert($super->save());
// Not Coding Standard
$bobby = UserTestHelper::createBasicUserWithEmailAddress('bobby');
$bobby->manager = $bobbyBoss;
assert($bobby->save());
// Not Coding Standard
$sarah = UserTestHelper::createBasicUserWithEmailAddress('sarah');
$sarah->manager = $sarahBoss;
assert($sarah->save());
// Not Coding Standard
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
self::$superBossUserId = $superBoss->id;
self::$bobbyBossUserId = $bobbyBoss->id;
self::$sarahBossUserId = $sarahBoss->id;
}
示例8: 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);
}
示例9: 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
示例10: 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);
$completedStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 9000);
$task = new Task();
$task->name = 'MyTask';
$task->owner = $user;
$task->dueDateTime = $dueStamp;
$task->completedDateTime = $completedStamp;
$task->description = 'my test description';
$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->assertEquals($completedStamp, $task->completedDateTime);
$this->assertEquals('my test description', $task->description);
$this->assertEquals($user, $task->owner);
$this->assertEquals(1, $task->activityItems->count());
$this->assertEquals($accounts[0], $task->activityItems->offsetGet(0));
foreach ($task->activityItems as $existingItem) {
$castedDownModel = $existingItem->castDown(array('Account'));
//this should not fail
}
}
示例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: testCreateAddAndSaveAndRemoveByIndexRelatedModels
public function testCreateAddAndSaveAndRemoveByIndexRelatedModels()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = UserTestHelper::createBasicUser('Billy');
$account = new Account();
$account->owner = $user;
$account->name = 'Wibble Corp';
$this->assertTrue($account->save());
for ($i = 0; $i < self::CONTACTS; $i++) {
$contact = ContactTestHelper::createContactByNameForOwner('sampleContact' . $i, Yii::app()->user->userModel);
$account->contacts->add($contact);
}
$this->assertTrue($account->save());
$contact = $account->contacts[0];
$this->assertFalse($account->isModified());
$this->assertFalse($contact->isModified());
$this->assertTrue($account->save());
$this->assertFalse($account->isModified());
$this->assertFalse($contact->isModified());
$accountId = $account->id;
unset($account);
$account = Account::getById($accountId);
$this->assertEquals('Wibble Corp', $account->name);
$this->assertEquals(self::CONTACTS, $account->contacts->count());
$this->assertEquals("{$account->contacts->count()} records.", strval($account->contacts));
$contact = $account->contacts[0];
$description = $contact->description;
$contact->description = "this is a contact";
$this->assertTrue($account->isModified());
$this->assertTrue($contact->isModified());
$this->assertTrue($account->save());
$this->assertFalse($account->isModified());
$this->assertFalse($contact->isModified());
}