From def39d0dd7a81a4af9ad68b62c9e9823fbc2b38e Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 10 Aug 2019 12:31:32 +0200 Subject: 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. --- tests/ApplicationUtilsTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 82f8804d..15388970 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -253,9 +253,9 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase 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 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase */ public function testCheckSupportedPHPVersion51() { - ApplicationUtils::checkPHPVersion('5.3', '5.1.0'); + $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); } /** @@ -275,7 +275,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase */ public function testCheckSupportedPHPVersion52() { - ApplicationUtils::checkPHPVersion('5.3', '5.2'); + $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); } /** -- cgit v1.2.3 From 8f60e1206e45e67c96a7630d4ff94e72fe875f09 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 26 Sep 2020 15:08:39 +0200 Subject: Comply with PHPUnit V8: setup/teardown functions must return void --- tests/ApplicationUtilsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 15388970..57359196 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -17,7 +17,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase /** * Reset test data for each test */ - public function setUp() + protected function setUp(): void { FakeApplicationUtils::$VERSION_CODE = ''; if (file_exists(self::$testUpdateFile)) { @@ -28,7 +28,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase /** * Remove test version file if it exists */ - public function tearDown() + protected function tearDown(): void { if (is_file('sandbox/version.php')) { unlink('sandbox/version.php'); -- cgit v1.2.3 From b1baca99f280570d0336b4d71ad1f9dca213a35b Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 27 Sep 2020 14:07:08 +0200 Subject: Convert legacy PHPUnit @expected* to new ->expect* Converted automatically using https://github.com/ArthurHoaro/convert-legacy-phpunit-expect --- tests/ApplicationUtilsTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 57359196..421d2dd9 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -145,10 +145,11 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase /** * Test update checks - invalid Git branch * @expectedException Exception - * @expectedExceptionMessageRegExp /Invalid branch selected for updates/ */ public function testCheckUpdateInvalidGitBranch() { + $this->expectExceptionMessageRegExp('/Invalid branch selected for updates/'); + ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable'); } @@ -261,20 +262,22 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase /** * Check a unsupported PHP version * @expectedException Exception - * @expectedExceptionMessageRegExp /Your PHP version is obsolete/ */ public function testCheckSupportedPHPVersion51() { + $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); + $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); } /** * Check another unsupported PHP version * @expectedException Exception - * @expectedExceptionMessageRegExp /Your PHP version is obsolete/ */ public function testCheckSupportedPHPVersion52() { + $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); + $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); } -- cgit v1.2.3 From a5a9cf23acd1248585173aa32757d9720b5f2d62 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 29 Sep 2020 14:41:40 +0200 Subject: Compatibility with PHPUnit 9 --- tests/ApplicationUtilsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 421d2dd9..7ad1d34c 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -8,7 +8,7 @@ require_once 'tests/utils/FakeApplicationUtils.php'; /** * Unitary tests for Shaarli utilities */ -class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase +class ApplicationUtilsTest extends \Shaarli\TestCase { protected static $testUpdateFile = 'sandbox/update.txt'; protected static $testVersion = '0.5.0'; -- cgit v1.2.3 From f447edb73b1bcb52e86286467d3ec7b7bdc29948 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 29 Sep 2020 18:41:21 +0200 Subject: Fix missing @expectedException convertion --- tests/ApplicationUtilsTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 7ad1d34c..a232b351 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -144,10 +144,10 @@ class ApplicationUtilsTest extends \Shaarli\TestCase /** * Test update checks - invalid Git branch - * @expectedException Exception */ public function testCheckUpdateInvalidGitBranch() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid branch selected for updates/'); ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable'); @@ -261,10 +261,10 @@ class ApplicationUtilsTest extends \Shaarli\TestCase /** * Check a unsupported PHP version - * @expectedException Exception */ public function testCheckSupportedPHPVersion51() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); @@ -272,10 +272,10 @@ class ApplicationUtilsTest extends \Shaarli\TestCase /** * Check another unsupported PHP version - * @expectedException Exception */ public function testCheckSupportedPHPVersion52() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); -- cgit v1.2.3