tests: Introduce `TemporaryLocalFileStorageTest`

refs #4630
This commit is contained in:
Johannes Meyer 2022-01-11 10:59:57 +01:00
parent 316885b271
commit 509d642982
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
<?php
/* Icinga Web 2 | (c) 2022 Icinga Development Team | GPLv2+ */
namespace Tests\Icinga\File\Storage;
use Icinga\File\Storage\TemporaryLocalFileStorage;
use Icinga\Test\BaseTestCase;
class TemporaryLocalFileStorageTest extends BaseTestCase
{
public function testDestructorRemovesFiles()
{
$storage = new TemporaryLocalFileStorage();
$storage->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);
}
}