X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FFileUtilsTest.php;h=9163bdf1face0b250ad801b13de5cd96385507a5;hb=a5a9cf23acd1248585173aa32757d9720b5f2d62;hp=57719175542c3562af141c0658a9b28e1ba96dcb;hpb=ff3b5dc5542ec150f0d9b447394364a15e9156d0;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/FileUtilsTest.php b/tests/FileUtilsTest.php index 57719175..9163bdf1 100644 --- a/tests/FileUtilsTest.php +++ b/tests/FileUtilsTest.php @@ -9,7 +9,7 @@ use Exception; * * Test file utility class. */ -class FileUtilsTest extends \PHPUnit\Framework\TestCase +class FileUtilsTest extends \Shaarli\TestCase { /** * @var string Test file path. @@ -19,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); } @@ -49,12 +49,12 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase /** * File not writable: raise an exception. - * - * @expectedException Shaarli\Exceptions\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); @@ -62,23 +62,23 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase /** * Folder non existent: raise an exception. - * - * @expectedException Shaarli\Exceptions\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 Shaarli\Exceptions\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);