adjust tests

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-06-01 10:29:46 +02:00 committed by Morris Jobke
parent bafb6b3c29
commit 1e0761c6b8
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
5 changed files with 18 additions and 2 deletions

View File

@ -59,7 +59,7 @@ class UpdateChecker {
if (strpos($data['changelog'], 'https://') === 0) {
$result['changelog'] = $data['changelog'];
}
if($data['whatsNew'] !== null) {
if (is_array($data['whatsNew']) && count($data['whatsNew']) <= 3) {
$result['whatsNew'] = $data['whatsNew'];
}

View File

@ -99,6 +99,8 @@ class AdminTest extends TestCase {
'updateAvailable' => true,
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'changelog' => 'https://nextcloud.com/changelog/#8.1.2',
'whatsNew' => ['Autoshare to mother-in-law', 'Faster backend', 'Sparkling frontend'],
'updaterEnabled' => true,
'versionIsEol' => false,
]);
@ -124,6 +126,8 @@ class AdminTest extends TestCase {
'channels' => $channels,
'newVersionString' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'changelogURL' => 'https://nextcloud.com/changelog/#8.1.2',
'whatsNew' => ['Autoshare to mother-in-law', 'Faster backend', 'Sparkling frontend'],
'updaterEnabled' => true,
'versionIsEol' => false,
'isDefaultUpdateServerURL' => true,

View File

@ -51,6 +51,8 @@ class UpdateCheckerTest extends TestCase {
'versionstring' => 'Nextcloud 123',
'web'=> 'javascript:alert(1)',
'url'=> 'javascript:alert(2)',
'changelog' => 'javascript:alert(3)',
'whatsNew' => 'javascript:alert(4)',
'autoupdater'=> '0',
'eol'=> '1',
]);
@ -73,6 +75,8 @@ class UpdateCheckerTest extends TestCase {
'versionstring' => 'Nextcloud 123',
'web'=> 'https://docs.nextcloud.com/myUrl',
'url'=> 'https://downloads.nextcloud.org/server',
'changelog' => 'https://nextcloud.com/changelog/#123.0.0',
'whatsNew' => ['Brews coffee', 'Makes appointments', 'Orchestrates Terminators'],
'autoupdater'=> '1',
'eol'=> '0',
]);
@ -84,6 +88,8 @@ class UpdateCheckerTest extends TestCase {
'versionIsEol' => false,
'updateLink' => 'https://docs.nextcloud.com/myUrl',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'changelog' => 'https://nextcloud.com/changelog/#123.0.0',
'whatsNew' => ['Brews coffee', 'Makes appointments', 'Orchestrates Terminators'],
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}

View File

@ -97,7 +97,7 @@ class VersionCheck {
$tmp['versionstring'] = (string)$data->versionstring;
$tmp['url'] = (string)$data->url;
$tmp['web'] = (string)$data->web;
$tmp['changelog'] = isset($data->changelog) ? (string)$data->changelog : null;
$tmp['changelog'] = isset($data->changelog) ? (string)$data->changelog : '';
// TODO: one's it is decided, use the proper field…
$tmp['whatsNew'] = isset($data->whatsNew) ? ((array)$data->whatsNew)['item'] : null;
$tmp['whatsNew'] = isset($data->whatsNew_admin) ? ((array)$data->whatsNew_admin)['item'] : (string)$data->whatsNew;

View File

@ -84,6 +84,8 @@ class VersionCheckTest extends \Test\TestCase {
'versionstring' => 'ownCloud 8.0.4',
'url' => 'https://download.example.org/community/owncloud-8.0.4.zip',
'web' => 'http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html',
'changelog' => '',
'whatsNew' => '',
'autoupdater' => '0',
'eol' => '1',
];
@ -181,6 +183,8 @@ class VersionCheckTest extends \Test\TestCase {
'versionstring' => '',
'url' => '',
'web' => '',
'changelog' => '',
'whatsNew' => '',
'autoupdater' => '',
'eol' => '0',
];
@ -275,6 +279,8 @@ class VersionCheckTest extends \Test\TestCase {
'versionstring' => '',
'url' => '',
'web' => '',
'changelog' => '',
'whatsNew' => '',
'autoupdater' => '',
'eol' => '0',
];