]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/FileUtilsTest.php
Compatibility with PHPUnit 9
[github/shaarli/Shaarli.git] / tests / FileUtilsTest.php
index d764e4953a1bff4870eaca13683e09864c736e42..9163bdf1face0b250ad801b13de5cd96385507a5 100644 (file)
@@ -1,13 +1,15 @@
 <?php
 
-require_once 'application/FileUtils.php';
+namespace Shaarli;
+
+use Exception;
 
 /**
  * Class FileUtilsTest
  *
  * Test file utility class.
  */
-class FileUtilsTest extends PHPUnit_Framework_TestCase
+class FileUtilsTest extends \Shaarli\TestCase
 {
     /**
      * @var string Test file path.
@@ -17,7 +19,7 @@ class FileUtilsTest extends PHPUnit_Framework_TestCase
     /**
      * Delete test file after every test.
      */
-    public function tearDown()
+    protected function tearDown(): void
     {
         @unlink(self::$file);
     }
@@ -47,12 +49,12 @@ class FileUtilsTest extends PHPUnit_Framework_TestCase
 
     /**
      * File not writable: raise an exception.
-     *
-     * @expectedException IOException
-     * @expectedExceptionMessage Error accessing "sandbox/flat.db"
      */
     public function testWriteWithoutPermission()
     {
+        $this->expectException(\Shaarli\Exceptions\IOException::class);
+        $this->expectExceptionMessage('Error accessing "sandbox/flat.db"');
+
         touch(self::$file);
         chmod(self::$file, 0440);
         FileUtils::writeFlatDB(self::$file, null);
@@ -60,23 +62,23 @@ class FileUtilsTest extends PHPUnit_Framework_TestCase
 
     /**
      * Folder non existent: raise an exception.
-     *
-     * @expectedException IOException
-     * @expectedExceptionMessage Error accessing "nopefolder"
      */
     public function testWriteFolderDoesNotExist()
     {
+        $this->expectException(\Shaarli\Exceptions\IOException::class);
+        $this->expectExceptionMessage('Error accessing "nopefolder"');
+
         FileUtils::writeFlatDB('nopefolder/file', null);
     }
 
     /**
      * Folder non writable: raise an exception.
-     *
-     * @expectedException IOException
-     * @expectedExceptionMessage Error accessing "sandbox"
      */
     public function testWriteFolderPermission()
     {
+        $this->expectException(\Shaarli\Exceptions\IOException::class);
+        $this->expectExceptionMessage('Error accessing "sandbox"');
+
         chmod(dirname(self::$file), 0555);
         try {
             FileUtils::writeFlatDB(self::$file, null);