add test case for getLocalFile
This commit is contained in:
parent
de37bafa5c
commit
d1c3aa3112
|
@ -108,7 +108,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
|
||||||
// abstract public function free_space($path);
|
// abstract public function free_space($path);
|
||||||
// abstract public function search($query);
|
// abstract public function search($query);
|
||||||
public function getLocalFile($path){
|
public function getLocalFile($path){
|
||||||
return $this->toTmpFile();
|
return $this->toTmpFile($path);
|
||||||
}
|
}
|
||||||
private function toTmpFile($path){//no longer in the storage api, still usefull here
|
private function toTmpFile($path){//no longer in the storage api, still usefull here
|
||||||
$source=$this->fopen($path,'r');
|
$source=$this->fopen($path,'r');
|
||||||
|
@ -117,7 +117,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
|
||||||
}
|
}
|
||||||
$extention=substr($path,strrpos($path,'.'));
|
$extention=substr($path,strrpos($path,'.'));
|
||||||
$tmpFile=OC_Helper::tmpFile($extention);
|
$tmpFile=OC_Helper::tmpFile($extention);
|
||||||
$target=fopen($tmpFile);
|
$target=fopen($tmpFile,'w');
|
||||||
$count=OC_Helper::streamCopy($source,$target);
|
$count=OC_Helper::streamCopy($source,$target);
|
||||||
return $tmpFile;
|
return $tmpFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,12 @@ abstract class Test_FileStorage extends UnitTestCase {
|
||||||
$this->assertFalse($this->instance->file_exists('/source.txt'));
|
$this->assertFalse($this->instance->file_exists('/source.txt'));
|
||||||
$this->assertEqual(file_get_contents($textFile),$this->instance->file_get_contents('/target.txt'));
|
$this->assertEqual(file_get_contents($textFile),$this->instance->file_get_contents('/target.txt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLocalFile(){
|
||||||
|
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||||
|
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile));
|
||||||
|
$localFile=$this->instance->getLocalFile('/lorem.txt');
|
||||||
|
$this->assertTrue(file_exists($localFile));
|
||||||
|
$this->assertEqual(file_get_contents($localFile),file_get_contents($textFile));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue