summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-01 17:46:48 +0100
committerLukas Reschke <lukas@owncloud.com>2015-02-01 17:46:48 +0100
commit944dc127b82105acb8c28ffb28439b245c020f43 (patch)
tree30b207fd166b05dac2780fba89689b2429de2cfb /tests
parentba29ea178f7ba18795e36b55ba8b397703280792 (diff)
downloadnextcloud-server-944dc127b82105acb8c28ffb28439b245c020f43.tar.gz
nextcloud-server-944dc127b82105acb8c28ffb28439b245c020f43.zip
Mock l10n in the setup
Diffstat (limited to 'tests')
-rw-r--r--tests/core/lostpassword/controller/lostcontrollertest.php49
1 files changed, 23 insertions, 26 deletions
diff --git a/tests/core/lostpassword/controller/lostcontrollertest.php b/tests/core/lostpassword/controller/lostcontrollertest.php
index 3f3cda2b0c7..b03cbd7c42f 100644
--- a/tests/core/lostpassword/controller/lostcontrollertest.php
+++ b/tests/core/lostpassword/controller/lostcontrollertest.php
@@ -29,6 +29,12 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
->disableOriginalConstructor()->getMock();
$this->container['L10N'] = $this->getMockBuilder('\OCP\IL10N')
->disableOriginalConstructor()->getMock();
+ $this->container['L10N']
+ ->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function($text, $parameters = array()) {
+ return vsprintf($text, $parameters);
+ }));
$this->container['Defaults'] = $this->getMockBuilder('\OC_Defaults')
->disableOriginalConstructor()->getMock();
$this->container['UserManager'] = $this->getMockBuilder('\OCP\IUserManager')
@@ -73,21 +79,13 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
array(true, $existingUser),
array(false, $nonExistingUser)
)));
- $this->container['L10N']
- ->expects($this->any())
- ->method('t')
- ->will(
- $this->returnValueMap(
- array(
- array('Couldn\'t send reset email. Please make sure your username is correct.', array(),
- 'Couldn\'t send reset email. Please make sure your username is correct.'),
-
- )
- ));
// With a non existing user
$response = $this->lostController->email($nonExistingUser);
- $expectedResponse = array('status' => 'error', 'msg' => 'Couldn\'t send reset email. Please make sure your username is correct.');
+ $expectedResponse = [
+ 'status' => 'error',
+ 'msg' => 'Couldn\'t send reset email. Please make sure your username is correct.'
+ ];
$this->assertSame($expectedResponse, $response);
// With no mail address
@@ -97,7 +95,10 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
->with($existingUser, 'settings', 'email')
->will($this->returnValue(null));
$response = $this->lostController->email($existingUser);
- $expectedResponse = array('status' => 'error', 'msg' => 'Couldn\'t send reset email. Please make sure your username is correct.');
+ $expectedResponse = [
+ 'status' => 'error',
+ 'msg' => 'Couldn\'t send reset email. Please make sure your username is correct.'
+ ];
$this->assertSame($expectedResponse, $response);
}
@@ -146,16 +147,6 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
}
public function testSetPasswordUnsuccessful() {
- $this->container['L10N']
- ->expects($this->any())
- ->method('t')
- ->will(
- $this->returnValueMap(
- array(
- array('Couldn\'t reset password because the token is invalid', array(),
- 'Couldn\'t reset password because the token is invalid'),
- )
- ));
$this->container['Config']
->expects($this->once())
->method('getUserValue')
@@ -165,12 +156,15 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
// With an invalid token
$userName = 'InvalidTokenUser';
$response = $this->lostController->setPassword('wrongToken', $userName, 'NewPassword', true);
- $expectedResponse = array('status' => 'error', 'msg' => 'Couldn\'t reset password because the token is invalid');
+ $expectedResponse = [
+ 'status' => 'error',
+ 'msg' => 'Couldn\'t reset password because the token is invalid'
+ ];
$this->assertSame($expectedResponse, $response);
// With a valid token and no proceed
$response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword!', $userName, 'NewPassword', false);
- $expectedResponse = array('status' => 'error', 'msg' => '', 'encryption' => true);
+ $expectedResponse = ['status' => 'error', 'msg' => '', 'encryption' => true];
$this->assertSame($expectedResponse, $response);
}
@@ -209,7 +203,10 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
->will($this->returnValue(null));
$response = $this->lostController->setPassword('', 'ValidTokenUser', 'NewPassword', true);
- $expectedResponse = ['status' => 'error', 'msg' => ''];
+ $expectedResponse = [
+ 'status' => 'error',
+ 'msg' => 'Couldn\'t reset password because the token is invalid'
+ ];
$this->assertSame($expectedResponse, $response);
}