chore: Adapt InstallerTest to Installer new construct parameters

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/53895/head
Côme Chilliet 3 months ago
parent 410389867c
commit f551b9192e
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 40
      tests/lib/InstallerTest.php

@ -17,6 +17,7 @@ use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ITempManager;
use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
/**
@ -38,6 +39,7 @@ class InstallerTest extends TestCase {
private $logger;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $config;
private IAppManager&MockObject $appManager;
protected function setUp(): void {
parent::setUp();
@ -47,18 +49,12 @@ class InstallerTest extends TestCase {
$this->tempManager = $this->createMock(ITempManager::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->config = $this->createMock(IConfig::class);
$this->appManager = $this->createMock(IAppManager::class);
$config = Server::get(IConfig::class);
$this->appstore = $config->setSystemValue('appstoreenabled', true);
$config->setSystemValue('appstoreenabled', true);
$installer = new Installer(
Server::get(AppFetcher::class),
Server::get(IClientService::class),
Server::get(ITempManager::class),
Server::get(LoggerInterface::class),
$config,
false
);
$installer = Server::get(Installer::class);
$installer->removeApp(self::$appid);
}
@ -69,19 +65,13 @@ class InstallerTest extends TestCase {
$this->tempManager,
$this->logger,
$this->config,
$this->appManager,
false
);
}
protected function tearDown(): void {
$installer = new Installer(
Server::get(AppFetcher::class),
Server::get(IClientService::class),
Server::get(ITempManager::class),
Server::get(LoggerInterface::class),
Server::get(IConfig::class),
false
);
$installer = Server::get(Installer::class);
$installer->removeApp(self::$appid);
Server::get(IConfig::class)->setSystemValue('appstoreenabled', $this->appstore);
@ -93,14 +83,7 @@ class InstallerTest extends TestCase {
Server::get(IAppManager::class)->getAppVersion('testapp', true);
// Build installer
$installer = new Installer(
Server::get(AppFetcher::class),
Server::get(IClientService::class),
Server::get(ITempManager::class),
Server::get(LoggerInterface::class),
Server::get(IConfig::class),
false
);
$installer = Server::get(Installer::class);
// Extract app
$pathOfTestApp = __DIR__ . '/../data/testapp.zip';
@ -158,6 +141,10 @@ class InstallerTest extends TestCase {
->expects($this->once())
->method('get')
->willReturn($appArray);
$this->appManager
->expects($this->exactly(2))
->method('getAppVersion')
->willReturn('1.0');
$installer = $this->getInstaller();
$this->assertSame($updateAvailable, $installer->isUpdateAvailable('files'));
@ -700,6 +687,11 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
$this->appManager
->expects($this->once())
->method('getAppVersion')
->willReturn('0.9');
$installer = $this->getInstaller();
$installer->downloadApp('testapp');
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));

Loading…
Cancel
Save