aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-09-29 15:00:11 +0200
committerArthurHoaro <arthur@hoa.ro>2020-09-29 18:57:22 +0200
commitab58f2542072e6bf34acd862f6cfed84b33feb29 (patch)
treea773a2ad2b98cd8e68c6f3c45c294e036cf3bd41
parenta5a9cf23acd1248585173aa32757d9720b5f2d62 (diff)
downloadShaarli-ab58f2542072e6bf34acd862f6cfed84b33feb29.tar.gz
Shaarli-ab58f2542072e6bf34acd862f6cfed84b33feb29.tar.zst
Shaarli-ab58f2542072e6bf34acd862f6cfed84b33feb29.zip
Compatibility with PHP 8
-rw-r--r--.travis.yml3
-rw-r--r--application/config/ConfigJson.php2
-rw-r--r--tests/PluginManagerTest.php4
-rw-r--r--tests/config/ConfigJsonTest.php13
-rw-r--r--tests/updater/DummyUpdater.php8
5 files changed, 11 insertions, 19 deletions
diff --git a/.travis.yml b/.travis.yml
index 5f86d338..25304120 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,9 @@ matrix:
8 install: 8 install:
9 - composer self-update --2 9 - composer self-update --2
10 - composer update --ignore-platform-req=php 10 - composer update --ignore-platform-req=php
11 - composer remove phpunit/phpunit
12 - composer require --dev --ignore-platform-req=php phpunit/php-text-template ^2.0
13 - composer require --dev --ignore-platform-req=php phpunit/phpunit ^9.0
11 - language: php 14 - language: php
12 php: 7.4 15 php: 7.4
13 - language: php 16 - language: php
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php
index 4509357c..c0c0dab9 100644
--- a/application/config/ConfigJson.php
+++ b/application/config/ConfigJson.php
@@ -46,7 +46,7 @@ class ConfigJson implements ConfigIO
46 // JSON_PRETTY_PRINT is available from PHP 5.4. 46 // JSON_PRETTY_PRINT is available from PHP 5.4.
47 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; 47 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
48 $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix(); 48 $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
49 if (!file_put_contents($filepath, $data)) { 49 if (empty($filepath) || !file_put_contents($filepath, $data)) {
50 throw new \Shaarli\Exceptions\IOException( 50 throw new \Shaarli\Exceptions\IOException(
51 $filepath, 51 $filepath,
52 t('Shaarli could not create the config file. '. 52 t('Shaarli could not create the config file. '.
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php
index 38cd5eba..bbd2e142 100644
--- a/tests/PluginManagerTest.php
+++ b/tests/PluginManagerTest.php
@@ -81,8 +81,8 @@ class PluginManagerTest extends \Shaarli\TestCase
81 $data = []; 81 $data = [];
82 $this->pluginManager->executeHooks('error', $data); 82 $this->pluginManager->executeHooks('error', $data);
83 83
84 $this->assertSame( 84 $this->assertMatchesRegularExpression(
85 'test [plugin incompatibility]: Class \'Unknown\' not found', 85 '/test \[plugin incompatibility\]: Class [\'"]Unknown[\'"] not found/',
86 $this->pluginManager->getErrors()[0] 86 $this->pluginManager->getErrors()[0]
87 ); 87 );
88 } 88 }
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index 4f508925..c0ba5b8f 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -42,7 +42,7 @@ class ConfigJsonTest extends \Shaarli\TestCase
42 public function testReadInvalidJson() 42 public function testReadInvalidJson()
43 { 43 {
44 $this->expectException(\Exception::class); 44 $this->expectException(\Exception::class);
45 $this->expectExceptionMessageRegExp(' /An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/'); 45 $this->expectExceptionMessageRegExp('/An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/');
46 46
47 $this->configIO->read('tests/utils/config/configInvalid.json.php'); 47 $this->configIO->read('tests/utils/config/configInvalid.json.php');
48 } 48 }
@@ -111,17 +111,6 @@ class ConfigJsonTest extends \Shaarli\TestCase
111 /** 111 /**
112 * Write to invalid path. 112 * Write to invalid path.
113 */ 113 */
114 public function testWriteInvalidArray()
115 {
116 $this->expectException(\Shaarli\Exceptions\IOException::class);
117
118 $conf = array('conf' => 'value');
119 @$this->configIO->write(array(), $conf);
120 }
121
122 /**
123 * Write to invalid path.
124 */
125 public function testWriteInvalidBlank() 114 public function testWriteInvalidBlank()
126 { 115 {
127 $this->expectException(\Shaarli\Exceptions\IOException::class); 116 $this->expectException(\Shaarli\Exceptions\IOException::class);
diff --git a/tests/updater/DummyUpdater.php b/tests/updater/DummyUpdater.php
index 07c7f5c4..3403233f 100644
--- a/tests/updater/DummyUpdater.php
+++ b/tests/updater/DummyUpdater.php
@@ -37,7 +37,7 @@ class DummyUpdater extends Updater
37 * 37 *
38 * @return bool true. 38 * @return bool true.
39 */ 39 */
40 final private function updateMethodDummy1() 40 final protected function updateMethodDummy1()
41 { 41 {
42 return true; 42 return true;
43 } 43 }
@@ -47,7 +47,7 @@ class DummyUpdater extends Updater
47 * 47 *
48 * @return bool true. 48 * @return bool true.
49 */ 49 */
50 final private function updateMethodDummy2() 50 final protected function updateMethodDummy2()
51 { 51 {
52 return true; 52 return true;
53 } 53 }
@@ -57,7 +57,7 @@ class DummyUpdater extends Updater
57 * 57 *
58 * @return bool true. 58 * @return bool true.
59 */ 59 */
60 final private function updateMethodDummy3() 60 final protected function updateMethodDummy3()
61 { 61 {
62 return true; 62 return true;
63 } 63 }
@@ -67,7 +67,7 @@ class DummyUpdater extends Updater
67 * 67 *
68 * @throws Exception error. 68 * @throws Exception error.
69 */ 69 */
70 final private function updateMethodException() 70 final protected function updateMethodException()
71 { 71 {
72 throw new Exception('whatever'); 72 throw new Exception('whatever');
73 } 73 }