本文整理汇总了PHP中sfGuardUser::setisValidated方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::setisValidated方法的具体用法?PHP sfGuardUser::setisValidated怎么用?PHP sfGuardUser::setisValidated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::setisValidated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBlockSaveForExistingAssignmentOnOtherUnreleasedEpisode
/**
* Only one sfGuardUser can sign up for one Episode with the same
* AuthorType for each Application period.
*/
public function testBlockSaveForExistingAssignmentOnOtherUnreleasedEpisode()
{
$subreddit = new Subreddit();
$subreddit->setName(rand(0, 10000));
$subreddit->setDomain(rand(0, 10000));
$subreddit->save();
$user = new sfGuardUser();
$user->setUsername(rand(0, 10000));
$user->setEmailAddress(rand(0, 10000));
$user->setisValidated(1);
$user->save();
$first = AuthorTypeTable::getInstance()->findOneByType('squid');
$episode = new Episode();
$episode->setReleaseDate(date('Y-m-d H:i:s', time() + 100000));
$episode->setSubreddit($subreddit);
$episode->save();
$deadline = new Deadline();
$deadline->setSubreddit($subreddit);
$deadline->setAuthorType($first);
$deadline->setSeconds(0);
$deadline->save();
// Establish conditions to trip up test.
$existing_episode = new Episode();
$existing_episode->setReleaseDate(date('Y-m-d H:i:s', time() + 100000));
$existing_episode->setSubreddit($subreddit);
$existing_episode->save();
$existing_assignment = new EpisodeAssignment();
$existing_assignment->setEpisode($existing_episode);
$existing_assignment->setSfGuardUser($user);
$existing_assignment->setAuthorType($first);
$existing_assignment->save();
// Try to save episode assignment.
$assignment = new EpisodeAssignment();
$assignment->setEpisode($episode);
$assignment->setSfGuardUser($user);
$assignment->setAuthorType($first);
$exception_thrown = false;
try {
$assignment->save();
} catch (sfException $exception) {
$this->assertEquals(102, $exception->getCode());
$exception_thrown = true;
unset($exception);
}
// Remove test data.
$existing_episode->delete();
$existing_assignment->delete();
if ($assignment->getIncremented()) {
$assignment->delete();
}
$episode->delete();
$user->delete();
$deadline->delete();
$subreddit->delete();
$this->assertTrue($exception_thrown);
}
示例2: testGetFirstByUserAuthorTypeAndSubreddit
/**
* This tests whether the
* EpisodeAssignmentTable::getFirstByUserAuthorTypeAndSubreddit() function
* retrieves the correct EpisodeAssignment for a particular User in a
* Subreddit based on the AuthorType used in the EpisodeAssignment. Users
* can sign up for one Episode per AuthorType in each Subreddit, which means
* future Episodes (sicne we don't want the existence of past episode to
* disqualify Users from ever signing up again).
*/
public function testGetFirstByUserAuthorTypeAndSubreddit()
{
// Create two episode assignments: one for a past Episode, one for a future
$subreddit = new Subreddit();
$subreddit->setName(rand(0, 10000));
$subreddit->setDomain(rand(0, 10000));
$subreddit->save();
$user = new sfGuardUser();
$user->setUsername(rand(0, 10000));
$user->setEmailAddress(rand(0, 10000));
$user->setisValidated(1);
$user->save();
$first = AuthorTypeTable::getInstance()->findOneBy('type', 'squid');
$understudy = AuthorTypeTable::getInstance()->findOneBy('type', 'shark');
$this->assertTrue($first instanceof AuthorType);
$this->assertNotEquals(null, $first->getIncremented());
$this->assertTrue($understudy instanceof AuthorType);
$this->assertNotEquals(null, $understudy->getIncremented());
$deadline_one = new Deadline();
$deadline_one->setSeconds(100);
$deadline_one->setAuthorType($first);
$deadline_one->setSubreddit($subreddit);
$deadline_one->save();
$deadline_two = new Deadline();
$deadline_two->setSeconds(0);
$deadline_two->setAuthorType($understudy);
$deadline_two->setSubreddit($subreddit);
$deadline_two->save();
$episode_one = new Episode();
$episode_one->setReleaseDate(date('Y-m-d H:i:s', time() + 200000));
$episode_one->setSubreddit($subreddit);
$episode_one->save();
$episode_two = new Episode();
$episode_two->setReleaseDate(date('Y-m-d H:i:s', time() + 100000));
$episode_two->setSubreddit($subreddit);
$episode_two->save();
$episode_three = new Episode();
$episode_three->setReleaseDate(date('Y-m-d H:i:s', time() + 300000));
$episode_three->setSubreddit($subreddit);
$episode_three->save();
$assignment_one = new EpisodeAssignment();
$assignment_one->setEpisode($episode_one);
$assignment_one->setSfGuardUser($user);
$assignment_one->setAuthorType($first);
$assignment_one->save();
$assignment_two = new EpisodeAssignment();
$assignment_two->setEpisode($episode_two);
$assignment_two->setSfGuardUser($user);
$assignment_two->setAuthorType($understudy);
$assignment_two->save();
/* There should only be one Episode Assignment for future episodes per
* authortype per subreddit, so saving the third assignment should fail
* --- this is covered more in EpisodeAssignmentTest.phop
*/
$exception_thrown = false;
$assignment_three = new EpisodeAssignment();
$assignment_three->setEpisode($episode_three);
$assignment_three->setSfGuardUser($user);
$assignment_three->setAuthorType($first);
try {
$assignment_three->save();
} catch (Exception $exception) {
$exception_thrown = true;
$this->assertEquals(102, $exception->getCode());
unset($exception);
}
$this->assertTrue($exception_thrown);
/* Since we can trust that only one assignment per authortype per user
* per subreddit exists for future episodes (based on the failure to
* save $assignment_three), we check now to ensure that the
* getFirstByUserAuthorTypeAndSubreddit() function returns a valid
* EpisodeAssignment.
*/
$test_one = EpisodeAssignmentTable::getInstance()->getFirstByUserAuthorTypeAndSubreddit($assignment_one->getAuthorTypeId(), $assignment_one->getSfGuardUserId(), $assignment_one->getEpisode()->getSubredditId());
$test_two = EpisodeAssignmentTable::getInstance()->getFirstByUserAuthorTypeAndSubreddit($assignment_two->getAuthorTypeId(), $assignment_two->getSfGuardUserId(), $assignment_two->getEpisode()->getSubredditId());
$this->assertEquals($test_one->getIncremented(), $assignment_one->getIncremented());
$this->assertEquals($test_two->getIncremented(), $assignment_two->getIncremented());
$assignment_one->delete();
$assignment_two->delete();
$episode_one->delete();
$episode_two->delete();
$episode_three->delete();
$deadline_one->delete();
$deadline_two->delete();
$user->delete();
$subreddit->delete();
}