예제 #1
0
 public static function createRandomTestUserLoginEvent()
 {
     $testData = self::$testData;
     unset($testData['id']);
     $testData['user'] = UserTest::createRandomTestUser();
     $testData['date'] = new DateTime();
     return new UserLoginEvent($testData);
 }
예제 #2
0
 public static function createOldTestPasswordResetToken()
 {
     $testData = self::$testData;
     $date = new DateTime();
     $date->sub(new DateInterval('P2D'));
     $testData['user'] = UserTest::createRandomTestUser();
     $testData['token'] = sha1(mt_rand());
     $testData['requestDate'] = $date;
     return new UserPasswordResetToken($testData);
 }
예제 #3
0
 public function setUp()
 {
     parent::setUp();
     Zend_Registry::set('staticSalt', sha1(mt_rand()));
     $this->_authUser = UserTest::createRandomTestUser();
     $this->_authUser->setUsername('Admin');
     $this->_authUser->setPassword(UserService::encryptPassword('password', $this->_authUser->getSalt()));
     AclRoleService::create($this->_authUser->getRole());
     UserService::create($this->_authUser);
 }
예제 #4
0
 public static function createRandomTestUserProfile(User $user = null)
 {
     $testData = self::$testData;
     unset($testData['id']);
     $testData['user'] = null === $user ? UserTest::createRandomTestUser() : $user;
     $testData['firstName'] .= substr(sha1(mt_rand()), 0, 4);
     $testData['lastName'] .= substr(sha1(mt_rand()), 0, 4);
     $testData['socialNetworkIdentities'] = new ArrayCollection(array(UserSocialNetworkIdentityTest::createTestIdentity()));
     $testData['timeZone'] = TimeZoneTest::createRandomTestTimeZone();
     return new UserProfile($testData);
 }
예제 #5
0
 public function setUp()
 {
     $fc = FrontController::getInstance();
     $fc->resetInstance();
     $fc->setControllerDirectory(dirname(__FILE__), 'default');
     #\Zend_Registry::set('acl', AclTest::createTestAcl());
     $user = UserTest::createTestUser();
     $userProfile = UserProfileTest::createTestUserProfile();
     $user->setProfile($userProfile);
     $acl = $this->_getCleanMock('Rexmac\\Zyndax\\Acl\\Acl');
     $acl->expects($this->once())->method('getUser')->will($this->returnValue($user));
     Zend_Registry::set('acl', $acl);
 }
예제 #6
0
파일: AclTest.php 프로젝트: rexmac/zyndax
 public function testIsUserAllowedWithValidUserAndGlobalResource()
 {
     $adminUser = UserTest::createRandomTestUser();
     $adminUser->setUsername('Admin');
     $adminUser->setRole($this->adminRole);
     self::$entityManager->persist($adminUser);
     self::$entityManager->flush();
     $authIdentity = new \stdClass();
     $authIdentity->id = $adminUser->getId();
     $authIdentity->username = $adminUser->getUsername();
     Zend_Registry::set('user', $adminUser);
     $this->acl = new Acl();
     $this->assertTrue($this->acl->isUserAllowed('mvc:admin:foobar', 'view'), 'Admin user can view all admin resources');
 }
예제 #7
0
 public function testSendVerificationEmail()
 {
     $siteDomain = 'mytestsite.tld';
     $siteName = 'MY_TEST_SITE';
     $_SERVER['HTTP_HOST'] = $siteDomain;
     Zend_Registry::set('siteName', $siteName);
     $recipient = 'root@localhost';
     $user = UserTest::createTestUser();
     $user->setEmail($recipient);
     // Real address in case we actually send mail
     $mock = new MockMailTransport();
     UserService::sendVerificationEmail($user, $mock);
     $subject = '[' . $siteName . '] Email Verification';
     $this->assertTrue($mock->called);
     $this->assertEquals($subject, $mock->subject);
     $this->assertEquals('noreply@' . $siteDomain, $mock->from);
     $this->assertContains($recipient, $mock->recipients);
     $this->assertContains("Thank you for registering with {$siteName}.", $mock->mail->getBodyText()->getRawContent());
     $this->assertContains("From: {$siteName} <noreply@{$siteDomain}>", $mock->header);
     $this->assertContains("Subject: {$subject}", $mock->header);
     $this->assertContains("To: {$recipient}", $mock->header);
 }