Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-04-27 00:20:40 +0300
committerGitHub <noreply@github.com>2017-04-27 00:20:40 +0300
commitaad07945005cfb8b59287452453623e1b0d33dd1 (patch)
tree95d99e77516678e4e8fa7a0e53d79fa77275c012 /tests
parent58fe27f09241cf9c27456259a2168aa326cb8d16 (diff)
parentd0e0bc55c80bf850c7941af99edead7ec5d56e59 (diff)
Merge pull request #4454 from nextcloud/add-bundles-to-install-page
Add app bundles to the apps page and unbundle enterprise apps
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Controller/AppSettingsControllerTest.php12
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleBase.php60
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleFetcherTest.php78
-rw-r--r--tests/lib/App/AppStore/Bundles/CoreBundleTest.php36
-rw-r--r--tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php41
-rw-r--r--tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php38
-rw-r--r--tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php40
-rw-r--r--tests/lib/InstallerTest.php17
-rw-r--r--tests/lib/Repair/NC12/InstallCoreBundleTest.php144
9 files changed, 461 insertions, 5 deletions
diff --git a/tests/Settings/Controller/AppSettingsControllerTest.php b/tests/Settings/Controller/AppSettingsControllerTest.php
index 14dc33ca191..9633c771596 100644
--- a/tests/Settings/Controller/AppSettingsControllerTest.php
+++ b/tests/Settings/Controller/AppSettingsControllerTest.php
@@ -22,6 +22,7 @@
namespace Tests\Settings\Controller;
+use OC\App\AppStore\Bundles\BundleFetcher;
use OC\App\AppStore\Fetcher\AppFetcher;
use OC\App\AppStore\Fetcher\CategoryFetcher;
use OC\Settings\Controller\AppSettingsController;
@@ -60,6 +61,8 @@ class AppSettingsControllerTest extends TestCase {
private $appFetcher;
/** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */
private $l10nFactory;
+ /** @var BundleFetcher|\PHPUnit_Framework_MockObject_MockObject */
+ private $bundleFetcher;
public function setUp() {
parent::setUp();
@@ -75,6 +78,7 @@ class AppSettingsControllerTest extends TestCase {
$this->categoryFetcher = $this->createMock(CategoryFetcher::class);
$this->appFetcher = $this->createMock(AppFetcher::class);
$this->l10nFactory = $this->createMock(IFactory::class);
+ $this->bundleFetcher = $this->createMock(BundleFetcher::class);
$this->appSettingsController = new AppSettingsController(
'settings',
@@ -85,7 +89,8 @@ class AppSettingsControllerTest extends TestCase {
$this->appManager,
$this->categoryFetcher,
$this->appFetcher,
- $this->l10nFactory
+ $this->l10nFactory,
+ $this->bundleFetcher
);
}
@@ -107,6 +112,11 @@ class AppSettingsControllerTest extends TestCase {
'displayName' => 'Disabled apps',
],
[
+ 'id' => 3,
+ 'ident' => 'app-bundles',
+ 'displayName' => 'App bundles',
+ ],
+ [
'id' => 'auth',
'ident' => 'auth',
'displayName' => 'Authentication & authorization',
diff --git a/tests/lib/App/AppStore/Bundles/BundleBase.php b/tests/lib/App/AppStore/Bundles/BundleBase.php
new file mode 100644
index 00000000000..23af1cda927
--- /dev/null
+++ b/tests/lib/App/AppStore/Bundles/BundleBase.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\App\AppStore\Bundles;
+
+use OC\App\AppStore\Bundles\Bundle;
+use OCP\IL10N;
+use Test\TestCase;
+
+abstract class BundleBase extends TestCase {
+ /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
+ protected $l10n;
+ /** @var Bundle */
+ protected $bundle;
+ /** @var string */
+ protected $bundleIdentifier;
+ /** @var string */
+ protected $bundleName;
+ /** @var array */
+ protected $bundleAppIds;
+
+ public function setUp() {
+ parent::setUp();
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->l10n->method('t')
+ ->will($this->returnCallback(function ($text, $parameters = []) {
+ return vsprintf($text, $parameters);
+ }));
+ }
+
+ public function testGetIdentifier() {
+ $this->assertSame($this->bundleIdentifier, $this->bundle->getIdentifier());
+ }
+
+ public function testGetName() {
+ $this->assertSame($this->bundleName, $this->bundle->getName());
+ }
+
+ public function testGetAppIdentifiers() {
+ $this->assertSame($this->bundleAppIds, $this->bundle->getAppIdentifiers());
+ }
+}
diff --git a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
new file mode 100644
index 00000000000..71f9820fc72
--- /dev/null
+++ b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\App\AppStore\Bundles;
+
+use OC\App\AppStore\Bundles\BundleFetcher;
+use OC\App\AppStore\Bundles\CoreBundle;
+use OC\App\AppStore\Bundles\EnterpriseBundle;
+use OC\App\AppStore\Bundles\GroupwareBundle;
+use OC\App\AppStore\Bundles\SocialSharingBundle;
+use OCP\IL10N;
+use Test\TestCase;
+
+class BundleFetcherTest extends TestCase {
+ /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
+ private $l10n;
+ /** @var BundleFetcher */
+ private $bundleFetcher;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->l10n = $this->createMock(IL10N::class);
+
+ $this->bundleFetcher = new BundleFetcher(
+ $this->l10n
+ );
+ }
+
+ public function testGetBundles() {
+ $expected = [
+ new EnterpriseBundle($this->l10n),
+ new GroupwareBundle($this->l10n),
+ new SocialSharingBundle($this->l10n),
+ ];
+ $this->assertEquals($expected, $this->bundleFetcher->getBundles());
+ }
+
+ public function testGetDefaultInstallationBundle() {
+ $expected = [
+ new CoreBundle($this->l10n),
+ ];
+ $this->assertEquals($expected, $this->bundleFetcher->getDefaultInstallationBundle());
+ }
+
+ public function testGetBundleByIdentifier() {
+ $this->assertEquals(new EnterpriseBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('EnterpriseBundle'));
+ $this->assertEquals(new CoreBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('CoreBundle'));
+ $this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle'));
+ }
+
+ /**
+ * @expectedException \BadMethodCallException
+ * @expectedExceptionMessage Bundle with specified identifier does not exist
+ */
+ public function testGetBundleByIdentifierWithException() {
+ $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle');
+ }
+
+}
diff --git a/tests/lib/App/AppStore/Bundles/CoreBundleTest.php b/tests/lib/App/AppStore/Bundles/CoreBundleTest.php
new file mode 100644
index 00000000000..235e2ec84fe
--- /dev/null
+++ b/tests/lib/App/AppStore/Bundles/CoreBundleTest.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\App\AppStore\Bundles;
+
+use OC\App\AppStore\Bundles\CoreBundle;
+
+class CoreBundleTest extends BundleBase {
+ public function setUp() {
+ parent::setUp();
+ $this->bundle = new CoreBundle($this->l10n);
+ $this->bundleIdentifier = 'CoreBundle';
+ $this->bundleName = 'Core bundle';
+ $this->bundleAppIds = [
+ 'bruteforcesettings',
+ ];
+ }
+}
diff --git a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
new file mode 100644
index 00000000000..e75486b3ed5
--- /dev/null
+++ b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\App\AppStore\Bundles;
+
+use OC\App\AppStore\Bundles\EnterpriseBundle;
+
+class EnterpriseBundleTest extends BundleBase {
+ public function setUp() {
+ parent::setUp();
+ $this->bundle = new EnterpriseBundle($this->l10n);
+ $this->bundleIdentifier = 'EnterpriseBundle';
+ $this->bundleName = 'Enterprise bundle';
+ $this->bundleAppIds = [
+ 'admin_audit',
+ 'user_ldap',
+ 'files_retention',
+ 'files_automatedtagging',
+ 'user_saml',
+ 'files_accesscontrol',
+ ];
+ }
+}
diff --git a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
new file mode 100644
index 00000000000..f2f9dcc5ccc
--- /dev/null
+++ b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\App\AppStore\Bundles;
+
+use OC\App\AppStore\Bundles\GroupwareBundle;
+
+class GroupwareBundleTest extends BundleBase {
+ public function setUp() {
+ parent::setUp();
+ $this->bundle = new GroupwareBundle($this->l10n);
+ $this->bundleIdentifier = 'GroupwareBundle';
+ $this->bundleName = 'Groupware bundle';
+ $this->bundleAppIds = [
+ 'calendar',
+ 'contacts',
+ 'spreed',
+ ];
+ }
+}
diff --git a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
new file mode 100644
index 00000000000..02ea0eb6ae5
--- /dev/null
+++ b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\App\AppStore\Bundles;
+
+use OC\App\AppStore\Bundles\SocialSharingBundle;
+
+class SocialSharingBundleTest extends BundleBase {
+ public function setUp() {
+ parent::setUp();
+ $this->bundle = new SocialSharingBundle($this->l10n);
+ $this->bundleIdentifier = 'SocialSharingBundle';
+ $this->bundleName = 'Social sharing bundle';
+ $this->bundleAppIds = [
+ 'socialsharing_twitter',
+ 'socialsharing_googleplus',
+ 'socialsharing_facebook',
+ 'socialsharing_email',
+ 'socialsharing_diaspora',
+ ];
+ }
+}
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index d1923970588..a31c8826bd9 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -9,11 +9,13 @@
namespace Test;
+use OC\App\AppStore\Bundles\Bundle;
use OC\App\AppStore\Fetcher\AppFetcher;
use OC\Archive\ZIP;
use OC\Installer;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
use OCP\ILogger;
use OCP\ITempManager;
@@ -29,6 +31,8 @@ class InstallerTest extends TestCase {
private $tempManager;
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
private $logger;
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ private $config;
/** @var Installer */
private $installer;
@@ -40,11 +44,13 @@ class InstallerTest extends TestCase {
$this->clientService = $this->createMock(IClientService::class);
$this->tempManager = $this->createMock(ITempManager::class);
$this->logger = $this->createMock(ILogger::class);
+ $this->config = $this->createMock(IConfig::class);
$this->installer = new Installer(
$this->appFetcher,
$this->clientService,
$this->tempManager,
- $this->logger
+ $this->logger,
+ $this->config
);
$config = \OC::$server->getConfig();
@@ -54,7 +60,8 @@ class InstallerTest extends TestCase {
\OC::$server->getAppFetcher(),
\OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(),
- \OC::$server->getLogger()
+ \OC::$server->getLogger(),
+ $config
);
$installer->removeApp(self::$appid);
}
@@ -64,7 +71,8 @@ class InstallerTest extends TestCase {
\OC::$server->getAppFetcher(),
\OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(),
- \OC::$server->getLogger()
+ \OC::$server->getLogger(),
+ \OC::$server->getConfig()
);
$installer->removeApp(self::$appid);
\OC::$server->getConfig()->setSystemValue('appstoreenabled', $this->appstore);
@@ -86,7 +94,8 @@ class InstallerTest extends TestCase {
\OC::$server->getAppFetcher(),
\OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(),
- \OC::$server->getLogger()
+ \OC::$server->getLogger(),
+ \OC::$server->getConfig()
);
$installer->installApp(self::$appid);
$isInstalled = Installer::isInstalled(self::$appid);
diff --git a/tests/lib/Repair/NC12/InstallCoreBundleTest.php b/tests/lib/Repair/NC12/InstallCoreBundleTest.php
new file mode 100644
index 00000000000..3a72934df86
--- /dev/null
+++ b/tests/lib/Repair/NC12/InstallCoreBundleTest.php
@@ -0,0 +1,144 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\Repair\NC12;
+
+use OC\App\AppStore\Bundles\Bundle;
+use OC\App\AppStore\Bundles\BundleFetcher;
+use OC\Installer;
+use OC\Repair\NC12\InstallCoreBundle;
+use OCP\IConfig;
+use OCP\Migration\IOutput;
+use Test\TestCase;
+
+
+class InstallCoreBundleTest extends TestCase {
+ /** @var BundleFetcher|\PHPUnit_Framework_MockObject_MockObject */
+ private $bundleFetcher;
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ private $config;
+ /** @var Installer|\PHPUnit_Framework_MockObject_MockObject */
+ private $installer;
+ /** @var InstallCoreBundle */
+ private $installCoreBundle;
+
+ public function setUp() {
+ parent::setUp();
+ $this->bundleFetcher = $this->createMock(BundleFetcher::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->installer = $this->createMock(Installer::class);
+
+ $this->installCoreBundle = new InstallCoreBundle(
+ $this->bundleFetcher,
+ $this->config,
+ $this->installer
+ );
+ }
+
+ public function testGetName() {
+ $this->assertSame('Install new core bundle components', $this->installCoreBundle->getName());
+ }
+
+ public function testRunOlder() {
+ $this->config
+ ->expects($this->once())
+ ->method('getSystemValue')
+ ->with('version', '0.0.0')
+ ->willReturn('12.0.0.15');
+ $this->bundleFetcher
+ ->expects($this->never())
+ ->method('getDefaultInstallationBundle');
+ /** @var IOutput|\PHPUnit_Framework_MockObject_MockObject $output */
+ $output = $this->createMock(IOutput::class);
+ $output
+ ->expects($this->never())
+ ->method('info');
+ $output
+ ->expects($this->never())
+ ->method('warning');
+
+ $this->installCoreBundle->run($output);
+ }
+
+ public function testRunWithException() {
+ $this->config
+ ->expects($this->once())
+ ->method('getSystemValue')
+ ->with('version', '0.0.0')
+ ->willReturn('12.0.0.14');
+ $bundle = $this->createMock(Bundle::class);
+ $this->bundleFetcher
+ ->expects($this->once())
+ ->method('getDefaultInstallationBundle')
+ ->willReturn([
+ $bundle,
+ ]);
+ $this->installer
+ ->expects($this->once())
+ ->method('installAppBundle')
+ ->with($bundle)
+ ->willThrowException(new \Exception('ExceptionText'));
+ /** @var IOutput|\PHPUnit_Framework_MockObject_MockObject $output */
+ $output = $this->createMock(IOutput::class);
+ $output
+ ->expects($this->never())
+ ->method('info');
+ $output
+ ->expects($this->once())
+ ->method('warning')
+ ->with('Could not install core app bundle: ExceptionText');
+
+ $this->installCoreBundle->run($output);
+ }
+
+ public function testRun() {
+ $this->config
+ ->expects($this->once())
+ ->method('getSystemValue')
+ ->with('version', '0.0.0')
+ ->willReturn('12.0.0.14');
+ $bundle = $this->createMock(Bundle::class);
+ $this->bundleFetcher
+ ->expects($this->once())
+ ->method('getDefaultInstallationBundle')
+ ->willReturn([
+ $bundle,
+ ]);
+ $this->installer
+ ->expects($this->once())
+ ->method('installAppBundle')
+ ->with($bundle);
+ /** @var IOutput|\PHPUnit_Framework_MockObject_MockObject $output */
+ $output = $this->createMock(IOutput::class);
+ $output
+ ->expects($this->once())
+ ->method('info')
+ ->with('Successfully installed core app bundle.');
+ $output
+ ->expects($this->never())
+ ->method('warning');
+
+ $this->installCoreBundle->run($output);
+ }
+
+}