Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
RWebUserTest.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  */
12 {
13  public $fixtures = array(
14  'users' => 'User',
15  );
16 
17  /**
18  * Login with authField => 'username' in configuration
19  */
20  public function testLogin()
21  {
22  return;
23  Yii::app()->getModule('user')->authField = 'username';
24  $user = $this->users['sample1'];
25  $userIdentity = new UserIdentity($user['username'], $user['password_not_hashed']);
26  $this->assertTrue($userIdentity->authenticate());
27 
28  Yii::app()->user->login($userIdentity);
29 
30  $this->assertEquals($user['username'], Yii::app()->user->name);
31  $this->assertEquals($user['email'], Yii::app()->user->email);
32  }
33 
34  /**
35  * Login with authField => 'email' in configuration
36  */
37  public function testLoginWithoutUsername()
38  {
39  return;
40  Yii::app()->getModule('user')->authField = 'email';
41  $user = $this->users['sample4'];
42  $userIdentity = new UserIdentity($user['email'], $user['password_not_hashed']);
43  $this->assertTrue($userIdentity->authenticate());
44 
45  Yii::app()->user->login($userIdentity);
46 
47  $this->assertEquals($user['email'], Yii::app()->user->name);
48  $this->assertEquals($user['email'], Yii::app()->user->email);
49  }
50 
51 }