Run Unit Tests against PHP 7.4
Bump PHPUnit version and fix unit test - Globals are handled differently and are persistent through tests - Tests without assertions are marked as risky: some of them are just meant to check that no error is raised.
This commit is contained in:
parent
ef02885753
commit
def39d0dd7
11 changed files with 676 additions and 566 deletions
|
@ -3,6 +3,8 @@ dist: trusty
|
|||
|
||||
matrix:
|
||||
include:
|
||||
- language: php
|
||||
php: 7.4
|
||||
- language: php
|
||||
php: 7.3
|
||||
- language: php
|
||||
|
|
|
@ -150,6 +150,8 @@ public static function checkUpdate(
|
|||
* @param string $minVersion minimum PHP required version
|
||||
* @param string $curVersion current PHP version (use PHP_VERSION)
|
||||
*
|
||||
* @return bool true on success
|
||||
*
|
||||
* @throws Exception the PHP version is not supported
|
||||
*/
|
||||
public static function checkPHPVersion($minVersion, $curVersion)
|
||||
|
@ -163,6 +165,7 @@ public static function checkPHPVersion($minVersion, $curVersion)
|
|||
);
|
||||
throw new Exception(sprintf($msg, $minVersion));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,8 @@ class ApiUtils
|
|||
* @param string $token JWT token extracted from the headers.
|
||||
* @param string $secret API secret set in the settings.
|
||||
*
|
||||
* @return bool true on success
|
||||
*
|
||||
* @throws ApiAuthorizationException the token is not valid.
|
||||
*/
|
||||
public static function validateJwtToken($token, $secret)
|
||||
|
@ -45,6 +47,8 @@ public static function validateJwtToken($token, $secret)
|
|||
) {
|
||||
throw new ApiAuthorizationException('Invalid JWT issued time');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
"shaarli/netscape-bookmark-parser": "^2.1",
|
||||
"erusev/parsedown": "^1.6",
|
||||
"slim/slim": "^3.0",
|
||||
"arthurhoaro/web-thumbnailer": "^1.1",
|
||||
"arthurhoaro/web-thumbnailer": "^2.0",
|
||||
"pubsubhubbub/publisher": "dev-master",
|
||||
"gettext/gettext": "^4.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"roave/security-advisories": "dev-master",
|
||||
"phpunit/phpcov": "*",
|
||||
"phpunit/phpunit": "^5.0",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"squizlabs/php_codesniffer": "3.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Allows fetching web pages and thumbnails in a more robust way",
|
||||
|
|
1201
composer.lock
generated
1201
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -253,9 +253,9 @@ public function testCheckUpdateNewVersionTwiceOutdated()
|
|||
public function testCheckSupportedPHPVersion()
|
||||
{
|
||||
$minVersion = '5.3';
|
||||
ApplicationUtils::checkPHPVersion($minVersion, '5.4.32');
|
||||
ApplicationUtils::checkPHPVersion($minVersion, '5.5');
|
||||
ApplicationUtils::checkPHPVersion($minVersion, '5.6.10');
|
||||
$this->assertTrue(ApplicationUtils::checkPHPVersion($minVersion, '5.4.32'));
|
||||
$this->assertTrue(ApplicationUtils::checkPHPVersion($minVersion, '5.5'));
|
||||
$this->assertTrue(ApplicationUtils::checkPHPVersion($minVersion, '5.6.10'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,7 +265,7 @@ public function testCheckSupportedPHPVersion()
|
|||
*/
|
||||
public function testCheckSupportedPHPVersion51()
|
||||
{
|
||||
ApplicationUtils::checkPHPVersion('5.3', '5.1.0');
|
||||
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,7 +275,7 @@ public function testCheckSupportedPHPVersion51()
|
|||
*/
|
||||
public function testCheckSupportedPHPVersion52()
|
||||
{
|
||||
ApplicationUtils::checkPHPVersion('5.3', '5.2');
|
||||
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,13 +58,12 @@ public function testPlugin()
|
|||
|
||||
/**
|
||||
* Test missing plugin loading.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPluginNotFound()
|
||||
{
|
||||
$this->pluginManager->load(array());
|
||||
$this->pluginManager->load(array('nope', 'renope'));
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,7 @@ public static function generateCustomJwtToken($header, $payload, $secret)
|
|||
public function testValidateJwtTokenValid()
|
||||
{
|
||||
$secret = 'WarIsPeace';
|
||||
ApiUtils::validateJwtToken(self::generateValidJwtToken($secret), $secret);
|
||||
$this->assertTrue(ApiUtils::validateJwtToken(self::generateValidJwtToken($secret), $secret));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
/**
|
||||
* Class ConfigPhpTest
|
||||
*
|
||||
* We run tests in separate processes due to the usage for $GLOBALS
|
||||
* which are kept between tests.
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class ConfigPhpTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ public function testConstruct()
|
|||
new CachedPage(self::$testCacheDir, '', false);
|
||||
new CachedPage(self::$testCacheDir, 'http://shaar.li/?do=rss', true);
|
||||
new CachedPage(self::$testCacheDir, 'http://shaar.li/?do=atom', false);
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -724,6 +724,9 @@ public function testUpdateMethodWebThumbnailerEnabled()
|
|||
*/
|
||||
public function testUpdateMethodWebThumbnailerDisabled()
|
||||
{
|
||||
if (isset($_SESSION['warnings'])) {
|
||||
unset($_SESSION['warnings']);
|
||||
}
|
||||
$this->conf->remove('thumbnails');
|
||||
$this->conf->set('thumbnail.enable_thumbnails', false);
|
||||
$updater = new Updater([], [], $this->conf, true, $_SESSION);
|
||||
|
@ -740,6 +743,9 @@ public function testUpdateMethodWebThumbnailerDisabled()
|
|||
*/
|
||||
public function testUpdateMethodWebThumbnailerNothingToDo()
|
||||
{
|
||||
if (isset($_SESSION['warnings'])) {
|
||||
unset($_SESSION['warnings']);
|
||||
}
|
||||
$updater = new Updater([], [], $this->conf, true, $_SESSION);
|
||||
$this->assertTrue($updater->updateMethodWebThumbnailer());
|
||||
$this->assertFalse($this->conf->exists('thumbnail'));
|
||||
|
|
Loading…
Reference in a new issue