]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Compatibility with PHP 8
authorArthurHoaro <arthur@hoa.ro>
Tue, 29 Sep 2020 13:00:11 +0000 (15:00 +0200)
committerArthurHoaro <arthur@hoa.ro>
Tue, 29 Sep 2020 16:57:22 +0000 (18:57 +0200)
.travis.yml
application/config/ConfigJson.php
tests/PluginManagerTest.php
tests/config/ConfigJsonTest.php
tests/updater/DummyUpdater.php

index 5f86d3388344600455138f51096202ddd08e7c8a..25304120470574cb951f19aafb28e0075e322646 100644 (file)
@@ -8,6 +8,9 @@ matrix:
       install:
         - composer self-update --2
         - composer update --ignore-platform-req=php
+        - composer remove phpunit/phpunit
+        - composer require --dev --ignore-platform-req=php phpunit/php-text-template ^2.0
+        - composer require --dev --ignore-platform-req=php phpunit/phpunit ^9.0
     - language: php
       php: 7.4
     - language: php
index 4509357ce887ea8a28334a68c50f999294780243..c0c0dab9ab9df4ce10f0a8217ae28a88dc011483 100644 (file)
@@ -46,7 +46,7 @@ class ConfigJson implements ConfigIO
         // JSON_PRETTY_PRINT is available from PHP 5.4.
         $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
         $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
-        if (!file_put_contents($filepath, $data)) {
+        if (empty($filepath) || !file_put_contents($filepath, $data)) {
             throw new \Shaarli\Exceptions\IOException(
                 $filepath,
                 t('Shaarli could not create the config file. '.
index 38cd5ebaeeb05db58c435be68c08d1c4408acd9e..bbd2e142feb7b21f84f73869f4225e43e5c80c07 100644 (file)
@@ -81,8 +81,8 @@ class PluginManagerTest extends \Shaarli\TestCase
         $data = [];
         $this->pluginManager->executeHooks('error', $data);
 
-        $this->assertSame(
-            'test [plugin incompatibility]: Class \'Unknown\' not found',
+        $this->assertMatchesRegularExpression(
+            '/test \[plugin incompatibility\]: Class [\'"]Unknown[\'"] not found/',
             $this->pluginManager->getErrors()[0]
         );
     }
index 4f50892582416bd39589f45b9b9ac5e9ac814ec9..c0ba5b8f07c1c0513ae26050408b3c76f326b9ae 100644 (file)
@@ -42,7 +42,7 @@ class ConfigJsonTest extends \Shaarli\TestCase
     public function testReadInvalidJson()
     {
         $this->expectException(\Exception::class);
-        $this->expectExceptionMessageRegExp(' /An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/');
+        $this->expectExceptionMessageRegExp('/An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/');
 
         $this->configIO->read('tests/utils/config/configInvalid.json.php');
     }
@@ -108,17 +108,6 @@ class ConfigJsonTest extends \Shaarli\TestCase
         unlink($dest);
     }
 
-    /**
-     * Write to invalid path.
-     */
-    public function testWriteInvalidArray()
-    {
-        $this->expectException(\Shaarli\Exceptions\IOException::class);
-
-        $conf = array('conf' => 'value');
-        @$this->configIO->write(array(), $conf);
-    }
-
     /**
      * Write to invalid path.
      */
index 07c7f5c48efd4b54ad35aff320a3b75b134038a6..3403233febf6d904ccefa817cb4719e5375a0ffa 100644 (file)
@@ -37,7 +37,7 @@ class DummyUpdater extends Updater
      *
      * @return bool true.
      */
-    final private function updateMethodDummy1()
+    final protected function updateMethodDummy1()
     {
         return true;
     }
@@ -47,7 +47,7 @@ class DummyUpdater extends Updater
      *
      * @return bool true.
      */
-    final private function updateMethodDummy2()
+    final protected function updateMethodDummy2()
     {
         return true;
     }
@@ -57,7 +57,7 @@ class DummyUpdater extends Updater
      *
      * @return bool true.
      */
-    final private function updateMethodDummy3()
+    final protected function updateMethodDummy3()
     {
         return true;
     }
@@ -67,7 +67,7 @@ class DummyUpdater extends Updater
      *
      * @throws Exception error.
      */
-    final private function updateMethodException()
+    final protected function updateMethodException()
     {
         throw new Exception('whatever');
     }