diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2023-09-18 09:45:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-18 09:45:58 +0200 |
commit | b36fb96984a418dbb5b1535ac0e781ef0fde8f0a (patch) | |
tree | 8273698ead2195eacb723c1c6cd875adeff5338a /tests | |
parent | eee5a3ddc90b256ee02072cd91ed979f04a5209b (diff) | |
parent | e24007b5301f7381d4121ed915ed05909c34e755 (diff) | |
download | nextcloud-server-b36fb96984a418dbb5b1535ac0e781ef0fde8f0a.tar.gz nextcloud-server-b36fb96984a418dbb5b1535ac0e781ef0fde8f0a.zip |
Merge pull request #40419 from nextcloud/fix/remove-at-matcher-in-installer-test
Remove deprecated at matcher in tests/lib/InstallerTest.php
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/InstallerTest.php | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php index 60c8ac1cc94..4e622dca6d1 100644 --- a/tests/lib/InstallerTest.php +++ b/tests/lib/InstallerTest.php @@ -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/')); |