From 3e2c56157bfb20fbc48bdf668bd56fb47bd7cc1f Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 20 Feb 2014 11:33:46 +0100 Subject: [PATCH 01/13] reduce width of searchbox on mobile, fix overlap, fix #7282 --- core/css/mobile.css | 20 ++++++++++++++++++++ core/css/styles.css | 10 ++++++---- lib/base.php | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 core/css/mobile.css diff --git a/core/css/mobile.css b/core/css/mobile.css new file mode 100644 index 0000000000..a4cca6f37f --- /dev/null +++ b/core/css/mobile.css @@ -0,0 +1,20 @@ +@media only screen and (max-width: 600px) { + +/* compress search box on mobile, expand when focused */ +.searchbox input[type="search"] { + width: 17%; + -webkit-transition: width 100ms; + -moz-transition: width 100ms; + -o-transition: width 100ms; + transition: width 100ms; +} +.searchbox input[type="search"]:focus, +.searchbox input[type="search"]:active { + width: 155px; + -webkit-transition: width 100ms; + -moz-transition: width 100ms; + -o-transition: width 100ms; + transition: width 100ms; +} + +} diff --git a/core/css/styles.css b/core/css/styles.css index bee44785f1..c17d0a9bc0 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -205,17 +205,19 @@ textarea:disabled { color: #bbb; } - +/* Searchbox */ .searchbox input[type="search"] { + position: relative; font-size: 1.2em; - padding: .2em .5em .2em 1.5em; + padding-left: 1.5em; background: #fff url('../img/actions/search.svg') no-repeat .5em center; border: 0; - border-radius: 1em; + border-radius: 2em; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity: .7; - margin-top: 10px; + margin-top: 6px; float: right; } + input[type="submit"].enabled { background: #66f866; border: 1px solid #5e5; diff --git a/lib/base.php b/lib/base.php index a5f064bdb4..84177c7ba6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -332,6 +332,7 @@ class OC { } OC_Util::addStyle("styles"); + OC_Util::addStyle("mobile"); OC_Util::addStyle("icons"); OC_Util::addStyle("apps"); OC_Util::addStyle("fixes"); From 92d57cb5a7de41e576c9cbd3fae70e9802561187 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 20 Feb 2014 13:36:52 +0100 Subject: [PATCH 02/13] move avatar into clickable area of user menu --- core/css/styles.css | 8 ++++---- core/js/js.js | 4 +++- core/templates/layout.user.php | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index c17d0a9bc0..1c80a3ea16 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -37,11 +37,12 @@ body { background:#fefefe; font:normal .8em/1.6em "Helvetica Neue",Helvetica,Ari .header-right { float:right; vertical-align:middle; padding:0.5em; } .header-right > * { vertical-align:middle; } +/* Profile picture in header */ #header .avatardiv { float: left; display: inline-block; + margin-right: 5px; } - #header .avatardiv img { opacity: 1; } @@ -708,12 +709,11 @@ label.infield { cursor:text !important; top:1.05em; left:.85em; } /* USER MENU */ #settings { float: right; - margin-top: 7px; - margin-left: 10px; color: #bbb; } #expand { - padding: 15px 15px 15px 5px; + display: block; + padding: 7px 12px 6px 7px; cursor: pointer; font-weight: bold; } diff --git a/core/js/js.js b/core/js/js.js index d4d2583f1e..59d4880641 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -860,6 +860,7 @@ function initCore() { // checkShowCredentials(); // $('input#user, input#password').keyup(checkShowCredentials); + // user menu $('#settings #expand').keydown(function(event) { if (event.which === 13 || event.which === 32) { $('#expand').click() @@ -872,7 +873,8 @@ function initCore() { $('#settings #expanddiv').click(function(event){ event.stopPropagation(); }); - $(document).click(function(){//hide the settings menu when clicking outside it + //hide the user menu when clicking outside it + $(document).click(function(){ $('#settings #expanddiv').slideUp(200); }); diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index bc1c700402..8b9e1e0f4f 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -50,12 +50,12 @@
+ +
+
- -
-
    From 20b740f8e4674ab16f44127bc809a35b8db24910 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 20 Feb 2014 13:37:23 +0100 Subject: [PATCH 03/13] do not show display name on mobile when profile picture is present --- core/css/mobile.css | 6 ++++++ core/js/avatar.js | 9 ++++++++- core/js/jquery.avatar.js | 10 +++++++++- settings/js/personal.js | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/core/css/mobile.css b/core/css/mobile.css index a4cca6f37f..65c756aa91 100644 --- a/core/css/mobile.css +++ b/core/css/mobile.css @@ -17,4 +17,10 @@ transition: width 100ms; } +/* do not show display name on mobile when profile picture is present */ +#header .avatardiv.avatardiv-shown + #expandDisplayName { + display: none; +} + + } diff --git a/core/js/avatar.js b/core/js/avatar.js index c54c406876..67d6b9b7b9 100644 --- a/core/js/avatar.js +++ b/core/js/avatar.js @@ -1,6 +1,13 @@ $(document).ready(function(){ if (OC.currentUser) { - $('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true); + var callback = function() { + // do not show display name on mobile when profile picture is present + if($('#header .avatardiv').children().length > 0) { + $('#header .avatardiv').addClass('avatardiv-shown'); + } + }; + + $('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true, callback); // Personal settings $('#avatar .avatardiv').avatar(OC.currentUser, 128); } diff --git a/core/js/jquery.avatar.js b/core/js/jquery.avatar.js index 6012eccfad..02a40c088b 100644 --- a/core/js/jquery.avatar.js +++ b/core/js/jquery.avatar.js @@ -39,10 +39,15 @@ * This will behave like the first example, but it will hide the avatardiv, if * it will display the default placeholder. undefined is the ie8fix from * example 4 and can be either true, or false/undefined, to be ignored. + * + * 6. $('.avatardiv').avatar('jdoe', 128, undefined, true, callback); + * This will behave like the above example, but it will call the function + * defined in callback after the avatar is placed into the DOM. + * */ (function ($) { - $.fn.avatar = function(user, size, ie8fix, hidedefault) { + $.fn.avatar = function(user, size, ie8fix, hidedefault, callback) { if (typeof(size) === 'undefined') { if (this.height() > 0) { size = this.height(); @@ -91,6 +96,9 @@ $div.html(''); } } + if(typeof callback === 'function') { + callback(); + } }); }); }; diff --git a/settings/js/personal.js b/settings/js/personal.js index ef261b50bb..5944272067 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -52,9 +52,11 @@ function updateAvatar (hidedefault) { if(hidedefault) { $headerdiv.hide(); + $('#header .avatardiv').removeClass('avatardiv-shown'); } else { $headerdiv.css({'background-color': ''}); $headerdiv.avatar(OC.currentUser, 32, true); + $('#header .avatardiv').addClass('avatardiv-shown'); } $displaydiv.css({'background-color': ''}); $displaydiv.avatar(OC.currentUser, 128, true); From d5690a174e42ad97cf7e9bffa3b62f42b69f6a82 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 20 Feb 2014 14:05:45 +0100 Subject: [PATCH 04/13] LDAP: fix and extend tests --- apps/user_ldap/tests/access.php | 71 ++++++++++++++++++++ apps/user_ldap/tests/user_ldap.php | 101 ++++++++++++++++++++++++++++- 2 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 apps/user_ldap/tests/access.php diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php new file mode 100644 index 0000000000..9beb2b9733 --- /dev/null +++ b/apps/user_ldap/tests/access.php @@ -0,0 +1,71 @@ +. +* +*/ + +namespace OCA\user_ldap\tests; + +use \OCA\user_ldap\lib\Access; +use \OCA\user_ldap\lib\Connection; +use \OCA\user_ldap\lib\ILDAPWrapper; + +class Test_Access extends \PHPUnit_Framework_TestCase { + private function getConnecterAndLdapMock() { + static $conMethods; + static $accMethods; + + if(is_null($conMethods) || is_null($accMethods)) { + $conMethods = get_class_methods('\OCA\user_ldap\lib\Connection'); + $accMethods = get_class_methods('\OCA\user_ldap\lib\Access'); + } + $lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper'); + $connector = $this->getMock('\OCA\user_ldap\lib\Connection', + $conMethods, + array($lw, null, null)); + + return array($lw, $connector); + } + + public function testEscapeFilterPartValidChars() { + list($lw, $con) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw); + + $input = 'okay'; + $this->assertTrue($input === $access->escapeFilterPart($input)); + } + + public function testEscapeFilterPartEscapeWildcard() { + list($lw, $con) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw); + + $input = '*'; + $expected = '\\\\*'; + $this->assertTrue($expected === $access->escapeFilterPart($input)); + } + + public function testEscapeFilterPartEscapeWildcard2() { + list($lw, $con) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw); + + $input = 'foo*bar'; + $expected = 'foo\\\\*bar'; + $this->assertTrue($expected === $access->escapeFilterPart($input)); + } +} \ No newline at end of file diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php index 9193a005ae..8c8d85b3c3 100644 --- a/apps/user_ldap/tests/user_ldap.php +++ b/apps/user_ldap/tests/user_ldap.php @@ -83,6 +83,12 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase { * @return void */ private function prepareAccessForCheckPassword(&$access) { + $access->expects($this->once()) + ->method('escapeFilterPart') + ->will($this->returnCallback(function($uid) { + return $uid; + })); + $access->connection->expects($this->any()) ->method('__get') ->will($this->returnCallback(function($name) { @@ -116,17 +122,34 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase { })); } - public function testCheckPassword() { + public function testCheckPasswordUidReturn() { $access = $this->getAccessMock(); + $this->prepareAccessForCheckPassword($access); $backend = new UserLDAP($access); \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'dt19'); $this->assertEquals('gunslinger', $result); + } + + public function testCheckPasswordWrongPassword() { + $access = $this->getAccessMock(); + + $this->prepareAccessForCheckPassword($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'wrong'); $this->assertFalse($result); + } + + public function testCheckPasswordWrongUser() { + $access = $this->getAccessMock(); + + $this->prepareAccessForCheckPassword($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = $backend->checkPassword('mallory', 'evil'); $this->assertFalse($result); @@ -140,9 +163,23 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase { $result = \OCP\User::checkPassword('roland', 'dt19'); $this->assertEquals('gunslinger', $result); + } + + public function testCheckPasswordPublicAPIWrongPassword() { + $access = $this->getAccessMock(); + $this->prepareAccessForCheckPassword($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = \OCP\User::checkPassword('roland', 'wrong'); $this->assertFalse($result); + } + + public function testCheckPasswordPublicAPIWrongUser() { + $access = $this->getAccessMock(); + $this->prepareAccessForCheckPassword($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = \OCP\User::checkPassword('mallory', 'evil'); $this->assertFalse($result); @@ -154,6 +191,12 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase { * @return void */ private function prepareAccessForGetUsers(&$access) { + $access->expects($this->once()) + ->method('escapeFilterPart') + ->will($this->returnCallback(function($search) { + return $search; + })); + $access->expects($this->any()) ->method('getFilterPartForUserSearch') ->will($this->returnCallback(function($search) { @@ -191,28 +234,52 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase { ->will($this->returnArgument(0)); } - public function testGetUsers() { + public function testGetUsersNoParam() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); $backend = new UserLDAP($access); $result = $backend->getUsers(); $this->assertEquals(3, count($result)); + } + + public function testGetUsersLimitOffset() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); $result = $backend->getUsers('', 1, 2); $this->assertEquals(1, count($result)); + } + + public function testGetUsersLimitOffset2() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); $result = $backend->getUsers('', 2, 1); $this->assertEquals(2, count($result)); + } + + public function testGetUsersSearchWithResult() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); $result = $backend->getUsers('yo'); $this->assertEquals(2, count($result)); + } + + public function testGetUsersSearchEmptyResult() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); $result = $backend->getUsers('nix'); $this->assertEquals(0, count($result)); } - public function testGetUsersViaAPI() { + public function testGetUsersViaAPINoParam() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); $backend = new UserLDAP($access); @@ -220,15 +287,43 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase { $result = \OCP\User::getUsers(); $this->assertEquals(3, count($result)); + } + + public function testGetUsersViaAPILimitOffset() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = \OCP\User::getUsers('', 1, 2); $this->assertEquals(1, count($result)); + } + + public function testGetUsersViaAPILimitOffset2() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = \OCP\User::getUsers('', 2, 1); $this->assertEquals(2, count($result)); + } + + public function testGetUsersViaAPISearchWithResult() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = \OCP\User::getUsers('yo'); $this->assertEquals(2, count($result)); + } + + public function testGetUsersViaAPISearchEmptyResult() { + $access = $this->getAccessMock(); + $this->prepareAccessForGetUsers($access); + $backend = new UserLDAP($access); + \OC_User::useBackend($backend); $result = \OCP\User::getUsers('nix'); $this->assertEquals(0, count($result)); From d46645846985fe181fcb252bec158624a1ee2957 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 20 Feb 2014 17:37:48 +0100 Subject: [PATCH 05/13] restrict zooming in to not mangle layout accidentally --- core/templates/layout.user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 8b9e1e0f4f..9e1555cfe6 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -15,7 +15,7 @@ - + From d5739e83d16dd4af1865999180c7867a7f77734f Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 20 Feb 2014 18:38:33 +0100 Subject: [PATCH 06/13] remove additional transition rule, reduce width of collapsed search bar --- core/css/mobile.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/css/mobile.css b/core/css/mobile.css index 65c756aa91..a63aa902d3 100644 --- a/core/css/mobile.css +++ b/core/css/mobile.css @@ -2,7 +2,7 @@ /* compress search box on mobile, expand when focused */ .searchbox input[type="search"] { - width: 17%; + width: 15%; -webkit-transition: width 100ms; -moz-transition: width 100ms; -o-transition: width 100ms; @@ -11,10 +11,6 @@ .searchbox input[type="search"]:focus, .searchbox input[type="search"]:active { width: 155px; - -webkit-transition: width 100ms; - -moz-transition: width 100ms; - -o-transition: width 100ms; - transition: width 100ms; } /* do not show display name on mobile when profile picture is present */ From daf28225b7da283763ec84930608e154f49dee46 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 20 Feb 2014 18:42:59 +0100 Subject: [PATCH 07/13] fix viewport size on windows phone --- core/js/js.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/js/js.js b/core/js/js.js index d4d2583f1e..c7024430aa 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -987,6 +987,17 @@ OC.set=function(name, value) { context[tail]=value; }; +// fix device width on windows phone +(function() { + if ("-ms-user-select" in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/)) { + var msViewportStyle = document.createElement("style"); + msViewportStyle.appendChild( + document.createTextNode("@-ms-viewport{width:auto!important}") + ); + document.getElementsByTagName("head")[0].appendChild(msViewportStyle); + } +})(); + /** * select a range in an input field * @link http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area From 1ae6e9ec21415ade8122a05d01dd091091cb4bcd Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 20 Feb 2014 18:50:27 +0100 Subject: [PATCH 08/13] add unit test for \OC\URLGenerator::getAbsoluteURL to verify #6935 --- tests/lib/urlgenerator.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/lib/urlgenerator.php diff --git a/tests/lib/urlgenerator.php b/tests/lib/urlgenerator.php new file mode 100644 index 0000000000..875a7f0658 --- /dev/null +++ b/tests/lib/urlgenerator.php @@ -0,0 +1,34 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +class Test_Urlgenerator extends PHPUnit_Framework_TestCase { + + + /** + * @small + * @brief test absolute URL construction + * @dataProvider provideURLs + */ + function testGetAbsoluteURL($url, $expectedResult) { + + $urlGenerator = new \OC\URLGenerator(null); + $result = $urlGenerator->getAbsoluteURL($url); + + $this->assertEquals($expectedResult, $result); + } + + public function provideURLs() { + return array( + array("index.php", "http://localhost/index.php"), + array("/index.php", "http://localhost/index.php"), + array("/apps/index.php", "http://localhost/apps/index.php"), + array("apps/index.php", "http://localhost/apps/index.php"), + ); + } +} + From 69325c5eebef1f21b514a5edeb48d71d53815668 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 21 Feb 2014 08:11:07 +0100 Subject: [PATCH 09/13] Move session_regenerate_id to `login()` --- lib/private/user.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/user.php b/lib/private/user.php index 08ead71202..a89b7286c1 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -227,6 +227,7 @@ class OC_User { * Log in a user and regenerate a new session - if the password is ok */ public static function login($uid, $password) { + session_regenerate_id(true); return self::getUserSession()->login($uid, $password); } From f7fa8662e21fdb93383e771ba629f82d8344582a Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 21 Feb 2014 08:12:45 +0100 Subject: [PATCH 10/13] Remove `session_id_regenerate` from here Jenkins somewhat complains that there are already sent headers. --- lib/private/user/session.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/private/user/session.php b/lib/private/user/session.php index cd03b30205..1740bad5ab 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -157,7 +157,6 @@ class Session implements Emitter, \OCP\IUserSession { if($user !== false) { if (!is_null($user)) { if ($user->isEnabled()) { - session_regenerate_id(true); $this->setUser($user); $this->setLoginName($uid); $this->manager->emit('\OC\User', 'postLogin', array($user, $password)); From 229356348826402e4dc8090e1a805f278d6c9ad0 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 21 Feb 2014 10:02:03 +0100 Subject: [PATCH 11/13] Remove unit tests which causes the filesystem tests to fail --- tests/lib/connector/sabre/file.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php index 50b8711a90..c2f0ffa12d 100644 --- a/tests/lib/connector/sabre/file.php +++ b/tests/lib/connector/sabre/file.php @@ -48,21 +48,6 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase { $etag = $file->put('test data'); } - /** - * Test setting name with setName() - */ - public function testSetName() { - // setup - $file = new OC_Connector_Sabre_File('/test.txt'); - $file->fileView = $this->getMock('\OC\Files\View', array('isUpdatable'), array(), '', FALSE); - $file->fileView->expects($this->any())->method('isUpdatable')->withAnyParameters()->will($this->returnValue(true)); - $etag = $file->put('test data'); - $file->setName('/renamed.txt'); - $this->assertTrue($file->fileView->file_exists('/renamed.txt')); - // clean up - $file->delete(); - } - /** * Test setting name with setName() with invalid chars * @expectedException Sabre_DAV_Exception_BadRequest From 2f6639875e88c54a95f94a28e2b0ffb18e1c3d1b Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 21 Feb 2014 10:58:05 +0100 Subject: [PATCH 12/13] ignore optional additional config files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 25cb1b227f..e61ec6f035 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /data /owncloud /config/config.php +/config/*.config.php /config/mount.php /apps/inc.php From cf7ef0d35686a4a418abab2c7ad798b56a9317a3 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 19 Feb 2014 16:56:37 +0100 Subject: [PATCH 13/13] fix sharing unit tests --- tests/lib/share/backend.php | 8 ++++---- tests/lib/share/share.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/lib/share/backend.php b/tests/lib/share/backend.php index 2f6c84678f..420bd9d88b 100644 --- a/tests/lib/share/backend.php +++ b/tests/lib/share/backend.php @@ -26,7 +26,7 @@ class Test_Share_Backend implements OCP\Share_Backend { const FORMAT_SOURCE = 0; const FORMAT_TARGET = 1; const FORMAT_PERMISSIONS = 2; - + private $testItem1 = 'test.txt'; private $testItem2 = 'share.txt'; @@ -57,11 +57,11 @@ class Test_Share_Backend implements OCP\Share_Backend { public function formatItems($items, $format, $parameters = null) { $testItems = array(); foreach ($items as $item) { - if ($format == self::FORMAT_SOURCE) { + if ($format === self::FORMAT_SOURCE) { $testItems[] = $item['item_source']; - } else if ($format == self::FORMAT_TARGET) { + } else if ($format === self::FORMAT_TARGET) { $testItems[] = $item['item_target']; - } else if ($format == self::FORMAT_PERMISSIONS) { + } else if ($format === self::FORMAT_PERMISSIONS) { $testItems[] = $item['permissions']; } } diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index a89f100d97..b5cba9430a 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -622,21 +622,21 @@ class Test_Share extends PHPUnit_Framework_TestCase { OC_User::setUserId($this->user1); $this->assertEquals( array('test.txt', 'test.txt'), - OCP\Share::getItemsShared('test', 'test.txt'), + OCP\Share::getItemsShared('test', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that the test.txt file is shared exactly two times by user1.' ); OC_User::setUserId($this->user2); $this->assertEquals( array('test.txt'), - OCP\Share::getItemsShared('test', 'test.txt'), + OCP\Share::getItemsShared('test', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that the test.txt file is shared exactly once by user2.' ); OC_User::setUserId($this->user3); $this->assertEquals( array('test.txt'), - OCP\Share::getItemsShared('test', 'test.txt'), + OCP\Share::getItemsShared('test', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that the test.txt file is shared exactly once by user3.' );