diff options
Diffstat (limited to 'tests/ApplicationUtilsTest.php')
-rw-r--r-- | tests/ApplicationUtilsTest.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 15388970..a232b351 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php | |||
@@ -8,7 +8,7 @@ require_once 'tests/utils/FakeApplicationUtils.php'; | |||
8 | /** | 8 | /** |
9 | * Unitary tests for Shaarli utilities | 9 | * Unitary tests for Shaarli utilities |
10 | */ | 10 | */ |
11 | class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase | 11 | class ApplicationUtilsTest extends \Shaarli\TestCase |
12 | { | 12 | { |
13 | protected static $testUpdateFile = 'sandbox/update.txt'; | 13 | protected static $testUpdateFile = 'sandbox/update.txt'; |
14 | protected static $testVersion = '0.5.0'; | 14 | protected static $testVersion = '0.5.0'; |
@@ -17,7 +17,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase | |||
17 | /** | 17 | /** |
18 | * Reset test data for each test | 18 | * Reset test data for each test |
19 | */ | 19 | */ |
20 | public function setUp() | 20 | protected function setUp(): void |
21 | { | 21 | { |
22 | FakeApplicationUtils::$VERSION_CODE = ''; | 22 | FakeApplicationUtils::$VERSION_CODE = ''; |
23 | if (file_exists(self::$testUpdateFile)) { | 23 | if (file_exists(self::$testUpdateFile)) { |
@@ -28,7 +28,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase | |||
28 | /** | 28 | /** |
29 | * Remove test version file if it exists | 29 | * Remove test version file if it exists |
30 | */ | 30 | */ |
31 | public function tearDown() | 31 | protected function tearDown(): void |
32 | { | 32 | { |
33 | if (is_file('sandbox/version.php')) { | 33 | if (is_file('sandbox/version.php')) { |
34 | unlink('sandbox/version.php'); | 34 | unlink('sandbox/version.php'); |
@@ -144,11 +144,12 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase | |||
144 | 144 | ||
145 | /** | 145 | /** |
146 | * Test update checks - invalid Git branch | 146 | * Test update checks - invalid Git branch |
147 | * @expectedException Exception | ||
148 | * @expectedExceptionMessageRegExp /Invalid branch selected for updates/ | ||
149 | */ | 147 | */ |
150 | public function testCheckUpdateInvalidGitBranch() | 148 | public function testCheckUpdateInvalidGitBranch() |
151 | { | 149 | { |
150 | $this->expectException(\Exception::class); | ||
151 | $this->expectExceptionMessageRegExp('/Invalid branch selected for updates/'); | ||
152 | |||
152 | ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable'); | 153 | ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable'); |
153 | } | 154 | } |
154 | 155 | ||
@@ -260,21 +261,23 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase | |||
260 | 261 | ||
261 | /** | 262 | /** |
262 | * Check a unsupported PHP version | 263 | * Check a unsupported PHP version |
263 | * @expectedException Exception | ||
264 | * @expectedExceptionMessageRegExp /Your PHP version is obsolete/ | ||
265 | */ | 264 | */ |
266 | public function testCheckSupportedPHPVersion51() | 265 | public function testCheckSupportedPHPVersion51() |
267 | { | 266 | { |
267 | $this->expectException(\Exception::class); | ||
268 | $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); | ||
269 | |||
268 | $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); | 270 | $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); |
269 | } | 271 | } |
270 | 272 | ||
271 | /** | 273 | /** |
272 | * Check another unsupported PHP version | 274 | * Check another unsupported PHP version |
273 | * @expectedException Exception | ||
274 | * @expectedExceptionMessageRegExp /Your PHP version is obsolete/ | ||
275 | */ | 275 | */ |
276 | public function testCheckSupportedPHPVersion52() | 276 | public function testCheckSupportedPHPVersion52() |
277 | { | 277 | { |
278 | $this->expectException(\Exception::class); | ||
279 | $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); | ||
280 | |||
278 | $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); | 281 | $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); |
279 | } | 282 | } |
280 | 283 | ||