|
|
|
|
@ -576,30 +576,30 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$this->appFetcher
|
|
|
|
|
->expects($this->atLeastOnce())
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('get')
|
|
|
|
|
->willReturnOnConsecutiveCalls($appArray);
|
|
|
|
|
->willReturn($appArray);
|
|
|
|
|
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
|
|
|
|
|
copy(__DIR__ . '/../data/testapp.tar.gz', $realTmpFile);
|
|
|
|
|
$this->tempManager
|
|
|
|
|
->expects($this->atLeastOnce())
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getTemporaryFile')
|
|
|
|
|
->with('.tar.gz')
|
|
|
|
|
->willReturnOnConsecutiveCalls($realTmpFile);
|
|
|
|
|
->willReturn($realTmpFile);
|
|
|
|
|
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
|
|
|
|
|
$this->tempManager
|
|
|
|
|
->expects($this->atLeastOnce())
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getTemporaryFolder')
|
|
|
|
|
->willReturnOnConsecutiveCalls($realTmpFolder);
|
|
|
|
|
->willReturn($realTmpFolder);
|
|
|
|
|
$client = $this->createMock(IClient::class);
|
|
|
|
|
$client
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('get')
|
|
|
|
|
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
|
|
|
|
|
$this->clientService
|
|
|
|
|
->expects($this->atLeastOnce())
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('newClient')
|
|
|
|
|
->willReturnOnConsecutiveCalls($client);
|
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
|
|
$installer = $this->getInstaller();
|
|
|
|
|
$installer->downloadApp('testapp');
|
|
|
|
|
@ -610,6 +610,14 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testDownloadAppWithDowngrade() {
|
|
|
|
|
// Use previous test to download the application in version 0.9
|
|
|
|
|
$this->testDownloadAppSuccessful();
|
|
|
|
|
|
|
|
|
|
// Reset mocks
|
|
|
|
|
$this->appFetcher = $this->createMock(AppFetcher::class);
|
|
|
|
|
$this->clientService = $this->createMock(IClientService::class);
|
|
|
|
|
$this->tempManager = $this->createMock(ITempManager::class);
|
|
|
|
|
|
|
|
|
|
$this->expectException(\Exception::class);
|
|
|
|
|
$this->expectExceptionMessage('App for id testapp has version 0.9 and tried to update to lower version 0.8');
|
|
|
|
|
|
|
|
|
|
@ -662,19 +670,19 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$this->appFetcher
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('get')
|
|
|
|
|
->willReturn($appArray);
|
|
|
|
|
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
|
|
|
|
|
copy(__DIR__ . '/../data/testapp.0.8.tar.gz', $realTmpFile);
|
|
|
|
|
$this->tempManager
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getTemporaryFile')
|
|
|
|
|
->with('.tar.gz')
|
|
|
|
|
->willReturn($realTmpFile);
|
|
|
|
|
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
|
|
|
|
|
$this->tempManager
|
|
|
|
|
->expects($this->at(3))
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getTemporaryFolder')
|
|
|
|
|
->willReturn($realTmpFolder);
|
|
|
|
|
$client = $this->createMock(IClient::class);
|
|
|
|
|
@ -683,10 +691,9 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
|
|
|
|
|
->method('get')
|
|
|
|
|
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
|
|
|
|
|
$this->clientService
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('newClient')
|
|
|
|
|
->willReturn($client);
|
|
|
|
|
$this->testDownloadAppSuccessful();
|
|
|
|
|
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));
|
|
|
|
|
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
|
|
|
|
|
|
|
|
|
|
|