summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-11-24 10:27:58 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-11-25 12:00:57 +0100
commit0e2f00ec59424b2ef5708a928856e2c75abe6deb (patch)
treecbd61c976a34b352bb8377899a244b66ff82f40d /tests
parenta97a290fd5ed06dfc33d2adeed5d3b7531674827 (diff)
downloadnextcloud-server-0e2f00ec59424b2ef5708a928856e2c75abe6deb.tar.gz
nextcloud-server-0e2f00ec59424b2ef5708a928856e2c75abe6deb.zip
Get the Installer via DI
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/InstallerTest.php44
-rw-r--r--tests/lib/SetupTest.php6
-rw-r--r--tests/lib/UpdaterTest.php13
3 files changed, 41 insertions, 22 deletions
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index 107b9dcb41f..68f3676faa8 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -40,9 +40,6 @@ class InstallerTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
- /** @var Installer */
- private $installer;
-
protected function setUp() {
parent::setUp();
@@ -51,13 +48,6 @@ class InstallerTest extends TestCase {
$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->config
- );
$config = \OC::$server->getConfig();
$this->appstore = $config->setSystemValue('appstoreenabled', true);
@@ -72,6 +62,16 @@ class InstallerTest extends TestCase {
$installer->removeApp(self::$appid);
}
+ protected function getInstaller() {
+ return new Installer(
+ $this->appFetcher,
+ $this->clientService,
+ $this->tempManager,
+ $this->logger,
+ $this->config
+ );
+ }
+
protected function tearDown() {
$installer = new Installer(
\OC::$server->getAppFetcher(),
@@ -197,7 +197,8 @@ gLgK8d8sKL60JMmKHN3boHrsThKBVA==
->willReturn($appArray);
- $this->installer->downloadApp('news');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('news');
}
/**
@@ -239,7 +240,8 @@ YSu356M=
->method('get')
->willReturn($appArray);
- $this->installer->downloadApp('news');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('news');
}
/**
@@ -281,7 +283,8 @@ cR92p/PYCFXkAKP3OO0RPlf6dXNKTw==
->method('get')
->willReturn($appArray);
- $this->installer->downloadApp('news');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('news');
}
/**
@@ -348,7 +351,8 @@ cR92p/PYCFXkAKP3OO0RPlf6dXNKTw==
->method('newClient')
->willReturn($client);
- $this->installer->downloadApp('passman');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('passman');
}
/**
@@ -431,7 +435,8 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
->method('newClient')
->willReturn($client);
- $this->installer->downloadApp('testapp');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('testapp');
}
/**
@@ -513,7 +518,8 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
->method('newClient')
->willReturn($client);
- $this->installer->downloadApp('testapp');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('testapp');
}
public function testDownloadAppSuccessful() {
@@ -591,7 +597,8 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
->method('newClient')
->willReturn($client);
- $this->installer->downloadApp('testapp');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('testapp');
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
@@ -679,7 +686,8 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
- $this->installer->downloadApp('testapp');
+ $installer = $this->getInstaller();
+ $installer->downloadApp('testapp');
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));
$this->assertEquals('0.8', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
}
diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php
index 78c35a5b0bb..e6e9fb5c56c 100644
--- a/tests/lib/SetupTest.php
+++ b/tests/lib/SetupTest.php
@@ -9,6 +9,7 @@
namespace Test;
use bantu\IniGetWrapper\IniGetWrapper;
+use OC\Installer;
use OC\SystemConfig;
use OCP\Defaults;
use OCP\IL10N;
@@ -31,6 +32,8 @@ class SetupTest extends \Test\TestCase {
protected $logger;
/** @var \OCP\Security\ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */
protected $random;
+ /** @var Installer|\PHPUnit_Framework_MockObject_MockObject */
+ protected $installer;
protected function setUp() {
parent::setUp();
@@ -41,9 +44,10 @@ class SetupTest extends \Test\TestCase {
$this->defaults = $this->createMock(Defaults::class);
$this->logger = $this->createMock(ILogger::class);
$this->random = $this->createMock(ISecureRandom::class);
+ $this->installer = $this->createMock(Installer::class);
$this->setupClass = $this->getMockBuilder('\OC\Setup')
->setMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
- ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10n, $this->defaults, $this->logger, $this->random])
+ ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10n, $this->defaults, $this->logger, $this->random, $this->installer])
->getMock();
}
diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php
index afa0635768d..a6a8224ac34 100644
--- a/tests/lib/UpdaterTest.php
+++ b/tests/lib/UpdaterTest.php
@@ -22,6 +22,7 @@
namespace Test;
+use OC\Installer;
use OC\Updater;
use OCP\IConfig;
use OCP\ILogger;
@@ -36,6 +37,8 @@ class UpdaterTest extends TestCase {
private $updater;
/** @var Checker | \PHPUnit_Framework_MockObject_MockObject */
private $checker;
+ /** @var Installer|\PHPUnit_Framework_MockObject_MockObject */
+ private $installer;
public function setUp() {
parent::setUp();
@@ -46,13 +49,17 @@ class UpdaterTest extends TestCase {
->disableOriginalConstructor()
->getMock();
$this->checker = $this->getMockBuilder(Checker::class)
- ->disableOriginalConstructor()
- ->getMock();
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->installer = $this->getMockBuilder(Installer::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$this->updater = new Updater(
$this->config,
$this->checker,
- $this->logger
+ $this->logger,
+ $this->installer
);
}