diff options
-rw-r--r-- | apps/files/ajax/newfile.php | 3 | ||||
-rw-r--r-- | apps/files/js/fileactions.js | 1 | ||||
-rw-r--r-- | apps/files_encryption/settings-personal.php | 1 | ||||
-rw-r--r-- | apps/files_external/js/settings.js | 4 | ||||
-rw-r--r-- | core/templates/layout.base.php | 2 | ||||
-rw-r--r-- | lib/private/contactsmanager.php | 8 | ||||
-rw-r--r-- | tests/lib/contactsmanager.php | 209 |
7 files changed, 220 insertions, 8 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php index b4d91514a2a..c162237fe92 100644 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -120,6 +120,9 @@ if($source) { $freeSpace = $storageStats['freeSpace']; foreach($meta['wrapper_data'] as $header) { + if (strpos($header, ':') === false){ + continue; + } list($name, $value) = explode(':', $header); if ('content-length' === strtolower(trim($name))) { $length = (int) trim($value); diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 4334daa7556..da48cf29be0 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -264,6 +264,7 @@ _renderRenameAction: function(actionSpec, isDefault, context) { var $actionEl = this._makeActionLink(actionSpec, context); var $container = context.$file.find('a.name span.nametext'); + $actionEl.find('img').attr('alt', t('files', 'Rename')); $container.find('.action-rename').remove(); $container.append($actionEl); return $actionEl; diff --git a/apps/files_encryption/settings-personal.php b/apps/files_encryption/settings-personal.php index 966556f6f94..834bac611ad 100644 --- a/apps/files_encryption/settings-personal.php +++ b/apps/files_encryption/settings-personal.php @@ -28,7 +28,6 @@ $result = false; if ($recoveryAdminEnabled || !$privateKeySet) {
\OCP\Util::addscript('files_encryption', 'settings-personal');
- \OCP\Util::addScript('settings', 'personal');
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
$tmpl->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 75d45ae1924..ee3d0b736da 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -468,14 +468,14 @@ $(document).ready(function() { OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no'); $('#userMountingBackends').addClass('hidden'); } - OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}}); + OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('files_external', 'Saved')}}); }); $('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() { OC.msg.startSaving('#userMountingMsg'); var userMountingBackends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){return $(this).val();}).get(); OC.AppConfig.setValue('files_external', 'user_mounting_backends', userMountingBackends.join()); - OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}}); + OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('files_external', 'Saved')}}); // disable allowUserMounting if(userMountingBackends.length === 0) { diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index 2b496c23246..96229fd370a 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -6,7 +6,7 @@ <!--[if gt IE 9]><html class="ng-csp ie" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]--> <!--[if !IE]><!--><html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><!--<![endif]--> - <head> + <head data-requesttoken="<?php p($_['requesttoken']); ?>"> <title> <?php p($theme->getTitle()); ?> </title> diff --git a/lib/private/contactsmanager.php b/lib/private/contactsmanager.php index 737fc4f0e3a..527b603ac38 100644 --- a/lib/private/contactsmanager.php +++ b/lib/private/contactsmanager.php @@ -63,10 +63,10 @@ namespace OC { } if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { - return null; + return $addressBook->delete($id); } - return $addressBook->delete($id); + return null; } /** @@ -84,10 +84,10 @@ namespace OC { } if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { - return null; + return $addressBook->createOrUpdate($properties); } - return $addressBook->createOrUpdate($properties); + return null; } /** diff --git a/tests/lib/contactsmanager.php b/tests/lib/contactsmanager.php new file mode 100644 index 00000000000..39e44cc6302 --- /dev/null +++ b/tests/lib/contactsmanager.php @@ -0,0 +1,209 @@ +<?php + + +class Test_ContactsManager extends \Test\TestCase { + + /** @var \OC\ContactsManager */ + private $cm; + + protected function setUp() { + parent::setUp(); + $this->cm = new \OC\ContactsManager(); + } + + public function searchProvider(){ + $search1 = array( + 0 => array( + 'N' => array(0 => '', 1 => 'Jan', 2 => 'Jansen', 3 => '', 4 => '',), + 'UID' => '04ada7f5-01f9-4309-9c82-6b555b2170ed', + 'FN' => 'Jan Jansen', + 'id' => '1', + 'addressbook-key' => 'simple:1', + ), + 0 => array( + 'N' => array(0 => '', 1 => 'Tom', 2 => 'Peeters', 3 => '', 4 => '',), + 'UID' => '04ada7f5-01f9-4309-9c82-2345-2345--6b555b2170ed', + 'FN' => 'Tom Peeters', + 'id' => '2', + 'addressbook-key' => 'simple:1', + ), + ); + + $search2 = array( + 0 => array( + 'N' => array(0 => '', 1 => 'fg', 2 => '', 3 => '', 4 => '',), + 'UID' => '04ada234h5jh357f5-01f9-4309-9c82-6b555b2170ed', + 'FN' => 'Jan Rompuy', + 'id' => '1', + 'addressbook-key' => 'simple:2', + ), + 0 => array( + 'N' => array(0 => '', 1 => 'fg', 2 => '', 3 => '', 4 => '',), + 'UID' => '04ada7f5-01f9-4309-345kj345j9c82-2345-2345--6b555b2170ed', + 'FN' => 'Tim Peeters', + 'id' => '2', + 'addressbook-key' => 'simple:2', + ), + ); + + $expectedResult = array_merge($search1, $search2); + return array( + array( + $search1, + $search2, + $expectedResult + ) + ); + } + + /** + * @dataProvider searchProvider + */ + public function testSearch($search1, $search2, $expectedResult ){ + $addressbook1 = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook1->expects($this->once()) + ->method('search') + ->willReturn($search1); + + $addressbook1->expects($this->any()) + ->method('getKey') + ->willReturn('simple:1'); + + $addressbook2 = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook2->expects($this->once()) + ->method('search') + ->willReturn($search2); + + $addressbook2->expects($this->any()) + ->method('getKey') + ->willReturn('simple:2'); + + + $this->cm->registerAddressBook($addressbook1); + $this->cm->registerAddressBook($addressbook2); + $result = $this->cm->search(''); + $this->assertEquals($expectedResult, $result); + } + + + public function testDeleteHavePermission(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook->expects($this->any()) + ->method('getPermissions') + ->willReturn(\OCP\Constants::PERMISSION_ALL); + + $addressbook->expects($this->once()) + ->method('delete') + ->willReturn('returnMe'); + + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->delete(1, $addressbook->getKey()); + $this->assertEquals($result, 'returnMe'); + } + + public function testDeleteNoPermission(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook->expects($this->any()) + ->method('getPermissions') + ->willReturn(\OCP\Constants::PERMISSION_READ); + + $addressbook->expects($this->never()) + ->method('delete'); + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->delete(1, $addressbook->getKey()); + $this->assertEquals($result, null); + } + + public function testDeleteNoAddressbook(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook->expects($this->never()) + ->method('delete'); + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->delete(1, 'noaddressbook'); + $this->assertEquals($result, null); + + } + + public function testCreateOrUpdateHavePermission(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook->expects($this->any()) + ->method('getPermissions') + ->willReturn(\OCP\Constants::PERMISSION_ALL); + + $addressbook->expects($this->once()) + ->method('createOrUpdate') + ->willReturn('returnMe'); + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->createOrUpdate(array(), $addressbook->getKey()); + $this->assertEquals($result, 'returnMe'); + } + + public function testCreateOrUpdateNoPermission(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook->expects($this->any()) + ->method('getPermissions') + ->willReturn(\OCP\Constants::PERMISSION_READ); + + $addressbook->expects($this->never()) + ->method('createOrUpdate'); + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->createOrUpdate(array(), $addressbook->getKey()); + $this->assertEquals($result, null); + + } + + public function testCreateOrUpdateNOAdressbook(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $addressbook->expects($this->never()) + ->method('createOrUpdate'); + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->createOrUpdate(array(), 'noaddressbook'); + $this->assertEquals($result, null); + } + + public function testIsEnabledIfNot(){ + $result = $this->cm->isEnabled(); + $this->assertFalse($result); + } + + public function testIsEnabledIfSo(){ + $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + ->disableOriginalConstructor() + ->getMock(); + + $this->cm->registerAddressBook($addressbook); + $result = $this->cm->isEnabled(); + $this->assertTrue($result); + } + +}
\ No newline at end of file |