Merge pull request #4454 from nextcloud/add-bundles-to-install-page
Add app bundles to the apps page and unbundle enterprise appspull/4545/head
commit
aad0794500
@ -0,0 +1,59 @@ |
||||
<?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 OC\App\AppStore\Bundles; |
||||
|
||||
use OCP\IL10N; |
||||
|
||||
abstract class Bundle { |
||||
/** @var IL10N */ |
||||
protected $l10n; |
||||
|
||||
/** |
||||
* @param IL10N $l10n |
||||
*/ |
||||
public function __construct(IL10N $l10n) { |
||||
$this->l10n = $l10n; |
||||
} |
||||
|
||||
/** |
||||
* Get the identifier of the bundle |
||||
* |
||||
* @return string |
||||
*/ |
||||
public final function getIdentifier() { |
||||
return substr(strrchr(get_class($this), '\\'), 1); |
||||
} |
||||
|
||||
/** |
||||
* Get the name of the bundle |
||||
* |
||||
* @return string |
||||
*/ |
||||
public abstract function getName(); |
||||
|
||||
/** |
||||
* Get the list of app identifiers in the bundle |
||||
* |
||||
* @return array |
||||
*/ |
||||
public abstract function getAppIdentifiers(); |
||||
} |
@ -0,0 +1,80 @@ |
||||
<?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 OC\App\AppStore\Bundles; |
||||
|
||||
use OCP\IL10N; |
||||
|
||||
class BundleFetcher { |
||||
/** @var IL10N */ |
||||
private $l10n; |
||||
|
||||
/** |
||||
* @param IL10N $l10n |
||||
*/ |
||||
public function __construct(IL10N $l10n) { |
||||
$this->l10n = $l10n; |
||||
} |
||||
|
||||
/** |
||||
* @return Bundle[] |
||||
*/ |
||||
public function getBundles() { |
||||
return [ |
||||
new EnterpriseBundle($this->l10n), |
||||
new GroupwareBundle($this->l10n), |
||||
new SocialSharingBundle($this->l10n), |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* Bundles that should be installed by default after installation |
||||
* |
||||
* @return Bundle[] |
||||
*/ |
||||
public function getDefaultInstallationBundle() { |
||||
return [ |
||||
new CoreBundle($this->l10n), |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* Get the bundle with the specified identifier |
||||
* |
||||
* @param string $identifier |
||||
* @return Bundle |
||||
* @throws \BadMethodCallException If the bundle does not exist |
||||
*/ |
||||
public function getBundleByIdentifier($identifier) { |
||||
/** @var Bundle[] $bundles */ |
||||
$bundles = array_merge( |
||||
$this->getBundles(), |
||||
$this->getDefaultInstallationBundle() |
||||
); |
||||
foreach($bundles as $bundle) { |
||||
if($bundle->getIdentifier() === $identifier) { |
||||
return $bundle; |
||||
} |
||||
} |
||||
|
||||
throw new \BadMethodCallException('Bundle with specified identifier does not exist'); |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
<?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 OC\App\AppStore\Bundles; |
||||
|
||||
class CoreBundle extends Bundle { |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getName() { |
||||
return 'Core bundle'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getAppIdentifiers() { |
||||
return [ |
||||
'bruteforcesettings', |
||||
]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,47 @@ |
||||
<?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 OC\App\AppStore\Bundles; |
||||
|
||||
class EnterpriseBundle extends Bundle { |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getName() { |
||||
return (string)$this->l10n->t('Enterprise bundle'); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getAppIdentifiers() { |
||||
return [ |
||||
'admin_audit', |
||||
'user_ldap', |
||||
'files_retention', |
||||
'files_automatedtagging', |
||||
'user_saml', |
||||
'files_accesscontrol', |
||||
]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,44 @@ |
||||
<?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 OC\App\AppStore\Bundles; |
||||
|
||||
class GroupwareBundle extends Bundle { |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getName() { |
||||
return (string)$this->l10n->t('Groupware bundle'); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getAppIdentifiers() { |
||||
return [ |
||||
'calendar', |
||||
'contacts', |
||||
'spreed', |
||||
]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@ |
||||
<?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 OC\App\AppStore\Bundles; |
||||
|
||||
class SocialSharingBundle extends Bundle { |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getName() { |
||||
return (string)$this->l10n->t('Social sharing bundle'); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
*/ |
||||
public function getAppIdentifiers() { |
||||
return [ |
||||
'socialsharing_twitter', |
||||
'socialsharing_googleplus', |
||||
'socialsharing_facebook', |
||||
'socialsharing_email', |
||||
'socialsharing_diaspora', |
||||
]; |
||||
} |
||||
|
||||
} |
@ -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 OC\Repair\NC12; |
||||
|
||||
use OC\App\AppStore\Bundles\BundleFetcher; |
||||
use OC\Installer; |
||||
use OCP\IConfig; |
||||
use OCP\Migration\IOutput; |
||||
use OCP\Migration\IRepairStep; |
||||
|
||||
class InstallCoreBundle implements IRepairStep { |
||||
/** @var BundleFetcher */ |
||||
private $bundleFetcher; |
||||
/** @var IConfig */ |
||||
private $config; |
||||
/** @var Installer */ |
||||
private $installer; |
||||
|
||||
/** |
||||
* @param BundleFetcher $bundleFetcher |
||||
* @param IConfig $config |
||||
* @param Installer $installer |
||||
*/ |
||||
public function __construct(BundleFetcher $bundleFetcher, |
||||
IConfig $config, |
||||
Installer $installer) { |
||||
$this->bundleFetcher = $bundleFetcher; |
||||
$this->config = $config; |
||||
$this->installer = $installer; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getName() { |
||||
return 'Install new core bundle components'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function run(IOutput $output) { |
||||
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
||||
|
||||
if (version_compare($versionFromBeforeUpdate, '12.0.0.14', '>')) { |
||||
return; |
||||
} |
||||
|
||||
$defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle(); |
||||
foreach($defaultBundle as $bundle) { |
||||
try { |
||||
$this->installer->installAppBundle($bundle); |
||||
$output->info('Successfully installed core app bundle.'); |
||||
} catch (\Exception $e) { |
||||
$output->warning('Could not install core app bundle: ' . $e->getMessage()); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |
@ -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'); |
||||
} |
||||
|
||||
} |
@ -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', |
||||
]; |
||||
} |
||||
} |
@ -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', |
||||
]; |
||||
} |
||||
} |
@ -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', |
||||
]; |
||||
} |
||||
} |
@ -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', |
||||
]; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue