diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-04-15 14:05:36 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-04-25 11:08:48 +0200 |
commit | 5e9b618604cbe36ecde488fad665e60607ef61a0 (patch) | |
tree | c3fbaf69ce93e8de52fa1bf0197181486eaac9d1 /apps/files_sharing/tests | |
parent | dc5c570d7caa3095a3cb4ab2b5a51bf772d7de4c (diff) | |
download | nextcloud-server-5e9b618604cbe36ecde488fad665e60607ef61a0.tar.gz nextcloud-server-5e9b618604cbe36ecde488fad665e60607ef61a0.zip |
Translate OCS Share API error messages
For https://github.com/owncloud/core/issues/22209
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r-- | apps/files_sharing/tests/api.php | 15 | ||||
-rw-r--r-- | apps/files_sharing/tests/api/share20ocstest.php | 75 |
2 files changed, 57 insertions, 33 deletions
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index 0a61e9a9fa2..3ded1bfc5d4 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -101,6 +101,12 @@ class Test_Files_Sharing_Api extends TestCase { private function createOCS($request, $userId) { $currentUser = \OC::$server->getUserManager()->get($userId); + $l = $this->getMock('\OCP\IL10N'); + $l->method('t') + ->will($this->returnCallback(function($text, $parameters = []) { + return vsprintf($text, $parameters); + })); + return new \OCA\Files_Sharing\API\Share20OCS( $this->shareManager, \OC::$server->getGroupManager(), @@ -108,7 +114,8 @@ class Test_Files_Sharing_Api extends TestCase { $request, \OC::$server->getRootFolder(), \OC::$server->getURLGenerator(), - $currentUser + $currentUser, + $l ); } @@ -665,7 +672,7 @@ class Test_Files_Sharing_Api extends TestCase { $this->assertFalse($result->succeeded()); $this->assertEquals(400, $result->getStatusCode()); - $this->assertEquals('not a directory', $result->getMeta()['message']); + $this->assertEquals('Not a directory', $result->getMeta()['message']); $this->shareManager->deleteShare($share1); } @@ -935,7 +942,7 @@ class Test_Files_Sharing_Api extends TestCase { $this->assertEquals(404, $result->getStatusCode()); $meta = $result->getMeta(); - $this->assertEquals('wrong share ID, share doesn\'t exist.', $meta['message']); + $this->assertEquals('Wrong share ID, share doesn\'t exist', $meta['message']); } /** @@ -1404,7 +1411,7 @@ class Test_Files_Sharing_Api extends TestCase { if ($valid === false) { $this->assertFalse($result->succeeded()); $this->assertEquals(404, $result->getStatusCode()); - $this->assertEquals('Invalid Date. Format must be YYYY-MM-DD.', $result->getMeta()['message']); + $this->assertEquals('Invalid date, date format must be YYYY-MM-DD', $result->getMeta()['message']); return; } diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php index 9a30b8720ed..56c350aa99a 100644 --- a/apps/files_sharing/tests/api/share20ocstest.php +++ b/apps/files_sharing/tests/api/share20ocstest.php @@ -20,6 +20,7 @@ */ namespace OCA\Files_Sharing\Tests\API; +use OCP\IL10N; use OCA\Files_Sharing\API\Share20OCS; use OCP\Files\NotFoundException; use OCP\IGroupManager; @@ -61,6 +62,9 @@ class Share20OCSTest extends \Test\TestCase { /** @var Share20OCS */ private $ocs; + /** @var IL10N */ + private $l; + protected function setUp() { $this->shareManager = $this->getMockBuilder('OCP\Share\IManager') ->disableOriginalConstructor() @@ -77,14 +81,21 @@ class Share20OCSTest extends \Test\TestCase { $this->currentUser = $this->getMock('OCP\IUser'); $this->currentUser->method('getUID')->willReturn('currentUser'); + $this->l = $this->getMock('\OCP\IL10N'); + $this->l->method('t') + ->will($this->returnCallback(function($text, $parameters = []) { + return vsprintf($text, $parameters); + })); + $this->ocs = new Share20OCS( - $this->shareManager, - $this->groupManager, - $this->userManager, - $this->request, - $this->rootFolder, - $this->urlGenerator, - $this->currentUser + $this->shareManager, + $this->groupManager, + $this->userManager, + $this->request, + $this->rootFolder, + $this->urlGenerator, + $this->currentUser, + $this->l ); } @@ -97,7 +108,8 @@ class Share20OCSTest extends \Test\TestCase { $this->request, $this->rootFolder, $this->urlGenerator, - $this->currentUser + $this->currentUser, + $this->l, ])->setMethods(['formatShare']) ->getMock(); } @@ -120,7 +132,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('outgoingServer2ServerSharesAllowed')->willReturn(true); - $expected = new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); + $expected = new \OC_OCS_Result(null, 404, 'Wrong share ID, share doesn\'t exist'); $this->assertEquals($expected, $this->ocs->deleteShare(42)); } @@ -361,7 +373,8 @@ class Share20OCSTest extends \Test\TestCase { $this->request, $this->rootFolder, $this->urlGenerator, - $this->currentUser + $this->currentUser, + $this->l, ])->setMethods(['canAccessShare']) ->getMock(); @@ -426,7 +439,7 @@ class Share20OCSTest extends \Test\TestCase { ->with('ocinternal:42') ->willReturn($share); - $expected = new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); + $expected = new \OC_OCS_Result(null, 404, 'Wrong share ID, share doesn\'t exist'); $this->assertEquals($expected->getMeta(), $this->ocs->getShare(42)->getMeta()); } @@ -478,7 +491,7 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareNoPath() { - $expected = new \OC_OCS_Result(null, 404, 'please specify a file or folder path'); + $expected = new \OC_OCS_Result(null, 404, 'Please specify a file or folder path'); $result = $this->ocs->createShare(); @@ -504,7 +517,7 @@ class Share20OCSTest extends \Test\TestCase { ->with('invalid-path') ->will($this->throwException(new \OCP\Files\NotFoundException())); - $expected = new \OC_OCS_Result(null, 404, 'wrong path, file/folder doesn\'t exist'); + $expected = new \OC_OCS_Result(null, 404, 'Wrong path, file/folder doesn\'t exist'); $result = $this->ocs->createShare(); @@ -572,7 +585,7 @@ class Share20OCSTest extends \Test\TestCase { ->with('valid-path') ->willReturn($path); - $expected = new \OC_OCS_Result(null, 404, 'please specify a valid user'); + $expected = new \OC_OCS_Result(null, 404, 'Please specify a valid user'); $result = $this->ocs->createShare(); @@ -610,7 +623,7 @@ class Share20OCSTest extends \Test\TestCase { ->with('valid-path') ->willReturn($path); - $expected = new \OC_OCS_Result(null, 404, 'please specify a valid user'); + $expected = new \OC_OCS_Result(null, 404, 'Please specify a valid user'); $result = $this->ocs->createShare(); @@ -631,7 +644,8 @@ class Share20OCSTest extends \Test\TestCase { $this->request, $this->rootFolder, $this->urlGenerator, - $this->currentUser + $this->currentUser, + $this->l, ])->setMethods(['formatShare']) ->getMock(); @@ -711,7 +725,7 @@ class Share20OCSTest extends \Test\TestCase { ->with('valid-path') ->willReturn($path); - $expected = new \OC_OCS_Result(null, 404, 'please specify a valid user'); + $expected = new \OC_OCS_Result(null, 404, 'Please specify a valid user'); $result = $this->ocs->createShare(); @@ -732,7 +746,8 @@ class Share20OCSTest extends \Test\TestCase { $this->request, $this->rootFolder, $this->urlGenerator, - $this->currentUser + $this->currentUser, + $this->l, ])->setMethods(['formatShare']) ->getMock(); @@ -819,7 +834,7 @@ class Share20OCSTest extends \Test\TestCase { $share->method('setNode')->with($path); - $expected = new \OC_OCS_Result(null, 404, 'group sharing is disabled by the administrator'); + $expected = new \OC_OCS_Result(null, 404, 'Group sharing is disabled by the administrator'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -845,7 +860,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); - $expected = new \OC_OCS_Result(null, 404, 'public link sharing is disabled by the administrator'); + $expected = new \OC_OCS_Result(null, 404, 'Public link sharing is disabled by the administrator'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -873,7 +888,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); - $expected = new \OC_OCS_Result(null, 403, 'public upload disabled by the administrator'); + $expected = new \OC_OCS_Result(null, 403, 'Public upload disabled by the administrator'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -902,7 +917,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 404, 'public upload is only possible for public shared folders'); + $expected = new \OC_OCS_Result(null, 404, 'Public upload is only possible for publicly shared folders'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1070,7 +1085,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 404, 'Invalid Date. Format must be YYYY-MM-DD.'); + $expected = new \OC_OCS_Result(null, 404, 'Invalid date, date format must be YYYY-MM-DD'); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1093,7 +1108,8 @@ class Share20OCSTest extends \Test\TestCase { $this->request, $this->rootFolder, $this->urlGenerator, - $this->currentUser + $this->currentUser, + $this->l, ])->setMethods(['formatShare']) ->getMock(); @@ -1142,7 +1158,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); - $expected = new \OC_OCS_Result(null, 404, 'wrong share Id, share doesn\'t exist.'); + $expected = new \OC_OCS_Result(null, 404, 'Wrong share ID, share doesn\'t exist'); $result = $this->ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1306,7 +1322,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(false); - $expected = new \OC_OCS_Result(null, 403, 'public upload disabled by the administrator'); + $expected = new \OC_OCS_Result(null, 403, 'Public upload disabled by the administrator'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1335,7 +1351,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 400, 'public upload is only possible for public shared folders'); + $expected = new \OC_OCS_Result(null, 400, 'Public upload is only possible for publicly shared folders'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1523,7 +1539,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 400, 'can\'t change permission for public link share'); + $expected = new \OC_OCS_Result(null, 400, 'Can\'t change permissions for public share links'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1899,7 +1915,8 @@ class Share20OCSTest extends \Test\TestCase { $this->request, $this->rootFolder, $this->urlGenerator, - $this->currentUser + $this->currentUser, + $this->l ); } |