make archive test cases work again
This commit is contained in:
parent
a53999e94e
commit
c4c8dd4e3a
|
@ -29,7 +29,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
$expected=array('lorem.txt','logo-wide.png','dir/','dir/lorem.txt');
|
$expected=array('lorem.txt','logo-wide.png','dir/','dir/lorem.txt');
|
||||||
$this->assertEqual(4,count($allFiles),'only found '.count($allFiles).' out of 4 expected files');
|
$this->assertEqual(4,count($allFiles),'only found '.count($allFiles).' out of 4 expected files');
|
||||||
foreach($expected as $file) {
|
foreach($expected as $file) {
|
||||||
$this->assertNotIdentical(false,array_search($file,$allFiles),'cant find '.$file.' in archive');
|
$this->assertContains($file, $allFiles, 'cant find '. $file . ' in archive');
|
||||||
$this->assertTrue($this->instance->fileExists($file),'file '.$file.' does not exist in archive');
|
$this->assertTrue($this->instance->fileExists($file),'file '.$file.' does not exist in archive');
|
||||||
}
|
}
|
||||||
$this->assertFalse($this->instance->fileExists('non/existing/file'));
|
$this->assertFalse($this->instance->fileExists('non/existing/file'));
|
||||||
|
@ -38,20 +38,20 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
$expected=array('lorem.txt','logo-wide.png','dir/');
|
$expected=array('lorem.txt','logo-wide.png','dir/');
|
||||||
$this->assertEqual(3,count($rootContent));
|
$this->assertEqual(3,count($rootContent));
|
||||||
foreach($expected as $file) {
|
foreach($expected as $file) {
|
||||||
$this->assertNotIdentical(false,array_search($file,$rootContent),'cant find '.$file.' in archive');
|
$this->assertContains($file, $rootContent, 'cant find '. $file . ' in archive');
|
||||||
}
|
}
|
||||||
|
|
||||||
$dirContent=$this->instance->getFolder('dir/');
|
$dirContent=$this->instance->getFolder('dir/');
|
||||||
$expected=array('lorem.txt');
|
$expected=array('lorem.txt');
|
||||||
$this->assertEqual(1,count($dirContent));
|
$this->assertEqual(1,count($dirContent));
|
||||||
foreach($expected as $file) {
|
foreach($expected as $file) {
|
||||||
$this->assertNotIdentical(false,array_search($file,$dirContent),'cant find '.$file.' in archive');
|
$this->assertContains($file, $dirContent, 'cant find '. $file . ' in archive');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testContent() {
|
public function testContent() {
|
||||||
$this->instance=$this->getExisting();
|
$this->instance=$this->getExisting();
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$textFile=$dir.'/lorem.txt';
|
$textFile=$dir.'/lorem.txt';
|
||||||
$this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt'));
|
$this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt'));
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrite() {
|
public function testWrite() {
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$textFile=$dir.'/lorem.txt';
|
$textFile=$dir.'/lorem.txt';
|
||||||
$this->instance=$this->getNew();
|
$this->instance=$this->getNew();
|
||||||
$this->assertEqual(0,count($this->instance->getFiles()));
|
$this->assertEqual(0,count($this->instance->getFiles()));
|
||||||
|
@ -76,7 +76,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReadStream() {
|
public function testReadStream() {
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$this->instance=$this->getExisting();
|
$this->instance=$this->getExisting();
|
||||||
$fh=$this->instance->getStream('lorem.txt','r');
|
$fh=$this->instance->getStream('lorem.txt','r');
|
||||||
$this->assertTrue($fh);
|
$this->assertTrue($fh);
|
||||||
|
@ -85,7 +85,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
$this->assertEqual(file_get_contents($dir.'/lorem.txt'),$content);
|
$this->assertEqual(file_get_contents($dir.'/lorem.txt'),$content);
|
||||||
}
|
}
|
||||||
public function testWriteStream() {
|
public function testWriteStream() {
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$this->instance=$this->getNew();
|
$this->instance=$this->getNew();
|
||||||
$fh=$this->instance->getStream('lorem.txt','w');
|
$fh=$this->instance->getStream('lorem.txt','w');
|
||||||
$source=fopen($dir.'/lorem.txt','r');
|
$source=fopen($dir.'/lorem.txt','r');
|
||||||
|
@ -107,7 +107,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
$this->assertFalse($this->instance->fileExists('/test/'));
|
$this->assertFalse($this->instance->fileExists('/test/'));
|
||||||
}
|
}
|
||||||
public function testExtract() {
|
public function testExtract() {
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$this->instance=$this->getExisting();
|
$this->instance=$this->getExisting();
|
||||||
$tmpDir=OCP\Files::tmpFolder();
|
$tmpDir=OCP\Files::tmpFolder();
|
||||||
$this->instance->extract($tmpDir);
|
$this->instance->extract($tmpDir);
|
||||||
|
@ -118,7 +118,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
OCP\Files::rmdirr($tmpDir);
|
OCP\Files::rmdirr($tmpDir);
|
||||||
}
|
}
|
||||||
public function testMoveRemove() {
|
public function testMoveRemove() {
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$textFile=$dir.'/lorem.txt';
|
$textFile=$dir.'/lorem.txt';
|
||||||
$this->instance=$this->getNew();
|
$this->instance=$this->getNew();
|
||||||
$this->instance->addFile('lorem.txt',$textFile);
|
$this->instance->addFile('lorem.txt',$textFile);
|
||||||
|
@ -131,7 +131,7 @@ abstract class Test_Archive extends UnitTestCase {
|
||||||
$this->assertFalse($this->instance->fileExists('target.txt'));
|
$this->assertFalse($this->instance->fileExists('target.txt'));
|
||||||
}
|
}
|
||||||
public function testRecursive() {
|
public function testRecursive() {
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
$this->instance=$this->getNew();
|
$this->instance=$this->getNew();
|
||||||
$this->instance->addRecursive('/dir',$dir);
|
$this->instance->addRecursive('/dir',$dir);
|
||||||
$this->assertTrue($this->instance->fileExists('/dir/lorem.txt'));
|
$this->assertTrue($this->instance->fileExists('/dir/lorem.txt'));
|
||||||
|
|
|
@ -8,17 +8,13 @@
|
||||||
|
|
||||||
require_once 'archive.php';
|
require_once 'archive.php';
|
||||||
|
|
||||||
if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')) {
|
class Test_Archive_TAR extends Test_Archive {
|
||||||
class Test_Archive_TAR extends Test_Archive{
|
protected function getExisting() {
|
||||||
protected function getExisting() {
|
$dir = OC::$SERVERROOT . '/tests/data';
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
return new OC_Archive_TAR($dir . '/data.tar.gz');
|
||||||
return new OC_Archive_TAR($dir.'/data.tar.gz');
|
}
|
||||||
}
|
|
||||||
|
protected function getNew() {
|
||||||
protected function getNew() {
|
return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
|
||||||
return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
abstract class Test_Archive_TAR extends Test_Archive{}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,13 @@
|
||||||
|
|
||||||
require_once 'archive.php';
|
require_once 'archive.php';
|
||||||
|
|
||||||
if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')) {
|
class Test_Archive_ZIP extends Test_Archive {
|
||||||
class Test_Archive_ZIP extends Test_Archive{
|
protected function getExisting() {
|
||||||
protected function getExisting() {
|
$dir = OC::$SERVERROOT . '/tests/data';
|
||||||
$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
|
return new OC_Archive_ZIP($dir . '/data.zip');
|
||||||
return new OC_Archive_ZIP($dir.'/data.zip');
|
}
|
||||||
}
|
|
||||||
|
protected function getNew() {
|
||||||
protected function getNew() {
|
return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
|
||||||
return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
abstract class Test_Archive_ZIP extends Test_Archive{}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue