X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FFileUtilsTest.php;h=57719175542c3562af141c0658a9b28e1ba96dcb;hb=HEAD;hp=d764e4953a1bff4870eaca13683e09864c736e42;hpb=3e395a6bc63cba16b0772a382f6cbac0ce4ab906;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/FileUtilsTest.php b/tests/FileUtilsTest.php deleted file mode 100644 index d764e495..00000000 --- a/tests/FileUtilsTest.php +++ /dev/null @@ -1,108 +0,0 @@ -assertTrue(FileUtils::writeFlatDB(self::$file, $data) > 0); - $this->assertTrue(startsWith(file_get_contents(self::$file), 'assertEquals($data, FileUtils::readFlatDB(self::$file)); - - $data = 0; - $this->assertTrue(FileUtils::writeFlatDB(self::$file, $data) > 0); - $this->assertEquals($data, FileUtils::readFlatDB(self::$file)); - - $data = null; - $this->assertTrue(FileUtils::writeFlatDB(self::$file, $data) > 0); - $this->assertEquals($data, FileUtils::readFlatDB(self::$file)); - - $data = false; - $this->assertTrue(FileUtils::writeFlatDB(self::$file, $data) > 0); - $this->assertEquals($data, FileUtils::readFlatDB(self::$file)); - } - - /** - * File not writable: raise an exception. - * - * @expectedException IOException - * @expectedExceptionMessage Error accessing "sandbox/flat.db" - */ - public function testWriteWithoutPermission() - { - touch(self::$file); - chmod(self::$file, 0440); - FileUtils::writeFlatDB(self::$file, null); - } - - /** - * Folder non existent: raise an exception. - * - * @expectedException IOException - * @expectedExceptionMessage Error accessing "nopefolder" - */ - public function testWriteFolderDoesNotExist() - { - FileUtils::writeFlatDB('nopefolder/file', null); - } - - /** - * Folder non writable: raise an exception. - * - * @expectedException IOException - * @expectedExceptionMessage Error accessing "sandbox" - */ - public function testWriteFolderPermission() - { - chmod(dirname(self::$file), 0555); - try { - FileUtils::writeFlatDB(self::$file, null); - } catch (Exception $e) { - chmod(dirname(self::$file), 0755); - throw $e; - } - } - - /** - * Read non existent file, use default parameter. - */ - public function testReadNotExistentFile() - { - $this->assertEquals(null, FileUtils::readFlatDB(self::$file)); - $this->assertEquals(['test'], FileUtils::readFlatDB(self::$file, ['test'])); - } - - /** - * Read non readable file, use default parameter. - */ - public function testReadNotReadable() - { - touch(self::$file); - chmod(self::$file, 0220); - $this->assertEquals(null, FileUtils::readFlatDB(self::$file)); - $this->assertEquals(['test'], FileUtils::readFlatDB(self::$file, ['test'])); - } -}