diff --git a/test/php/library/Icinga/File/Storage/TemporaryLocalFileStorageTest.php b/test/php/library/Icinga/File/Storage/TemporaryLocalFileStorageTest.php new file mode 100644 index 000000000..f7ca0f45f --- /dev/null +++ b/test/php/library/Icinga/File/Storage/TemporaryLocalFileStorageTest.php @@ -0,0 +1,51 @@ +create('foo', 'bar'); + $storage->create('bar', 'foo'); + + $fooPath = $storage->resolvePath('foo'); + $barPath = $storage->resolvePath('bar'); + + $storage = null; + + $this->assertFileNotExists($fooPath); + $this->assertFileNotExists($barPath); + } + + public function testDestructorRemovesDirectories() + { + $storage = new TemporaryLocalFileStorage(); + $storage->create('foo/bar', 'raboof'); + + $dirPath = dirname($storage->resolvePath('foo/bar')); + + $storage = null; + + $this->assertDirectoryNotExists($dirPath); + } + + public function testDestructorRemovesNestedDirectories() + { + $storage = new TemporaryLocalFileStorage(); + $storage->create('a/b/c/fileA', 'foo'); + $storage->create('a/b/d/fileB', 'bar'); + $storage->create('a/e/f/g/h/fileC', 'raboof'); + + $aPath = dirname($storage->resolvePath('a/b/c/fileA'), 3); + + $storage = null; + + $this->assertDirectoryNotExists($aPath); + } +}