diff options
51 files changed, 294 insertions, 242 deletions
diff --git a/apps/files/css/detailsView.css b/apps/files/css/detailsView.css index ea9d48b470c..8acf884f219 100644 --- a/apps/files/css/detailsView.css +++ b/apps/files/css/detailsView.css @@ -71,17 +71,14 @@ #app-sidebar .fileName h3 { max-width: 300px; - float:left; + display: inline-block; padding: 5px 0; margin: -5px 0; } #app-sidebar .file-details { - margin-top: 3px; - margin-bottom: 15px; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; opacity: .5; - float:left; } #app-sidebar .action-favorite { vertical-align: text-bottom; diff --git a/apps/files/js/detailsview.js b/apps/files/js/detailsview.js index 3a775c29ec6..b01f9cea610 100644 --- a/apps/files/js/detailsview.js +++ b/apps/files/js/detailsview.js @@ -84,7 +84,7 @@ }, _onClose: function(event) { - OC.Apps.hideAppSidebar(); + OC.Apps.hideAppSidebar(this.$el); event.preventDefault(); }, diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index f3f137a0537..d3904f2f6d3 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -594,6 +594,7 @@ this.registerAction({ name: 'Rename', + displayName: t('files', 'Rename'), mime: 'all', permissions: OC.PERMISSION_UPDATE, icon: function() { @@ -614,6 +615,7 @@ this.registerAction({ name: 'Delete', + displayName: t('files', 'Delete'), mime: 'all', // permission is READ because we show a hint instead if there is no permission permissions: OC.PERMISSION_DELETE, diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 2af5be73d96..28bac23ecb0 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -300,12 +300,13 @@ if (this._detailsView) { this.fileActions.registerAction({ name: 'Details', + displayName: t('files', 'Details'), mime: 'all', icon: OC.imagePath('core', 'actions/details'), permissions: OC.PERMISSION_READ, actionHandler: function(fileName, context) { self._updateDetailsView(fileName); - OC.Apps.showAppSidebar(); + OC.Apps.showAppSidebar(self._detailsView.$el); } }); } @@ -380,7 +381,7 @@ if (tabId) { this._detailsView.selectTab(tabId); } - OC.Apps.showAppSidebar(); + OC.Apps.showAppSidebar(this._detailsView.$el); }, /** diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 9f45da9a6e2..23945d52603 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -78,7 +78,7 @@ // register "star" action fileActions.registerAction({ name: 'Favorite', - displayName: 'Favorite', + displayName: t('files', 'Favorite'), mime: 'all', permissions: OC.PERMISSION_READ, type: OCA.Files.FileActions.TYPE_INLINE, diff --git a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php index 3787ef42d9f..1c29b1da736 100644 --- a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php @@ -87,6 +87,11 @@ class SharingCheckMiddleware extends Middleware { return false; } + // Check if the shareAPI is enabled + if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { + return false; + } + // Check whether public sharing is enabled if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { return false; diff --git a/apps/files_sharing/tests/locking.php b/apps/files_sharing/tests/locking.php index 6d13fc1cda5..269c924d142 100644 --- a/apps/files_sharing/tests/locking.php +++ b/apps/files_sharing/tests/locking.php @@ -30,7 +30,7 @@ use OCP\Lock\ILockingProvider; class Locking extends TestCase { /** - * @var \OC_User_Dummy + * @var \Test\Util\User\Dummy */ private $userBackend; @@ -40,7 +40,7 @@ class Locking extends TestCase { public function setUp() { parent::setUp(); - $this->userBackend = new \OC_User_Dummy(); + $this->userBackend = new \Test\Util\User\Dummy(); \OC::$server->getUserManager()->registerBackend($this->userBackend); $this->ownerUid = $this->getUniqueID('owner_'); diff --git a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php index 0db8a1ed5bc..58f4b841339 100644 --- a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php @@ -54,7 +54,13 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { ->will($this->returnValue(true)); $this->config - ->expects($this->once()) + ->expects($this->at(0)) + ->method('getAppValue') + ->with('core', 'shareapi_enabled', 'yes') + ->will($this->returnValue('yes')); + + $this->config + ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'shareapi_allow_links', 'yes') ->will($this->returnValue('yes')); @@ -72,7 +78,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } - public function testIsSharingEnabledWithSharingDisabled() { + public function testIsSharingEnabledWithLinkSharingDisabled() { $this->appManager ->expects($this->once()) ->method('isEnabledForUser') @@ -80,11 +86,34 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { ->will($this->returnValue(true)); $this->config - ->expects($this->once()) + ->expects($this->at(0)) + ->method('getAppValue') + ->with('core', 'shareapi_enabled', 'yes') + ->will($this->returnValue('yes')); + + $this->config + ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'shareapi_allow_links', 'yes') ->will($this->returnValue('no')); $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } + + public function testIsSharingEnabledWithSharingAPIDisabled() { + $this->appManager + ->expects($this->once()) + ->method('isEnabledForUser') + ->with('files_sharing') + ->will($this->returnValue(true)); + + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('core', 'shareapi_enabled', 'yes') + ->will($this->returnValue('no')); + + $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); + } + } diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php index 7533b13f79d..c91734a5b03 100644 --- a/apps/files_sharing/tests/testcase.php +++ b/apps/files_sharing/tests/testcase.php @@ -72,7 +72,7 @@ abstract class TestCase extends \Test\TestCase { \OC::registerShareHooks(); // create users - $backend = new \OC_User_Dummy(); + $backend = new \Test\Util\User\Dummy(); \OC_User::useBackend($backend); $backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1); $backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2); diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js index 473cce88a71..c3be762f095 100644 --- a/apps/files_trashbin/js/app.js +++ b/apps/files_trashbin/js/app.js @@ -59,6 +59,7 @@ OCA.Trashbin.App = { fileActions.registerAction({ name: 'Delete', + displayName: t('files', 'Delete'), mime: 'all', permissions: OC.PERMISSION_READ, icon: function() { diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php index 7cca409ed6c..da214ead60a 100644 --- a/apps/files_versions/tests/versions.php +++ b/apps/files_versions/tests/versions.php @@ -749,7 +749,7 @@ class Test_Files_Versioning extends \Test\TestCase { public static function loginHelper($user, $create = false) { if ($create) { - $backend = new \OC_User_Dummy(); + $backend = new \Test\Util\User\Dummy(); $backend->createUser($user, $user); \OC::$server->getUserManager()->registerBackend($backend); } diff --git a/autotest.sh b/autotest.sh index 243b8df0c6a..cd36193cf6c 100755 --- a/autotest.sh +++ b/autotest.sh @@ -203,8 +203,14 @@ function execute_tests { echo "Waiting for Oracle initialization ... " - # grep exits on the first match and then the script continues - times out after 2 minutes - timeout 240 docker logs -f "$DOCKER_CONTAINER_ID" 2>&1 | grep -q "Grant succeeded." + # Try to connect to the OCI host via sqlplus to ensure that the connection is already running + for i in {1..48} + do + if sqlplus "system/oracle@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=$DATABASEHOST)(Port=1521))(CONNECT_DATA=(SID=XE)))" < /dev/null | grep 'Connected to'; then + break; + fi + sleep 5 + done DATABASEUSER=autotest DATABASENAME='XE' diff --git a/config/config.sample.php b/config/config.sample.php index 8949bd44465..51529cdb0cc 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -609,7 +609,9 @@ $CONFIG = array( /** * ownCloud uses some 3rd party PHP components to provide certain functionality. * These components are shipped as part of the software package and reside in - * ``owncloud/3rdparty``. Use this option to configure a different location. + * ``owncloud/3rdparty``. Use this option to configure a different location. + * For example, if your location is /var/www/owncloud/foo/3rdparty, then the + * correct configuration is '3rdpartyroot' => '/var/www/owncloud/foo/', */ '3rdpartyroot' => '', diff --git a/core/css/multiselect.css b/core/css/multiselect.css index a9451964f59..a4b03319156 100644 --- a/core/css/multiselect.css +++ b/core/css/multiselect.css @@ -33,9 +33,8 @@ ul.multiselectoptions>li { white-space: nowrap; } -ul.multiselectoptions > li > input[type="checkbox"] { - margin: 10px 7px; - vertical-align: middle; +ul.multiselectoptions > li > input[type="checkbox"]+label:before { + margin-left: 7px; } ul.multiselectoptions > li input[type='checkbox']+label { font-weight: normal; diff --git a/core/css/styles.css b/core/css/styles.css index 1a4a4ab4f3d..aefc0ff755a 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -178,6 +178,8 @@ input[type="checkbox"] + label:before { opacity: 0.7; } +input[type="checkbox"]:disabled +label:before { opacity: .6; } + input[type="checkbox"].u-left +label:before { float: left; } input[type="checkbox"].white + label:before { diff --git a/core/js/js.js b/core/js/js.js index de773dc1221..b5971bfc579 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1972,4 +1972,5 @@ jQuery.fn.tipsy = function(argument) { this.tooltip(argument); jQuery.fn.tooltip.call(this, argument); } + return this; } diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index e49ace6df73..af2ad73c51b 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -9,26 +9,23 @@ OC.MimeTypeList={ aliases: { "application/coreldraw": "image", - "application/epub+zip": "text", - "application/font-sfnt": "image", - "application/font-woff": "image", - "application/illustrator": "image", - "application/javascript": "text/code", + "application/font-sfnt": "font", + "application/font-woff": "font", + "application/illustrator": "image/vector", "application/json": "text/code", - "application/msaccess": "file", + "application/msaccess": "database", "application/msexcel": "x-office/spreadsheet", "application/mspowerpoint": "x-office/presentation", "application/msword": "x-office/document", "application/octet-stream": "file", - "application/postscript": "image", - "application/rss+xml": "text/code", + "application/postscript": "image/vector", "application/vnd.android.package-archive": "package/x-generic", "application/vnd.ms-excel": "x-office/spreadsheet", "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", - "application/vnd.ms-fontobject": "image", + "application/vnd.ms-fontobject": "font", "application/vnd.ms-powerpoint": "x-office/presentation", "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", @@ -52,56 +49,48 @@ OC.MimeTypeList={ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", "application/x-7z-compressed": "package/x-generic", - "application/x-cbr": "text", "application/x-compressed": "package/x-generic", "application/x-dcraw": "image", "application/x-deb": "package/x-generic", - "application/x-font": "image", + "application/x-font": "font", "application/x-gimp": "image", "application/x-gzip": "package/x-generic", "application/x-perl": "text/code", "application/x-photoshop": "image", "application/x-php": "text/code", "application/x-rar-compressed": "package/x-generic", - "application/x-shockwave-flash": "application", "application/x-tar": "package/x-generic", "application/x-tex": "text", "application/xml": "text/html", "application/yaml": "text/code", "application/zip": "package/x-generic", - "database": "file", "httpd/unix-directory": "dir", - "image/svg+xml": "image", - "image/vector": "image", + "image/svg+xml": "image/vector", "text/css": "text/code", "text/csv": "x-office/spreadsheet", - "text/html": "text/code", - "text/x-c": "text/code", - "text/x-h": "text/code", - "text/x-python": "text/code", - "text/x-shellscript": "text/code", - "web": "text/code" + "text/x-shellscript": "text/code" }, files: [ - "video", + "application-pdf", + "application", + "audio", + "file", "folder-drag-accept", + "folder-external", "folder-public", + "folder-shared", + "folder-starred", + "folder", + "image", "package-x-generic", - "folder-external", - "text-vcard", - "application", + "text-calendar", "text-code", - "x-office-spreadsheet", - "application-pdf", - "folder", + "text-vcard", + "text", + "video", "x-office-document", - "text-calendar", "x-office-presentation", - "file", - "text", - "folder-shared", - "image", - "audio" + "x-office-spreadsheet" ], themes: [] }; diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php index 3dc3975fb2a..0c647ab44c6 100644 --- a/lib/private/files/type/detection.php +++ b/lib/private/files/type/detection.php @@ -49,15 +49,22 @@ class Detection implements IMimeTypeDetector { private $urlGenerator; /** @var string */ - private $configDir; + private $customConfigDir; + + /** @var string */ + private $defaultConfigDir; /** * @param IURLGenerator $urlGenerator - * @param string $configDir + * @param string $customConfigDir + * @param string $defaultConfigDir */ - public function __construct(IURLGenerator $urlGenerator, $configDir) { + public function __construct(IURLGenerator $urlGenerator, + $customConfigDir, + $defaultConfigDir) { $this->urlGenerator = $urlGenerator; - $this->configDir = $configDir; + $this->customConfigDir = $customConfigDir; + $this->defaultConfigDir = $defaultConfigDir; } /** @@ -71,7 +78,9 @@ class Detection implements IMimeTypeDetector { * @param string $mimetype * @param string|null $secureMimeType */ - public function registerType($extension, $mimetype, $secureMimeType = null) { + public function registerType($extension, + $mimetype, + $secureMimeType = null) { $this->mimetypes[$extension] = array($mimetype, $secureMimeType); $this->secureMimeTypes[$mimetype] = $secureMimeType ?: $mimetype; } @@ -102,10 +111,10 @@ class Detection implements IMimeTypeDetector { return; } - $this->mimeTypeAlias = json_decode(file_get_contents($this->configDir . '/mimetypealiases.dist.json'), true); + $this->mimeTypeAlias = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypealiases.dist.json'), true); - if (file_exists($this->configDir . '/mimetypealiases.json')) { - $custom = json_decode(file_get_contents($this->configDir . '/mimetypealiases.json'), true); + if (file_exists($this->customConfigDir . '/mimetypealiases.json')) { + $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypealiases.json'), true); $this->mimeTypeAlias = array_merge($this->mimeTypeAlias, $custom); } } @@ -126,15 +135,15 @@ class Detection implements IMimeTypeDetector { return; } - $mimetypemapping = json_decode(file_get_contents($this->configDir . '/mimetypemapping.dist.json'), true); + $mimetypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypemapping.dist.json'), true); //Check if need to load custom mappings - if (file_exists($this->configDir . '/mimetypemapping.json')) { - $custom = json_decode(file_get_contents($this->configDir . '/mimetypemapping.json'), true); - $mimetypemapping = array_merge($mimetypemapping, $custom); + if (file_exists($this->customConfigDir . '/mimetypemapping.json')) { + $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypemapping.json'), true); + $mimetypeMapping = array_merge($mimetypeMapping, $custom); } - $this->registerTypeArray($mimetypemapping); + $this->registerTypeArray($mimetypeMapping); } /** diff --git a/lib/private/http/client/client.php b/lib/private/http/client/client.php index b0aff10a413..1907937e55e 100644 --- a/lib/private/http/client/client.php +++ b/lib/private/http/client/client.php @@ -62,7 +62,7 @@ class Client implements IClient { $dataDir = $this->config->getSystemValue('datadirectory'); $this->client->setDefaultOption('verify', $dataDir.'/'.$this->certificateManager->getCertificateBundle()); } else { - $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/config/ca-bundle.crt'); + $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); } $this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler'); diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php index bfa86a6920e..a08357a6024 100644 --- a/lib/private/lock/dblockingprovider.php +++ b/lib/private/lock/dblockingprovider.php @@ -58,9 +58,17 @@ class DBLockingProvider extends AbstractLockingProvider { $this->timeFactory = $timeFactory; } - protected function initLockField($path) { + /** + * Insert a file locking row if it does not exists. + * + * @param string $path + * @param int $lock + * @return int number of inserted rows + */ + + protected function initLockField($path, $lock = 0) { $expire = $this->getExpireTime(); - $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => 0, 'ttl' => $expire], ['key']); + return $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire], ['key']); } /** @@ -98,18 +106,23 @@ class DBLockingProvider extends AbstractLockingProvider { $this->logger->warning("Trying to acquire a lock for '$path' while inside a transition"); } - $this->initLockField($path); $expire = $this->getExpireTime(); if ($type === self::LOCK_SHARED) { - $result = $this->connection->executeUpdate( - 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0', - [$expire, $path] - ); + $result = $this->initLockField($path,1); + if ($result <= 0) { + $result = $this->connection->executeUpdate ( + 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0', + [$expire, $path] + ); + } } else { - $result = $this->connection->executeUpdate( - 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0', - [$expire, $path] - ); + $result = $this->initLockField($path,-1); + if ($result <= 0) { + $result = $this->connection->executeUpdate( + 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0', + [$expire, $path] + ); + } } if ($result !== 1) { throw new LockedException($path); @@ -122,7 +135,6 @@ class DBLockingProvider extends AbstractLockingProvider { * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE */ public function releaseLock($path, $type) { - $this->initLockField($path); if ($type === self::LOCK_SHARED) { $this->connection->executeUpdate( 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` - 1 WHERE `key` = ? AND `lock` > 0', diff --git a/lib/private/preview.php b/lib/private/preview.php index db2a56f9fa5..978da1161c2 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -772,12 +772,6 @@ class Preview { throw new NotFoundException('File not found.'); } - if ($cachedPath = $this->isCached($this->info->getId())) { - header('Content-Type: ' . $this->info->getMimetype()); - $this->userView->readfile($cachedPath); - return; - } - if (is_null($this->preview)) { $this->getPreview(); } diff --git a/lib/private/security/certificatemanager.php b/lib/private/security/certificatemanager.php index 4d470f69a66..ded81863a73 100644 --- a/lib/private/security/certificatemanager.php +++ b/lib/private/security/certificatemanager.php @@ -110,7 +110,7 @@ class CertificateManager implements ICertificateManager { } // Append the default certificates - $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/config/ca-bundle.crt'); + $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); fwrite($fh_certs, $defaultCertificates); fclose($fh_certs); } diff --git a/lib/private/server.php b/lib/private/server.php index d5f4f532c1c..9f99ead849b 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -470,7 +470,9 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('MimeTypeDetector', function(Server $c) { return new \OC\Files\Type\Detection( $c->getURLGenerator(), - \OC::$configDir); + \OC::$SERVERROOT . '/config/', + \OC::$SERVERROOT . '/resources/config/' + ); }); $this->registerService('MimeTypeLoader', function(Server $c) { return new \OC\Files\Type\Loader( diff --git a/lib/private/updater.php b/lib/private/updater.php index 71e9732c307..b33180c3425 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -279,13 +279,6 @@ class Updater extends BasicEmitter { throw new \Exception($e->getMessage()); } - // FIXME: Some users do not upload the new ca-bundle.crt, let's catch this - // in the update. For a newer release we shall use an integrity check after - // the update. - if(!file_exists(\OC::$configDir .'/ca-bundle.crt')) { - throw new \Exception('Please upload the ca-bundle.crt file into the \'config\' directory.'); - } - // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) diff --git a/lib/private/user.php b/lib/private/user.php index e70734ece40..ee1ff6f3766 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -146,6 +146,10 @@ class OC_User { self::$_usedBackends[$backend] = new OC_User_Database(); self::getManager()->registerBackend(self::$_usedBackends[$backend]); break; + case 'dummy': + self::$_usedBackends[$backend] = new \Test\Util\User\Dummy(); + self::getManager()->registerBackend(self::$_usedBackends[$backend]); + break; default: \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG); $className = 'OC_USER_' . strToUpper($backend); diff --git a/config/ca-bundle.crt b/resources/config/ca-bundle.crt index c93d3c4d4a7..c93d3c4d4a7 100644 --- a/config/ca-bundle.crt +++ b/resources/config/ca-bundle.crt diff --git a/config/mimetypealiases.dist.json b/resources/config/mimetypealiases.dist.json index 2c9bdaa00c8..3d6c5edc132 100644 --- a/config/mimetypealiases.dist.json +++ b/resources/config/mimetypealiases.dist.json @@ -1,7 +1,7 @@ { "_comment" : "Array of mimetype aliases.", "_comment2": "Any changes you make here will be overwritten on an update of ownCloud.", - "_comment3": "Put any custom aliases in a new file mimetypealiases.json in this directory", + "_comment3": "Put any custom mappings in a new file mimetypealiases.json in the config/ folder of ownCloud", "_comment4": "After any change to mimetypealiases.json run:", "_comment5": "./occ maintenance:mimetypesjs", diff --git a/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json index 48ec4a56dab..79b0ca65240 100644 --- a/config/mimetypemapping.dist.json +++ b/resources/config/mimetypemapping.dist.json @@ -4,7 +4,7 @@ "_comment3": "and the second (if present] is a secure alternative", "_comment4": "Any changes you make here will be overwritten on an update of ownCloud", - "_comment5": "Put any custom mappings in a new file mimetypemapping.json in this directory", + "_comment5": "Put any custom mappings in a new file mimetypemapping.json in the config/ folder of ownCloud", "3gp": ["video/3gpp"], diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 94001291d86..b5f186c5416 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -60,7 +60,7 @@ class FileCache extends \Test_Cache { \OC_Config::setValue('cachedirectory', $datadir); \OC_User::clearBackends(); - \OC_User::useBackend(new \OC_User_Dummy()); + \OC_User::useBackend(new \Test\Util\User\Dummy()); //login \OC_User::createUser('test', 'test'); diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php index c3d364d6800..1a11b29cf00 100644 --- a/tests/lib/files/etagtest.php +++ b/tests/lib/files/etagtest.php @@ -17,7 +17,7 @@ class EtagTest extends \Test\TestCase { private $tmpDir; /** - * @var \OC_User_Dummy $userBackend + * @var \Test\Util\User\Dummy $userBackend */ private $userBackend; @@ -35,7 +35,7 @@ class EtagTest extends \Test\TestCase { $this->tmpDir = \OC_Helper::tmpFolder(); \OC_Config::setValue('datadirectory', $this->tmpDir); - $this->userBackend = new \OC_User_Dummy(); + $this->userBackend = new \Test\Util\User\Dummy(); \OC_User::useBackend($this->userBackend); } diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index b7061bd19a0..cc01ed70b5d 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -72,7 +72,7 @@ class Filesystem extends \Test\TestCase { protected function setUp() { parent::setUp(); - $userBackend = new \OC_User_Dummy(); + $userBackend = new \Test\Util\User\Dummy(); $userBackend->createUser(self::TEST_FILESYSTEM_USER1, self::TEST_FILESYSTEM_USER1); $userBackend->createUser(self::TEST_FILESYSTEM_USER2, self::TEST_FILESYSTEM_USER2); \OC::$server->getUserManager()->registerBackend($userBackend); @@ -274,7 +274,7 @@ class Filesystem extends \Test\TestCase { $user = \OC_User::getUser(); } else { $user = self::TEST_FILESYSTEM_USER1; - $backend = new \OC_User_Dummy(); + $backend = new \Test\Util\User\Dummy(); \OC_User::useBackend($backend); $backend->createUser($user, $user); $userObj = \OC::$server->getUserManager()->get($user); diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php index e3b8019b4ca..c431a2eb366 100644 --- a/tests/lib/files/node/file.php +++ b/tests/lib/files/node/file.php @@ -18,7 +18,7 @@ class File extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->user = new \OC\User\User('', new \OC_User_Dummy); + $this->user = new \OC\User\User('', new \Test\Util\User\Dummy); } protected function getFileInfo($data) { diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php index 96795cb02ef..b30f352847d 100644 --- a/tests/lib/files/node/folder.php +++ b/tests/lib/files/node/folder.php @@ -21,7 +21,7 @@ class Folder extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->user = new \OC\User\User('', new \OC_User_Dummy); + $this->user = new \OC\User\User('', new \Test\Util\User\Dummy); } protected function getFileInfo($data) { diff --git a/tests/lib/files/node/integration.php b/tests/lib/files/node/integration.php index 2d5ccd1fb85..5580b40a126 100644 --- a/tests/lib/files/node/integration.php +++ b/tests/lib/files/node/integration.php @@ -36,7 +36,7 @@ class IntegrationTests extends \Test\TestCase { \OC_Hook::clear('OC_Filesystem'); - $user = new User($this->getUniqueID('user'), new \OC_User_Dummy); + $user = new User($this->getUniqueID('user'), new \Test\Util\User\Dummy); $this->loginAsUser($user->getUID()); $this->view = new View(); diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php index 01ed84c4a06..afcf4cbabaa 100644 --- a/tests/lib/files/node/node.php +++ b/tests/lib/files/node/node.php @@ -15,7 +15,7 @@ class Node extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->user = new \OC\User\User('', new \OC_User_Dummy); + $this->user = new \OC\User\User('', new \Test\Util\User\Dummy); } protected function getFileInfo($data) { diff --git a/tests/lib/files/node/root.php b/tests/lib/files/node/root.php index a763428209c..4b1aea1da4e 100644 --- a/tests/lib/files/node/root.php +++ b/tests/lib/files/node/root.php @@ -17,7 +17,7 @@ class Root extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->user = new \OC\User\User('', new \OC_User_Dummy); + $this->user = new \OC\User\User('', new \Test\Util\User\Dummy); } protected function getFileInfo($data) { diff --git a/tests/lib/files/type/detection.php b/tests/lib/files/type/detection.php index 1997fa4dfd6..5800f4eb8e3 100644 --- a/tests/lib/files/type/detection.php +++ b/tests/lib/files/type/detection.php @@ -19,58 +19,64 @@ * */ -namespace OC\Files\Type; +namespace Test\Files\Type; use \OC\Files\Type\Detection; class DetectionTest extends \Test\TestCase { + /** @var Detection */ + private $detection; + + public function setUp() { + parent::setUp(); + $this->detection = new Detection( + \OC::$server->getURLGenerator(), + \OC::$SERVERROOT . '/config/', + \OC::$SERVERROOT . '/resources/config/' + ); + } public function testDetect() { - $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir); $dir = \OC::$SERVERROOT.'/tests/data'; - $result = $detection->detect($dir."/"); + $result = $this->detection->detect($dir."/"); $expected = 'httpd/unix-directory'; $this->assertEquals($expected, $result); - $result = $detection->detect($dir."/data.tar.gz"); + $result = $this->detection->detect($dir."/data.tar.gz"); $expected = 'application/x-gzip'; $this->assertEquals($expected, $result); - $result = $detection->detect($dir."/data.zip"); + $result = $this->detection->detect($dir."/data.zip"); $expected = 'application/zip'; $this->assertEquals($expected, $result); - $result = $detection->detect($dir."/testimagelarge.svg"); + $result = $this->detection->detect($dir."/testimagelarge.svg"); $expected = 'image/svg+xml'; $this->assertEquals($expected, $result); - $result = $detection->detect($dir."/testimage.png"); + $result = $this->detection->detect($dir."/testimage.png"); $expected = 'image/png'; $this->assertEquals($expected, $result); } public function testGetSecureMimeType() { - $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir); - - $result = $detection->getSecureMimeType('image/svg+xml'); + $result = $this->detection->getSecureMimeType('image/svg+xml'); $expected = 'text/plain'; $this->assertEquals($expected, $result); - $result = $detection->getSecureMimeType('image/png'); + $result = $this->detection->getSecureMimeType('image/png'); $expected = 'image/png'; $this->assertEquals($expected, $result); } public function testDetectPath() { - $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir); - - $this->assertEquals('text/plain', $detection->detectPath('foo.txt')); - $this->assertEquals('image/png', $detection->detectPath('foo.png')); - $this->assertEquals('image/png', $detection->detectPath('foo.bar.png')); - $this->assertEquals('application/octet-stream', $detection->detectPath('.png')); - $this->assertEquals('application/octet-stream', $detection->detectPath('foo')); - $this->assertEquals('application/octet-stream', $detection->detectPath('')); + $this->assertEquals('text/plain', $this->detection->detectPath('foo.txt')); + $this->assertEquals('image/png', $this->detection->detectPath('foo.png')); + $this->assertEquals('image/png', $this->detection->detectPath('foo.bar.png')); + $this->assertEquals('application/octet-stream', $this->detection->detectPath('.png')); + $this->assertEquals('application/octet-stream', $this->detection->detectPath('foo')); + $this->assertEquals('application/octet-stream', $this->detection->detectPath('')); } public function testDetectString() { @@ -78,16 +84,14 @@ class DetectionTest extends \Test\TestCase { $this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows'); } - $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir); - - $result = $detection->detectString("/data/data.tar.gz"); + $result = $this->detection->detectString("/data/data.tar.gz"); $expected = 'text/plain; charset=us-ascii'; $this->assertEquals($expected, $result); } public function testMimeTypeIcon() { if (!class_exists('org\\bovigo\\vfs\\vfsStream')) { - $this->markTestSkipped('Pacakge vfsStream not installed'); + $this->markTestSkipped('Package vfsStream not installed'); } $confDir = \org\bovigo\vfs\vfsStream::setup(); $mimetypealiases_dist = \org\bovigo\vfs\vfsStream::newFile('mimetypealiases.dist.json')->at($confDir); @@ -111,7 +115,7 @@ class DetectionTest extends \Test\TestCase { ->with($this->equalTo('core'), $this->equalTo('filetypes/folder.png')) ->willReturn('folder.svg'); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('dir'); $this->assertEquals('folder.svg', $mimeType); @@ -130,7 +134,7 @@ class DetectionTest extends \Test\TestCase { ->with($this->equalTo('core'), $this->equalTo('filetypes/folder-shared.png')) ->willReturn('folder-shared.svg'); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('dir-shared'); $this->assertEquals('folder-shared.svg', $mimeType); @@ -150,7 +154,7 @@ class DetectionTest extends \Test\TestCase { ->with($this->equalTo('core'), $this->equalTo('filetypes/folder-external.png')) ->willReturn('folder-external.svg'); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('dir-external'); $this->assertEquals('folder-external.svg', $mimeType); @@ -170,7 +174,7 @@ class DetectionTest extends \Test\TestCase { ->with($this->equalTo('core'), $this->equalTo('filetypes/my-type.png')) ->willReturn('my-type.svg'); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('my-type'); $this->assertEquals('my-type.svg', $mimeType); @@ -200,7 +204,7 @@ class DetectionTest extends \Test\TestCase { } )); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('my-type'); $this->assertEquals('my.svg', $mimeType); @@ -231,7 +235,7 @@ class DetectionTest extends \Test\TestCase { } )); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('foo-bar'); $this->assertEquals('file.svg', $mimeType); @@ -250,7 +254,7 @@ class DetectionTest extends \Test\TestCase { ->with($this->equalTo('core'), $this->equalTo('filetypes/foo-bar.png')) ->willReturn('foo-bar.svg'); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('foo-bar'); $this->assertEquals('foo-bar.svg', $mimeType); $mimeType = $detection->mimeTypeIcon('foo-bar'); @@ -276,7 +280,7 @@ class DetectionTest extends \Test\TestCase { ->with($this->equalTo('core'), $this->equalTo('filetypes/foobar-baz.png')) ->willReturn('foobar-baz.svg'); - $detection = new Detection($urlGenerator, $confDir->url()); + $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('foo'); $this->assertEquals('foobar-baz.svg', $mimeType); } diff --git a/tests/lib/files/utils/scanner.php b/tests/lib/files/utils/scanner.php index 75cd75ee3f5..5492774f42e 100644 --- a/tests/lib/files/utils/scanner.php +++ b/tests/lib/files/utils/scanner.php @@ -42,14 +42,14 @@ class TestScanner extends \OC\Files\Utils\Scanner { class Scanner extends \Test\TestCase { /** - * @var \OC_User_Dummy + * @var \Test\Util\User\Dummy */ private $userBackend; protected function setUp() { parent::setUp(); - $this->userBackend = new \OC_User_Dummy(); + $this->userBackend = new \Test\Util\User\Dummy(); \OC::$server->getUserManager()->registerBackend($this->userBackend); $this->loginAsUser(); } diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 618f29fc6f2..83f53833855 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -68,7 +68,7 @@ class View extends \Test\TestCase { \OC_Hook::clear(); \OC_User::clearBackends(); - \OC_User::useBackend(new \OC_User_Dummy()); + \OC_User::useBackend(new \Test\Util\User\Dummy()); //login $userManager = \OC::$server->getUserManager(); diff --git a/tests/lib/group.php b/tests/lib/group.php index 795de695513..066dddc738e 100644 --- a/tests/lib/group.php +++ b/tests/lib/group.php @@ -30,7 +30,7 @@ class Test_Group extends \Test\TestCase { } public function testSingleBackend() { - $userBackend = new \OC_User_Dummy(); + $userBackend = new \Test\Util\User\Dummy(); \OC_User::getManager()->registerBackend($userBackend); OC_Group::useBackend(new OC_Group_Dummy()); @@ -112,7 +112,7 @@ class Test_Group extends \Test\TestCase { public function testUsersInGroup() { OC_Group::useBackend(new OC_Group_Dummy()); - $userBackend = new \OC_User_Dummy(); + $userBackend = new \Test\Util\User\Dummy(); \OC_User::getManager()->registerBackend($userBackend); $group1 = $this->getUniqueID(); @@ -141,7 +141,7 @@ class Test_Group extends \Test\TestCase { } public function testMultiBackend() { - $userBackend = new \OC_User_Dummy(); + $userBackend = new \Test\Util\User\Dummy(); \OC_User::getManager()->registerBackend($userBackend); $backend1 = new OC_Group_Dummy(); $backend2 = new OC_Group_Dummy(); diff --git a/tests/lib/preview.php b/tests/lib/preview.php index 82ee8e2eca2..9e118014bac 100644 --- a/tests/lib/preview.php +++ b/tests/lib/preview.php @@ -61,7 +61,7 @@ class Preview extends TestCase { $userManager = \OC::$server->getUserManager(); $userManager->clearBackends(); - $backend = new \OC_User_Dummy(); + $backend = new \Test\Util\User\Dummy(); $userManager->registerBackend($backend); $backend->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1); $this->loginAsUser(self::TEST_PREVIEW_USER1); diff --git a/tests/lib/preview/provider.php b/tests/lib/preview/provider.php index 02459b83bb3..5377f30df82 100644 --- a/tests/lib/preview/provider.php +++ b/tests/lib/preview/provider.php @@ -49,7 +49,7 @@ abstract class Provider extends \Test\TestCase { $userManager = \OC::$server->getUserManager(); $userManager->clearBackends(); - $backend = new \OC_User_Dummy(); + $backend = new \Test\Util\User\Dummy(); $userManager->registerBackend($backend); $userId = $this->getUniqueID(); diff --git a/tests/lib/traits/usertrait.php b/tests/lib/traits/usertrait.php index 401d8b8a832..229087a5200 100644 --- a/tests/lib/traits/usertrait.php +++ b/tests/lib/traits/usertrait.php @@ -13,7 +13,7 @@ namespace Test\Traits; */ trait UserTrait { /** - * @var \OC_User_Dummy|\OCP\UserInterface + * @var \Test\Util\User\Dummy|\OCP\UserInterface */ protected $userBackend; @@ -22,7 +22,7 @@ trait UserTrait { } protected function setUpUserTrait() { - $this->userBackend = new \OC_User_Dummy(); + $this->userBackend = new \Test\Util\User\Dummy(); \OC::$server->getUserManager()->registerBackend($this->userBackend); } diff --git a/tests/lib/user.php b/tests/lib/user.php index cb0c661b2a4..3c068be2826 100644 --- a/tests/lib/user.php +++ b/tests/lib/user.php @@ -18,7 +18,7 @@ class User extends TestCase { protected function setUp(){ parent::setUp(); - $this->backend = $this->getMock('\OC_User_Dummy'); + $this->backend = $this->getMock('\Test\Util\User\Dummy'); $manager = \OC_User::getManager(); $manager->registerBackend($this->backend); } diff --git a/tests/lib/user/avataruserdummy.php b/tests/lib/user/avataruserdummy.php index 738b10492ea..086adb6043f 100644 --- a/tests/lib/user/avataruserdummy.php +++ b/tests/lib/user/avataruserdummy.php @@ -20,7 +20,7 @@ * */ -class Avatar_User_Dummy extends \OC_User_Dummy { +class Avatar_User_Dummy extends \Test\Util\User\Dummy { public function canChangeAvatar($uid) { return true; } diff --git a/tests/lib/user/dummy.php b/tests/lib/user/dummy.php index fcc921de4b1..c6c79d7a860 100644 --- a/tests/lib/user/dummy.php +++ b/tests/lib/user/dummy.php @@ -23,6 +23,6 @@ class Test_User_Dummy extends Test_User_Backend { protected function setUp() { parent::setUp(); - $this->backend=new OC_User_Dummy(); + $this->backend=new \Test\Util\User\Dummy(); } } diff --git a/tests/lib/user/manager.php b/tests/lib/user/manager.php index cc8bcd65896..df673f581c4 100644 --- a/tests/lib/user/manager.php +++ b/tests/lib/user/manager.php @@ -11,7 +11,7 @@ namespace Test\User; class Manager extends \Test\TestCase { public function testGetBackends() { - $userDummyBackend = $this->getMock('\OC_User_Dummy'); + $userDummyBackend = $this->getMock('\Test\Util\User\Dummy'); $manager = new \OC\User\Manager(); $manager->registerBackend($userDummyBackend); $this->assertEquals([$userDummyBackend], $manager->getBackends()); @@ -23,9 +23,9 @@ class Manager extends \Test\TestCase { public function testUserExistsSingleBackendExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) @@ -39,9 +39,9 @@ class Manager extends \Test\TestCase { public function testUserExistsSingleBackendNotExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) @@ -61,18 +61,18 @@ class Manager extends \Test\TestCase { public function testUserExistsTwoBackendsSecondExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 */ - $backend1 = $this->getMock('\OC_User_Dummy'); + $backend1 = $this->getMock('\Test\Util\User\Dummy'); $backend1->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) ->will($this->returnValue(false)); /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 */ - $backend2 = $this->getMock('\OC_User_Dummy'); + $backend2 = $this->getMock('\Test\Util\User\Dummy'); $backend2->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) @@ -87,18 +87,18 @@ class Manager extends \Test\TestCase { public function testUserExistsTwoBackendsFirstExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 */ - $backend1 = $this->getMock('\OC_User_Dummy'); + $backend1 = $this->getMock('\Test\Util\User\Dummy'); $backend1->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) ->will($this->returnValue(true)); /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 */ - $backend2 = $this->getMock('\OC_User_Dummy'); + $backend2 = $this->getMock('\Test\Util\User\Dummy'); $backend2->expects($this->never()) ->method('userExists'); @@ -113,7 +113,7 @@ class Manager extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('checkPassword') ->with($this->equalTo('foo'), $this->equalTo('bar')) @@ -140,7 +140,7 @@ class Manager extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->never()) ->method('checkPassword'); @@ -156,9 +156,9 @@ class Manager extends \Test\TestCase { public function testGetOneBackendExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) @@ -172,9 +172,9 @@ class Manager extends \Test\TestCase { public function testGetOneBackendNotExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) @@ -188,9 +188,9 @@ class Manager extends \Test\TestCase { public function testSearchOneBackend() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('getUsers') ->with($this->equalTo('fo')) @@ -207,18 +207,18 @@ class Manager extends \Test\TestCase { public function testSearchTwoBackendLimitOffset() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 */ - $backend1 = $this->getMock('\OC_User_Dummy'); + $backend1 = $this->getMock('\Test\Util\User\Dummy'); $backend1->expects($this->once()) ->method('getUsers') ->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1)) ->will($this->returnValue(array('foo1', 'foo2'))); /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 */ - $backend2 = $this->getMock('\OC_User_Dummy'); + $backend2 = $this->getMock('\Test\Util\User\Dummy'); $backend2->expects($this->once()) ->method('getUsers') ->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1)) @@ -237,9 +237,9 @@ class Manager extends \Test\TestCase { public function testCreateUserSingleBackendNotExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') ->will($this->returnValue(true)); @@ -265,9 +265,9 @@ class Manager extends \Test\TestCase { */ public function testCreateUserSingleBackendExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') ->will($this->returnValue(true)); @@ -288,9 +288,9 @@ class Manager extends \Test\TestCase { public function testCreateUserSingleBackendNotSupported() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') ->will($this->returnValue(false)); @@ -320,9 +320,9 @@ class Manager extends \Test\TestCase { */ public function testCreateUserTwoBackendExists() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1 */ - $backend1 = $this->getMock('\OC_User_Dummy'); + $backend1 = $this->getMock('\Test\Util\User\Dummy'); $backend1->expects($this->any()) ->method('implementsActions') ->will($this->returnValue(true)); @@ -336,9 +336,9 @@ class Manager extends \Test\TestCase { ->will($this->returnValue(false)); /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 */ - $backend2 = $this->getMock('\OC_User_Dummy'); + $backend2 = $this->getMock('\Test\Util\User\Dummy'); $backend2->expects($this->any()) ->method('implementsActions') ->will($this->returnValue(true)); @@ -368,9 +368,9 @@ class Manager extends \Test\TestCase { public function testCountUsersOneBackend() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('countUsers') ->will($this->returnValue(7)); @@ -382,14 +382,14 @@ class Manager extends \Test\TestCase { $backend->expects($this->once()) ->method('getBackendName') - ->will($this->returnValue('Mock_OC_User_Dummy')); + ->will($this->returnValue('Mock_Test_Util_User_Dummy')); $manager = new \OC\User\Manager(); $manager->registerBackend($backend); $result = $manager->countUsers(); $keys = array_keys($result); - $this->assertTrue(strpos($keys[0], 'Mock_OC_User_Dummy') !== false); + $this->assertTrue(strpos($keys[0], 'Mock_Test_Util_User_Dummy') !== false); $users = array_shift($result); $this->assertEquals(7, $users); @@ -397,9 +397,9 @@ class Manager extends \Test\TestCase { public function testCountUsersTwoBackends() { /** - * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend + * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend1 = $this->getMock('\OC_User_Dummy'); + $backend1 = $this->getMock('\Test\Util\User\Dummy'); $backend1->expects($this->once()) ->method('countUsers') ->will($this->returnValue(7)); @@ -410,9 +410,9 @@ class Manager extends \Test\TestCase { ->will($this->returnValue(true)); $backend1->expects($this->once()) ->method('getBackendName') - ->will($this->returnValue('Mock_OC_User_Dummy')); + ->will($this->returnValue('Mock_Test_Util_User_Dummy')); - $backend2 = $this->getMock('\OC_User_Dummy'); + $backend2 = $this->getMock('\Test\Util\User\Dummy'); $backend2->expects($this->once()) ->method('countUsers') ->will($this->returnValue(16)); @@ -423,7 +423,7 @@ class Manager extends \Test\TestCase { ->will($this->returnValue(true)); $backend2->expects($this->once()) ->method('getBackendName') - ->will($this->returnValue('Mock_OC_User_Dummy')); + ->will($this->returnValue('Mock_Test_Util_User_Dummy')); $manager = new \OC\User\Manager(); $manager->registerBackend($backend1); @@ -433,7 +433,7 @@ class Manager extends \Test\TestCase { //because the backends have the same class name, only one value expected $this->assertEquals(1, count($result)); $keys = array_keys($result); - $this->assertTrue(strpos($keys[0], 'Mock_OC_User_Dummy') !== false); + $this->assertTrue(strpos($keys[0], 'Mock_Test_Util_User_Dummy') !== false); $users = array_shift($result); //users from backends shall be summed up @@ -442,7 +442,7 @@ class Manager extends \Test\TestCase { public function testDeleteUser() { $manager = new \OC\User\Manager(); - $backend = new \OC_User_Dummy(); + $backend = new \Test\Util\User\Dummy(); $backend->createUser('foo', 'bar'); $manager->registerBackend($backend); diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index 4dc7f29c5b8..d9dace2ef05 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -20,7 +20,7 @@ class Session extends \Test\TestCase { ->with('user_id') ->will($this->returnValue('foo')); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('userExists') ->with('foo') @@ -41,7 +41,7 @@ class Session extends \Test\TestCase { ->with('user_id') ->will($this->returnValue('foo')); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('userExists') ->with('foo') @@ -62,7 +62,7 @@ class Session extends \Test\TestCase { ->with('user_id') ->will($this->returnValue(null)); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->never()) ->method('userExists'); @@ -82,7 +82,7 @@ class Session extends \Test\TestCase { $manager = $this->getMock('\OC\User\Manager'); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); $user->expects($this->once()) @@ -122,7 +122,7 @@ class Session extends \Test\TestCase { } $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); $user->expects($this->once()) @@ -161,7 +161,7 @@ class Session extends \Test\TestCase { } $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); $user->expects($this->once()) @@ -196,7 +196,7 @@ class Session extends \Test\TestCase { } $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); $user->expects($this->never()) @@ -220,7 +220,7 @@ class Session extends \Test\TestCase { $manager = $this->getMock('\OC\User\Manager'); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $manager->expects($this->once()) ->method('checkPassword') @@ -257,7 +257,7 @@ class Session extends \Test\TestCase { } $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); @@ -305,7 +305,7 @@ class Session extends \Test\TestCase { } $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); @@ -347,7 +347,7 @@ class Session extends \Test\TestCase { } $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); - $backend = $this->getMock('OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php index b1df975b60f..bc1365d35bf 100644 --- a/tests/lib/user/user.php +++ b/tests/lib/user/user.php @@ -74,7 +74,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('setPassword') ->with($this->equalTo('foo'), $this->equalTo('bar')); @@ -97,7 +97,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->never()) ->method('setPassword'); @@ -182,7 +182,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('deleteUser') ->with($this->equalTo('foo')); @@ -195,7 +195,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('getHome') ->with($this->equalTo('foo')) @@ -216,7 +216,7 @@ class User extends \Test\TestCase { } public function testGetBackendClassName() { - $user = new \OC\User\User('foo', new \OC_User_Dummy()); + $user = new \OC\User\User('foo', new \Test\Util\User\Dummy()); $this->assertEquals('Dummy', $user->getBackendClassName()); $user = new \OC\User\User('foo', new \OC_User_Database()); $this->assertEquals('Database', $user->getBackendClassName()); @@ -226,7 +226,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->never()) ->method('getHome'); @@ -253,7 +253,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') @@ -273,7 +273,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') @@ -287,7 +287,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') @@ -307,7 +307,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->any()) ->method('implementsActions') @@ -393,7 +393,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('setPassword'); @@ -434,7 +434,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Dummy'); + $backend = $this->getMock('\Test\Util\User\Dummy'); $backend->expects($this->once()) ->method('deleteUser'); diff --git a/lib/private/user/dummy.php b/tests/lib/util/user/dummy.php index 3779f7b5ddf..6e23e22ab67 100644 --- a/lib/private/user/dummy.php +++ b/tests/lib/util/user/dummy.php @@ -25,10 +25,14 @@ * */ +namespace Test\Util\User; + +use OC_User_Backend; + /** * dummy user backend, does not keep state, only for testing use */ -class OC_User_Dummy extends OC_User_Backend implements \OCP\IUserBackend { +class Dummy extends OC_User_Backend implements \OCP\IUserBackend { private $users = array(); private $displayNames = array(); diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php index 06065a8454e..6fab43d6a16 100644 --- a/tests/settings/controller/userscontrollertest.php +++ b/tests/settings/controller/userscontrollertest.php @@ -100,7 +100,7 @@ class UsersControllerTest extends \Test\TestCase { $admin ->expects($this->once()) ->method('getBackendClassName') - ->will($this->returnValue('OC_User_Dummy')); + ->will($this->returnValue('\Test\Util\User\Dummy')); $bar = $this->getMockBuilder('\OC\User\User') ->disableOriginalConstructor()->getMock(); $bar @@ -120,7 +120,7 @@ class UsersControllerTest extends \Test\TestCase { $bar ->expects($this->once()) ->method('getBackendClassName') - ->will($this->returnValue('OC_User_Dummy')); + ->will($this->returnValue('\Test\Util\User\Dummy')); $this->container['GroupManager'] ->expects($this->once()) @@ -175,7 +175,7 @@ class UsersControllerTest extends \Test\TestCase { 'quota' => 404, 'storageLocation' => '/home/admin', 'lastLogin' => 12000, - 'backend' => 'OC_User_Dummy', + 'backend' => '\Test\Util\User\Dummy', 'email' => 'admin@bar.com', 'isRestoreDisabled' => false, ), @@ -187,7 +187,7 @@ class UsersControllerTest extends \Test\TestCase { 'quota' => 2323, 'storageLocation' => '/home/bar', 'lastLogin' => 3999000, - 'backend' => 'OC_User_Dummy', + 'backend' => '\Test\Util\User\Dummy', 'email' => 'bar@dummy.com', 'isRestoreDisabled' => false, ), @@ -257,7 +257,7 @@ class UsersControllerTest extends \Test\TestCase { $admin ->expects($this->once()) ->method('getBackendClassName') - ->will($this->returnValue('OC_User_Dummy')); + ->will($this->returnValue('\Test\Util\User\Dummy')); $bar = $this->getMockBuilder('\OC\User\User') ->disableOriginalConstructor()->getMock(); $bar @@ -277,7 +277,7 @@ class UsersControllerTest extends \Test\TestCase { $bar ->expects($this->once()) ->method('getBackendClassName') - ->will($this->returnValue('OC_User_Dummy')); + ->will($this->returnValue('\Test\Util\User\Dummy')); $this->container['GroupManager'] ->expects($this->at(0)) @@ -343,7 +343,7 @@ class UsersControllerTest extends \Test\TestCase { 'quota' => 404, 'storageLocation' => '/home/admin', 'lastLogin' => 12000, - 'backend' => 'OC_User_Dummy', + 'backend' => '\Test\Util\User\Dummy', 'email' => 'admin@bar.com', 'isRestoreDisabled' => false, ], @@ -355,7 +355,7 @@ class UsersControllerTest extends \Test\TestCase { 'quota' => 2323, 'storageLocation' => '/home/bar', 'lastLogin' => 3999000, - 'backend' => 'OC_User_Dummy', + 'backend' => '\Test\Util\User\Dummy', 'email' => 'bar@dummy.com', 'isRestoreDisabled' => false, ], @@ -414,7 +414,7 @@ class UsersControllerTest extends \Test\TestCase { $admin ->expects($this->once()) ->method('getBackendClassName') - ->will($this->returnValue('OC_User_Dummy')); + ->will($this->returnValue('\Test\Util\User\Dummy')); $bar = $this->getMockBuilder('\OC\User\User') ->disableOriginalConstructor()->getMock(); $bar @@ -434,7 +434,7 @@ class UsersControllerTest extends \Test\TestCase { $bar ->expects($this->once()) ->method('getBackendClassName') - ->will($this->returnValue('OC_User_Dummy')); + ->will($this->returnValue('\Test\Util\User\Dummy')); $this->container['UserManager'] ->expects($this->once()) @@ -474,7 +474,7 @@ class UsersControllerTest extends \Test\TestCase { 'quota' => 404, 'storageLocation' => '/home/admin', 'lastLogin' => 12000, - 'backend' => 'OC_User_Dummy', + 'backend' => '\Test\Util\User\Dummy', 'email' => 'admin@bar.com', 'isRestoreDisabled' => false, ), @@ -486,7 +486,7 @@ class UsersControllerTest extends \Test\TestCase { 'quota' => 2323, 'storageLocation' => '/home/bar', 'lastLogin' => 3999000, - 'backend' => 'OC_User_Dummy', + 'backend' => '\Test\Util\User\Dummy', 'email' => 'bar@dummy.com', 'isRestoreDisabled' => false, ), @@ -522,16 +522,12 @@ class UsersControllerTest extends \Test\TestCase { $this->container['UserManager'] ->expects($this->once()) ->method('getBackends') - ->will($this->returnValue([new \OC_User_Dummy(), new \OC_User_Database()])); + ->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC_User_Database()])); $this->container['UserManager'] ->expects($this->once()) ->method('clearBackends'); $this->container['UserManager'] ->expects($this->once()) - ->method('registerBackend') - ->with(new \OC_User_Dummy()); - $this->container['UserManager'] - ->expects($this->once()) ->method('search') ->with('') ->will($this->returnValue([$user])); @@ -552,7 +548,7 @@ class UsersControllerTest extends \Test\TestCase { ) ) ); - $response = $this->container['UsersController']->index(0, 10, '','', 'OC_User_Dummy'); + $response = $this->container['UsersController']->index(0, 10, '','', '\Test\Util\User\Dummy'); $this->assertEquals($expectedResponse, $response); } @@ -562,7 +558,7 @@ class UsersControllerTest extends \Test\TestCase { $this->container['UserManager'] ->expects($this->once()) ->method('getBackends') - ->will($this->returnValue([new \OC_User_Dummy(), new \OC_User_Database()])); + ->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC_User_Database()])); $this->container['UserManager'] ->expects($this->once()) ->method('search') @@ -570,7 +566,7 @@ class UsersControllerTest extends \Test\TestCase { ->will($this->returnValue([])); $expectedResponse = new DataResponse([]); - $response = $this->container['UsersController']->index(0, 10, '','', 'OC_User_Dummy'); + $response = $this->container['UsersController']->index(0, 10, '','', '\Test\Util\User\Dummy'); $this->assertEquals($expectedResponse, $response); } |