Merge pull request #19817 from nextcloud/backport/19742/stable16

[stable16] Add message for DoesNotExistException
This commit is contained in:
Roeland Jago Douma 2020-03-07 14:17:25 +01:00 committed by GitHub
commit 56422f10ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -54,8 +54,8 @@ class ChangesCheck {
$version = $this->normalizeVersion($version); $version = $this->normalizeVersion($version);
$changesInfo = $this->mapper->getChanges($version); $changesInfo = $this->mapper->getChanges($version);
$changesData = json_decode($changesInfo->getData(), true); $changesData = json_decode($changesInfo->getData(), true);
if(empty($changesData)) { if (empty($changesData)) {
throw new DoesNotExistException(); throw new DoesNotExistException('Unable to decode changes info');
} }
return $changesData; return $changesData;
} }

View File

@ -380,4 +380,21 @@ class ChangesCheckTest extends TestCase {
$this->assertTrue(isset($data['whatsNew']['en']['regular'])); $this->assertTrue(isset($data['whatsNew']['en']['regular']));
$this->assertTrue(isset($data['changelogURL'])); $this->assertTrue(isset($data['changelogURL']));
} }
public function testGetChangesForVersionEmptyData() {
$entry = $this->createMock(ChangesResult::class);
$entry->expects($this->once())
->method('__call')
->with('getData')
->willReturn('');
$this->mapper->expects($this->once())
->method('getChanges')
->with('13.0.7')
->willReturn($entry);
$this->expectException(DoesNotExistException::class);
/** @noinspection PhpUnhandledExceptionInspection */
$this->checker->getChangesForVersion('13.0.7');
}
} }