diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-02-29 23:47:53 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-02-29 23:47:53 +0100 |
commit | f193e474c1f499458f6d18ba6d7fa7f83c2098c8 (patch) | |
tree | 73a86890b3e69b42547ae789777b4c8a45b78976 /tests | |
parent | e76e4e75407cc672bf342f13bbd77392a93c1623 (diff) | |
download | nextcloud-server-f193e474c1f499458f6d18ba6d7fa7f83c2098c8.tar.gz nextcloud-server-f193e474c1f499458f6d18ba6d7fa7f83c2098c8.zip |
add test cases for stat and touch
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/filestorage.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/lib/filestorage.php b/tests/lib/filestorage.php index fb050868ee3..6296d7abf99 100644 --- a/tests/lib/filestorage.php +++ b/tests/lib/filestorage.php @@ -126,4 +126,49 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertTrue(file_exists($localFile)); $this->assertEqual(file_get_contents($localFile),file_get_contents($textFile)); } + + public function testStat(){ + $textFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; + $ctimeStart=time(); + $this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile)); + $this->assertTrue($this->instance->is_readable('/lorem.txt')); + $ctimeEnd=time(); + $cTime=$this->instance->filectime('/lorem.txt'); + $mTime=$this->instance->filemtime('/lorem.txt'); + $this->assertTrue($ctimeStart<=$cTime); + $this->assertTrue($cTime<=$ctimeEnd); + $this->assertEqual($cTime,$mTime); + $this->assertEqual(filesize($textFile),$this->instance->filesize('/lorem.txt')); + + $stat=$this->instance->stat('/lorem.txt'); + //only size, mtime and ctime are requered in the result + $this->assertEqual($stat['size'],$this->instance->filesize('/lorem.txt')); + $this->assertEqual($stat['mtime'],$mTime); + $this->assertEqual($stat['ctime'],$cTime); + + $mtimeStart=time(); + $this->instance->touch('/lorem.txt'); + $mtimeEnd=time(); + $originalCTime=$cTime; + $cTime=$this->instance->filectime('/lorem.txt'); + $mTime=$this->instance->filemtime('/lorem.txt'); + $this->assertTrue($mtimeStart<=$mTime); + $this->assertTrue($mTime<=$mtimeEnd); + $this->assertEqual($cTime,$originalCTime); + + $this->instance->touch('/lorem.txt',100); + $mTime=$this->instance->filemtime('/lorem.txt'); + $this->assertEqual($mTime,100); + + $mtimeStart=time(); + $fh=$this->instance->fopen('/lorem.txt','a'); + fwrite($fh,' '); + fclose($fh); + clearstatcache(); + $mtimeEnd=time(); + $originalCTime=$cTime; + $mTime=$this->instance->filemtime('/lorem.txt'); + $this->assertTrue($mtimeStart<=$mTime); + $this->assertTrue($mTime<=$mtimeEnd); + } } |