Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 59 additions & 13 deletions tests/lib/Files/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,51 @@ public function testTestFunction() {
* @dataProvider directoryProvider
*/
public function testDirectories($directory) {
$this->assertFalse($this->instance->file_exists('/' . $directory));
$this->assertFalse(
$this->instance->file_exists('/' . $directory),
"The folder '$directory' already exists at the start of the test"
);

$this->assertTrue($this->instance->mkdir('/' . $directory));
$this->assertTrue(
$this->instance->mkdir('/' . $directory),
"The folder '$directory' could not be created"
);

$this->assertTrue($this->instance->file_exists('/' . $directory));
$this->assertTrue($this->instance->is_dir('/' . $directory));
$this->assertFalse($this->instance->is_file('/' . $directory));
$this->assertEquals('dir', $this->instance->filetype('/' . $directory));
$this->assertEquals(0, $this->instance->filesize('/' . $directory));
$this->assertTrue($this->instance->isReadable('/' . $directory));
$this->assertTrue($this->instance->isUpdatable('/' . $directory));
$this->assertTrue(
$this->instance->file_exists('/' . $directory),
"The folder '$directory' does not exist"
);
$this->assertTrue(
$this->instance->is_dir('/' . $directory),
"The folder '$directory' is not a directory"
);
$this->assertFalse(
$this->instance->is_file('/' . $directory),
"The folder '$directory' is actually a file"
);
$fileType = $this->instance->filetype('/' . $directory);
if ($fileType === false) {
$this->fail("The file type of folder '$directory' could not be determined");
}
$this->assertEquals(
'dir',
$fileType,
"The folder '$directory' is file type $fileType, not 'dir'"
);
$fileSize = $this->instance->filesize('/' . $directory);
$this->assertEquals(
0,
$fileSize,
"The empty folder '$directory' has non-zero size " . (string) $fileSize
);
$this->assertTrue(
$this->instance->isReadable('/' . $directory),
"The folder '$directory' is not readable"
);
$this->assertTrue(
$this->instance->isUpdatable('/' . $directory),
"The folder '$directory' is not updatable"
);

$dh = $this->instance->opendir('/');
$content = [];
Expand All @@ -87,13 +121,25 @@ public function testDirectories($directory) {
}
$this->assertEquals([$directory], $content);

$this->assertFalse($this->instance->mkdir('/' . $directory)); //can't create existing folders
$this->assertTrue($this->instance->rmdir('/' . $directory));
$this->assertFalse(
$this->instance->mkdir('/' . $directory),
"The folder '$directory' could be created again when it already exists"
); //can't create existing folders
$this->assertTrue(
$this->instance->rmdir('/' . $directory),
"The folder '$directory' could not be deleted"
);

$this->wait();
$this->assertFalse($this->instance->file_exists('/' . $directory));
$this->assertFalse(
$this->instance->file_exists('/' . $directory),
"The folder '$directory' still exists after deleting it"
);

$this->assertFalse($this->instance->rmdir('/' . $directory)); //can't remove non existing folders
$this->assertFalse(
$this->instance->rmdir('/' . $directory),
"The folder '$directory' could be deleted again even though it was just deleted"
); //can't remove non-existing folders

$dh = $this->instance->opendir('/');
$content = [];
Expand Down