Commit 90b15dfb authored by Laurent's avatar Laurent

add filesize to storm filesystem

parent 5e356081
Pipeline #1323 passed with stage
in 5 seconds
......@@ -35,6 +35,11 @@ class Storm_FileSystem_Disk {
}
public function fileGetSize($path) {
return filesize($path);
}
public function filePutContents($path, $data) {
file_put_contents($path, $data);
return $this;
......
......@@ -72,6 +72,13 @@ class Storm_FileSystem_Volatile {
}
public function fileGetSize($path) {
if (!$file = $this->asPath($path)->asEntry())
return 0;
return $file->getSize();
}
public function rm($path) {
$this->asPath($path)->rm();
return $this;
......@@ -315,17 +322,25 @@ class Storm_FileSystem_Volatile_File extends Storm_FileSystem_Volatile_Entry {
return false;
}
public function isFile() {
return true;
}
public function putContents($contents) {
$this->_contents = $contents;
}
public function getContents() {
return $this->_contents;
}
public function getSize() {
return strlen($this->_contents);
}
}
......
......@@ -60,12 +60,25 @@ class Storm_FileSystem_VolatileTest extends PHPUnit_Framework_TestCase {
}
/** @test */
public function notesTxtFileGetSizeTxtShouldAnswersFifteen() {
$this->assertEquals(15,
$this->_fs->fileGetSize('/var/notes.txt'));
}
/** @test */
public function ghostGetContentsShouldAnswersNull() {
$this->assertNull($this->_fs->fileGetContents('ghost.txt'));
}
/** @test */
public function ghostFileGetSizeShouldAnswersZero() {
$this->assertSame(0, $this->_fs->fileGetSize('ghost.txt'));
}
public function validPaths() {
return [
['/etc'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment