本文整理汇总了PHP中Account::forget方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::forget方法的具体用法?PHP Account::forget怎么用?PHP Account::forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account::forget方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPopulateCustomAttributes
/**
* @depends testCreateDropDownWithMixedCaseAttributeName
*/
public function testPopulateCustomAttributes()
{
$currencies = Currency::getAll();
$account = new Account();
$account->name = 'my test account';
$account->owner = Yii::app()->user->userModel;
$account->testCheckBox2Cstm = 0;
$account->testCurrency2Cstm->value = 728.89;
$account->testCurrency2Cstm->currency = $currencies[0];
$account->testDate2Cstm = '2008-09-03';
$account->testDate3Cstm = '2008-09-02';
$account->testDateTime2Cstm = '2008-09-02 03:03:03';
$account->testDateTime3Cstm = '2008-09-01 03:03:03';
$account->testDecimal2Cstm = 45.67;
$account->testDecimal3Cstm = 31.05;
$account->testAirPlaneCstm->value = 'A380';
//Dive Bomber
$account->testInteger2Cstm = 56;
$account->testInteger3Cstm = 21;
$account->testPhone2Cstm = '345345234';
$account->testPhone3Cstm = '345345221';
$account->testAirPlanePartsCstm->value = 'Seat';
// Wheel
$account->testText2Cstm = 'some test stuff';
$account->testText3Cstm = 'some test stuff 3';
$account->testTextArea2Cstm = 'some test text area stuff';
$account->testTextArea3Cstm = 'some test text area stuff 3';
$account->testUrl2Cstm = 'https://www.zurmo.com';
$account->testUrl3Cstm = 'www.zurmo.org';
$account->playMyFavoriteSongCstm->value = 'song2';
// song 3
$account->testCountryCstm->value = 'bbbb';
$account->testStateCstm->value = 'bbb2';
$account->testCityCstm->value = 'bc2';
$account->testEducationCstm->value = 'cccc';
$account->testStreamCstm->value = 'ccc3';
//Set value to Multiselect list.
$customHobbyValue1 = new CustomFieldValue();
$customHobbyValue1->value = 'Reading';
$account->testHobbies1Cstm->values->add($customHobbyValue1);
$customHobbyValue2 = new CustomFieldValue();
$customHobbyValue2->value = 'Singing';
$account->testHobbies2Cstm->values->add($customHobbyValue2);
//Set value to Tagcloud.
$customLanguageValue1 = new CustomFieldValue();
$customLanguageValue1->value = 'English';
$account->testLanguages1Cstm->values->add($customLanguageValue1);
$customLanguageValue2 = new CustomFieldValue();
$customLanguageValue2->value = 'Spanish';
$account->testLanguages2Cstm->values->add($customLanguageValue2);
unset($customHobbyValue1);
unset($customHobbyValue2);
unset($customLanguageValue1);
unset($customLanguageValue2);
$saved = $account->save();
$this->assertTrue($saved);
$accountId = $account->id;
$account->forget();
unset($account);
$account = Account::getById($accountId);
$this->assertEquals(0, $account->testCheckBox2Cstm);
$this->assertEquals(false, (bool) $account->testCheckBox2Cstm);
$this->assertEquals(728.89, $account->testCurrency2Cstm->value);
$this->assertEquals(1, $account->testCurrency2Cstm->rateToBase);
$this->assertEquals('2008-09-03', $account->testDate2Cstm);
$this->assertEquals('2008-09-02 03:03:03', $account->testDateTime2Cstm);
$this->assertEquals(45.67, $account->testDecimal2Cstm);
$this->assertEquals('A380', $account->testAirPlaneCstm->value);
$this->assertEquals(56, $account->testInteger2Cstm);
$this->assertEquals(345345234, $account->testPhone2Cstm);
$this->assertEquals('Seat', $account->testAirPlanePartsCstm->value);
$this->assertEquals('some test stuff', $account->testText2Cstm);
$this->assertEquals('some test text area stuff', $account->testTextArea2Cstm);
$this->assertEquals('https://www.zurmo.com', $account->testUrl2Cstm);
$this->assertEquals('http://www.zurmo.org', $account->testUrl3Cstm);
$this->assertEquals('song2', $account->playMyFavoriteSongCstm->value);
$this->assertContains('Writing', $account->testHobbies1Cstm->values);
$this->assertContains('Reading', $account->testHobbies1Cstm->values);
$this->assertContains('Singing', $account->testHobbies2Cstm->values);
$this->assertContains('English', $account->testLanguages1Cstm->values);
$this->assertContains('French', $account->testLanguages1Cstm->values);
$this->assertContains('Spanish', $account->testLanguages2Cstm->values);
$this->assertEquals('bbbb', $account->testCountryCstm->value);
$this->assertEquals('bbb2', $account->testStateCstm->value);
$this->assertEquals('bc2', $account->testCityCstm->value);
$this->assertEquals('cccc', $account->testEducationCstm->value);
$this->assertEquals('ccc3', $account->testStreamCstm->value);
$metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('testCalculatedValue', 'Account');
$testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $account);
$this->assertEquals('$774.56', $testCalculatedValue);
unset($testCalculatedValue);
$account->forget();
unset($account);
$account = Account::getById($accountId);
//Switch values around to cover for any default value pollution on the assertions above.
$account->testCheckBox2Cstm = 1;
$account->testCurrency2Cstm->value = 728.92;
//.........这里部分代码省略.........
示例2: testValidatesWithoutOwnerWhenSpecifyingAttributesToValidate
/**
* @depends testCreateAndGetAccountById
*/
public function testValidatesWithoutOwnerWhenSpecifyingAttributesToValidate()
{
$user = User::getByUsername('steven');
$this->assertTrue($user->id > 0);
$account = new Account(false);
$_POST['MassEdit'] = array('employees' => '1');
$_POST['fake'] = array('employees' => 4);
PostUtil::sanitizePostForSavingMassEdit('fake');
$account->setAttributes($_POST['fake']);
$account->validate(array_keys($_POST['MassEdit']));
$this->assertEquals(array(), $account->getErrors());
$account->forget();
$account = new Account(false);
$_POST['MassEdit'] = array('owner' => '1');
$_POST['fake'] = array('owner' => array('id' => ''));
PostUtil::sanitizePostForSavingMassEdit('fake');
$account->setAttributes($_POST['fake']);
$account->validate(array_keys($_POST['MassEdit']));
//there should be an owner error since it is specified but blank
$this->assertNotEquals(array(), $account->getErrors());
$account->forget();
$account = new Account(false);
$_POST['MassEdit'] = array('employees' => '1', 'owner' => '2');
$_POST['fake'] = array('employees' => 4, 'owner' => array('id' => $user->id));
PostUtil::sanitizePostForSavingMassEdit('fake');
$account->setAttributes($_POST['fake']);
$account->validate(array_keys($_POST['MassEdit']));
$this->assertEquals(array(), $account->getErrors());
}
示例3: testABitOfEverythingAsAnExample
//.........这里部分代码省略.........
// regardless of what they have been granted.
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($adminDude));
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($adminDudes));
$this->assertEquals(Permission::ALL, $account->getEffectivePermissions($accountOwner));
$this->assertEquals(Permission::READ_WRITE, $account->getEffectivePermissions($salesDude1));
$this->assertEquals(Permission::READ_WRITE, $account->getEffectivePermissions($salesDude2));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($managementDudette));
$this->assertEquals(Permission::READ_WRITE, $account->getEffectivePermissions($salesDudes));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($managementDudes));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($supportDude));
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($everyone));
// We'll give Management Dudes back their permissions.
$account->removePermissions($managementDudes, Permission::ALL, Permission::DENY);
// And give management dudette change permissions.
$account->addPermissions($managementDudette, Permission::CHANGE_PERMISSIONS);
$account->save();
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($adminDude));
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($adminDudes));
$this->assertEquals(Permission::ALL, $account->getEffectivePermissions($accountOwner));
$this->assertEquals(Permission::READ_WRITE, $account->getEffectivePermissions($salesDude1));
$this->assertEquals(Permission::READ_WRITE, $account->getEffectivePermissions($salesDude2));
$this->assertEquals(Permission::READ | Permission::CHANGE_PERMISSIONS | Permission::CHANGE_OWNER, $account->getEffectivePermissions($managementDudette));
$this->assertEquals(Permission::READ_WRITE, $account->getEffectivePermissions($salesDudes));
$this->assertEquals(Permission::READ | Permission::CHANGE_OWNER, $account->getEffectivePermissions($managementDudes));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($supportDude));
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($everyone));
// Then we'll just nuke eveyone's permissions. If you use this it is for
// the kind of scenario where an admin wants to re-setup permissions from scratch
// so you'd put a Do You Really Want To Do This???? kind of message.
Permission::deleteAll();
// Removing all permissions is done directly on the database,
// so we need to forget our account and get it back again.
$accountId = $account->id;
$account->forget();
unset($account);
$account = Account::getById($accountId);
// Nobody else has permissions again.
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($adminDude));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($adminDudes));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($salesDude1));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($salesDude2));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($managementDudette));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($salesDudes));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($managementDudes));
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($supportDude));
// TODO
// - Permissions on modules.
// - Permissions on types.
// - Permissions on fields.
// All users have the right to login via the web, because the Everyone group was granted that right.
$this->assertEquals(Right::ALLOW, $adminDude->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $adminDudes->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $salesDude1->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $salesDude2->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $managementDudette->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $salesDudes->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $managementDudes->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $supportDude->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $everyone->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB));
$this->assertEquals(Right::ALLOW, $adminDude->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
$this->assertEquals(Right::ALLOW, $adminDudes->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
$this->assertEquals(Right::DENY, $salesDude1->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
$this->assertEquals(Right::DENY, $salesDude2->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
$this->assertEquals(Right::DENY, $managementDudette->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
$this->assertEquals(Right::DENY, $salesDudes->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
$this->assertEquals(Right::DENY, $managementDudes->getEffectiveRight('UsersModule', UsersModule::RIGHT_CHANGE_USER_PASSWORDS));
示例4: testMakeBySecurableItem
public function testMakeBySecurableItem()
{
Yii::app()->user->userModel = User::getByUsername('super');
$group2 = Group::getByName('Group2');
$group3 = Group::getByName('Group3');
$account = new Account();
$account->name = 'aTestAccount';
$account->owner = Yii::app()->user->userModel;
$this->assertTrue($account->save());
$account->addPermissions($group2, Permission::READ_WRITE);
$account->addPermissions($group3, Permission::READ);
$this->assertTrue($account->save());
$accountId = $account->id;
$account->forget();
unset($account);
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($accountId));
$this->assertTrue($explicitReadWriteModelPermissions instanceof ExplicitReadWriteModelPermissions);
$readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
$readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
$this->assertEquals(1, count($readWritePermitables));
$this->assertEquals(1, count($readOnlyPermitables));
$this->assertEquals($group3, $readOnlyPermitables[$group3->id]);
$this->assertEquals($group2, $readWritePermitables[$group2->id]);
}
示例5: testMultiSelectDropDownAttributeValuesAfterCreateAndEditPlacedForAccountsModule
/**
* @depends testSearchForMultiSelectDropDownAttributePlacedForAccountsModule
*/
public function testMultiSelectDropDownAttributeValuesAfterCreateAndEditPlacedForAccountsModule()
{
//Test that the multiple select attribute can query properly for search.
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Create an account to test searching multiple fields on for search.
$account = new Account();
$this->assertEquals(1, $account->testHobbiesCstm->values->count());
$account->testHobbiesCstm->values->removeAll();
$this->assertEquals(0, $account->testHobbiesCstm->values->count());
$account->name = 'MyTestAccount';
$account->owner = Yii::app()->user->userModel;
$customFieldValue1 = new CustomFieldValue();
$customFieldValue1->value = 'Reading';
$account->testHobbiesCstm->values->add($customFieldValue1);
$customFieldValue2 = new CustomFieldValue();
$customFieldValue2->value = 'Writing';
$account->testHobbiesCstm->values->add($customFieldValue2);
$this->assertTrue($account->save());
$accountId = $account->id;
$account->forget();
unset($account);
$account = Account::getById($accountId);
$this->assertEquals(2, $account->testHobbiesCstm->values->count());
$this->assertContains('Reading', $account->testHobbiesCstm->values);
$this->assertContains('Writing', $account->testHobbiesCstm->values);
$account->forget();
unset($account);
$account = Account::getById($accountId);
$customFieldValue3 = new CustomFieldValue();
$customFieldValue3->value = 'Writing';
$account->testHobbiesCstm->values->add($customFieldValue3);
$this->assertEquals(3, $account->testHobbiesCstm->values->count());
$this->assertContains('Reading', $account->testHobbiesCstm->values);
$this->assertContains('Writing', $account->testHobbiesCstm->values);
$this->assertNotContains('Surfing', $account->testHobbiesCstm->values);
$this->assertNotContains('Gardening', $account->testHobbiesCstm->values);
}
示例6: testItemReadOnlyChangeScenarioSoCanPopulate
/**
* @depends testItemReadOnlyFieldsModifiedUser
*/
public function testItemReadOnlyChangeScenarioSoCanPopulate()
{
Yii::app()->user->userModel = User::getByUsername('super');
$dbDateTime1 = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 200);
$dbDateTime2 = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 300);
$dbDateTime3 = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 400);
$jimmy = UserTestHelper::createBasicUser('Jimmy');
$user = User::getByUsername('billy');
$account = new Account();
$account->setScenario('importModel');
$account->createdByUser = $user;
$account->modifiedByUser = $user;
$account->createdDateTime = $dbDateTime1;
$account->modifiedDateTime = $dbDateTime2;
$account->owner = Yii::app()->user->userModel;
$account->name = 'someName';
$this->assertTrue($account->save());
$accountId = $account->id;
$account->forget();
$account = Account::getById($accountId);
$this->assertEquals($user, $account->createdByUser);
$this->assertEquals($user, $account->modifiedByUser);
$this->assertEquals($dbDateTime1, $account->createdDateTime);
$this->assertEquals($dbDateTime2, $account->modifiedDateTime);
$account->name = 'aNewName';
$this->assertTrue($account->save());
$account->forget();
//Now test that the attempt to change createdByUser and modifiedUser on an existing model will not work.
//even when there are read only override permissions set.
$account = Account::getById($accountId);
$this->assertEquals($user, $account->createdByUser);
$this->assertEquals(Yii::app()->user->userModel, $account->modifiedByUser);
$this->assertNotEquals($dbDateTime2, $account->modifiedDateTime);
$this->assertNotEquals($dbDateTime3, $account->modifiedDateTime);
}