当前位置: 首页>>代码示例>>PHP>>正文


PHP sfGuardUser::getIncremented方法代码示例

本文整理汇总了PHP中sfGuardUser::getIncremented方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::getIncremented方法的具体用法?PHP sfGuardUser::getIncremented怎么用?PHP sfGuardUser::getIncremented使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfGuardUser的用法示例。


在下文中一共展示了sfGuardUser::getIncremented方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSavingBlockedUser

 /**
  * Tests saving a sfGuardUserSubredditMembership that identifies a User as
  * "blocked" for a particular Subreddit.  When this occurs, all existing
  * future EpisodeAssignments should be deleted because blocked users cannot
  * participate with the Subreddit.
  */
 public function testSavingBlockedUser()
 {
     // Establish fake Subreddit
     $subreddit = new Subreddit();
     $subreddit->setName(rand(0, 1000));
     $subreddit->setDomain(rand(0, 1000));
     $subreddit->save();
     // Establish User
     $user = new sfGuardUser();
     $user->setEmailAddress(rand(0, 100000));
     $user->setUsername(rand(0, 10000));
     $user->setIsValidated(1);
     $user->save();
     $user_id = $user->getIncremented();
     $this->assertNotEquals(0, $user_id);
     // Establish Episode for Subreddit
     $episode = new Episode();
     $episode->setSubreddit($subreddit);
     $episode->setReleaseDate(date('Y-m-d H:i:s', time() + 34000));
     $episode->save();
     $author_type = AuthorTypeTable::getInstance()->findOneBy('type', 'squid');
     $deadline = new Deadline();
     $deadline->setSubreddit($subreddit);
     $deadline->setAuthorType($author_type);
     $deadline->setSeconds(0);
     $deadline->save();
     $episode_assignment = new EpisodeAssignment();
     $episode_assignment->setSfGuardUser($user);
     $episode_assignment->setEpisode($episode);
     $episode_assignment->setAuthorType($author_type);
     $episode_assignment->save();
     $number_of_episodes = EpisodeAssignmentTable::getInstance()->createQuery()->select('COUNT(EpisodeAssignment.id)')->leftJoin('Episode')->where('subreddit_id = ?', $subreddit->getIncremented())->andWhere('EpisodeAssignment.sf_guard_user_id = ?', $user_id)->andWhere('Episode.release_date > NOW()')->groupBy('EpisodeAssignment.id')->count();
     $this->assertEquals(1, $number_of_episodes);
     // Establish User Membership as Blocked
     $blocked = MembershipTable::getInstance()->findOneBy('type', 'blocked');
     $user_membership = new sfGuardUserSubredditMembership();
     $user_membership->setSubreddit($subreddit);
     $user_membership->setSfGuardUser($user);
     $user_membership->setMembership($blocked);
     // Save Membership
     $user_membership->save();
     // Asert that User has zero Episodes
     $number_of_episodes = EpisodeAssignmentTable::getInstance()->createQuery()->select('COUNT(EpisodeAssignment.id)')->leftJoin('Episode')->where('subreddit_id = ?', $subreddit->getIncremented())->andWhere('EpisodeAssignment.sf_guard_user_id = ?', $user_id)->andWhere('Episode.release_date > NOW()')->groupBy('EpisodeAssignment.id');
     $sql = $number_of_episodes->getSqlQuery();
     $number_of_episodes = $number_of_episodes->count();
     $this->assertTrue(0 == $number_of_episodes, $sql . "\n" . $subreddit->getIncremented() . "\n" . $user_id);
     // Remove User Membership
     $user_membership->delete();
     // Delete User
     $user->delete();
     // Delete Episode
     $episode->delete();
     // Delete Deadline
     $deadline->delete();
     // Delete Subreddit
     $subreddit->delete();
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:63,代码来源:sfGuardUserSubredditMembershipTest.php

示例2: testGetFirstByUserSubredditAndMemberships

 /**
  * Since a User can only have one membership in a Subreddit, this tests that
  * the first returned sfGuardUserSubredditMembership is the exact same as
  * the only one made.  The limitation on sfGuardUserSubredditMemberships is
  * in place using Unique indexes in the database, so we depend upon that to
  * prevent multiple Subreddit Memberships.
  */
 public function testGetFirstByUserSubredditAndMemberships()
 {
     $user = new sfGuardUser();
     $user->setEmailAddress(rand(0, 1000));
     $user->setUsername(rand(0, 1000));
     $user->setIsValidated(1);
     $user->save();
     $subreddit = new Subreddit();
     $subreddit->setName(rand(0, 1000));
     $subreddit->setDomain(rand(0, 1000));
     $subreddit->save();
     $membership = MembershipTable::getInstance()->findOneByType('user');
     $second_membership = MembershipTable::getInstance()->findOneByType('admin');
     $user_subreddit_membership = new sfGuardUserSubredditMembership();
     $user_subreddit_membership->setSfGuardUserId($user->getIncremented());
     $user_subreddit_membership->setSubredditId($subreddit->getIncremented());
     $user_subreddit_membership->setMembership($membership);
     $user_subreddit_membership->save();
     $second_user_subreddit_membership = new sfGuardUserSubredditMembership();
     $second_user_subreddit_membership->setSfGuardUserId($user->getIncremented());
     $second_user_subreddit_membership->setSubredditId($subreddit->getIncremented());
     $second_user_subreddit_membership->setMembership($second_membership);
     $exception_thrown = false;
     try {
         $second_user_subreddit_membership->save();
     } catch (Exception $exception) {
         unset($exception);
         $exception_thrown = true;
     }
     $retrieved_object = sfGuardUserSubredditMembershipTable::getInstance()->getFirstByUserSubredditAndMemberships($user->getIncremented(), $subreddit->getIncremented(), array($membership->getType()));
     $this->assertEquals($retrieved_object->getIncremented(), $user_subreddit_membership->getIncremented());
     $user_subreddit_membership->delete();
     $subreddit->delete();
     $user->delete();
     $this->assertTrue($exception_thrown);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:43,代码来源:sfGuardUserSubredditMembershipTableTest.php


注:本文中的sfGuardUser::getIncremented方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。