|
@@ 68-83 (lines=16) @@
|
| 65 |
|
/** |
| 66 |
|
* @covers ::actionAuthenticate |
| 67 |
|
*/ |
| 68 |
|
public function testApiAuthControllerAuthenticateShouldReturnInternalServerErrorWhenKeyCannotBeSaved() |
| 69 |
|
{ |
| 70 |
|
$username = 'username'; |
| 71 |
|
$password = 'test123'; |
| 72 |
|
$key = 'averynicekey'; |
| 73 |
|
$errorMessage = Craft::t('Something went wrong'); |
| 74 |
|
|
| 75 |
|
$mockUser = $this->getMockUser(); |
| 76 |
|
$this->setMockRequestService('POST', $username, $password); |
| 77 |
|
$this->setMockUserSessionService($username, $password, true, $mockUser); |
| 78 |
|
$this->setMockApiAuthService($key, $mockUser, false); |
| 79 |
|
|
| 80 |
|
$apiAuthController = $this->getMockApiAuthController('returnErrorJson', $errorMessage); |
| 81 |
|
|
| 82 |
|
$apiAuthController->actionAuthenticate(); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
/** |
| 86 |
|
* @covers ::actionAuthenticate |
|
@@ 88-102 (lines=15) @@
|
| 85 |
|
/** |
| 86 |
|
* @covers ::actionAuthenticate |
| 87 |
|
*/ |
| 88 |
|
public function testApiAuthControllerAuthenticateShouldReturnKey() |
| 89 |
|
{ |
| 90 |
|
$username = 'username'; |
| 91 |
|
$password = 'test123'; |
| 92 |
|
$key = 'averynicekey'; |
| 93 |
|
|
| 94 |
|
$mockUser = $this->getMockUser(); |
| 95 |
|
$this->setMockRequestService('POST', $username, $password); |
| 96 |
|
$this->setMockUserSessionService($username, $password, true, $mockUser); |
| 97 |
|
$this->setMockApiAuthService($key, $mockUser, true); |
| 98 |
|
|
| 99 |
|
$apiAuthController = $this->getMockApiAuthController('returnJson', array('key' => $key)); |
| 100 |
|
|
| 101 |
|
$apiAuthController->actionAuthenticate(); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
/** |
| 105 |
|
* @covers ::actionResetPassword |