Skip to content

Commit

Permalink
Merge pull request #40419 from nextcloud/fix/remove-at-matcher-in-ins…
Browse files Browse the repository at this point in the history
…taller-test

Remove deprecated at matcher in tests/lib/InstallerTest.php
  • Loading branch information
come-nc authored Sep 18, 2023
2 parents eee5a3d + e24007b commit b36fb96
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions tests/lib/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,30 +576,30 @@ public function testDownloadAppSuccessful() {
],
];
$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');
Expand All @@ -610,6 +610,14 @@ public function testDownloadAppSuccessful() {


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');

Expand Down Expand Up @@ -662,19 +670,19 @@ public function testDownloadAppWithDowngrade() {
],
];
$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);
Expand All @@ -683,10 +691,9 @@ public function testDownloadAppWithDowngrade() {
->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/'));

Expand Down

0 comments on commit b36fb96

Please sign in to comment.