aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-05 22:24:36 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-05 22:24:36 +0200
commitc4c8dd4e3a5fcd9a86835566db954662dcb41a0c (patch)
tree60458ed3dd92bf7eef9dec4890774b54d6d71e4e /tests/lib
parenta53999e94ebefc7c87830df5bc52c6b975ad45b4 (diff)
downloadnextcloud-server-c4c8dd4e3a5fcd9a86835566db954662dcb41a0c.tar.gz
nextcloud-server-c4c8dd4e3a5fcd9a86835566db954662dcb41a0c.zip
make archive test cases work again
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/archive.php30
-rw-r--r--tests/lib/archive/tar.php18
-rw-r--r--tests/lib/archive/zip.php18
3 files changed, 29 insertions, 37 deletions
diff --git a/tests/lib/archive.php b/tests/lib/archive.php
index 565c314cb8c..04ae722aea7 100644
--- a/tests/lib/archive.php
+++ b/tests/lib/archive.php
@@ -22,46 +22,46 @@ abstract class Test_Archive extends UnitTestCase {
* @return OC_Archive
*/
abstract protected function getNew();
-
+
public function testGetFiles() {
$this->instance=$this->getExisting();
$allFiles=$this->instance->getFiles();
$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');
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->assertFalse($this->instance->fileExists('non/existing/file'));
-
+
$rootContent=$this->instance->getFolder('');
$expected=array('lorem.txt','logo-wide.png','dir/');
$this->assertEqual(3,count($rootContent));
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/');
$expected=array('lorem.txt');
$this->assertEqual(1,count($dirContent));
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() {
$this->instance=$this->getExisting();
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$textFile=$dir.'/lorem.txt';
$this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt'));
-
+
$tmpFile=OCP\Files::tmpFile('.txt');
$this->instance->extractFile('lorem.txt',$tmpFile);
$this->assertEqual(file_get_contents($textFile),file_get_contents($tmpFile));
}
public function testWrite() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$textFile=$dir.'/lorem.txt';
$this->instance=$this->getNew();
$this->assertEqual(0,count($this->instance->getFiles()));
@@ -69,14 +69,14 @@ abstract class Test_Archive extends UnitTestCase {
$this->assertEqual(1,count($this->instance->getFiles()));
$this->assertTrue($this->instance->fileExists('lorem.txt'));
$this->assertFalse($this->instance->fileExists('lorem.txt/'));
-
+
$this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt'));
$this->instance->addFile('lorem.txt','foobar');
$this->assertEqual('foobar',$this->instance->getFile('lorem.txt'));
}
public function testReadStream() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getExisting();
$fh=$this->instance->getStream('lorem.txt','r');
$this->assertTrue($fh);
@@ -85,7 +85,7 @@ abstract class Test_Archive extends UnitTestCase {
$this->assertEqual(file_get_contents($dir.'/lorem.txt'),$content);
}
public function testWriteStream() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getNew();
$fh=$this->instance->getStream('lorem.txt','w');
$source=fopen($dir.'/lorem.txt','r');
@@ -107,7 +107,7 @@ abstract class Test_Archive extends UnitTestCase {
$this->assertFalse($this->instance->fileExists('/test/'));
}
public function testExtract() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getExisting();
$tmpDir=OCP\Files::tmpFolder();
$this->instance->extract($tmpDir);
@@ -118,7 +118,7 @@ abstract class Test_Archive extends UnitTestCase {
OCP\Files::rmdirr($tmpDir);
}
public function testMoveRemove() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$textFile=$dir.'/lorem.txt';
$this->instance=$this->getNew();
$this->instance->addFile('lorem.txt',$textFile);
@@ -131,7 +131,7 @@ abstract class Test_Archive extends UnitTestCase {
$this->assertFalse($this->instance->fileExists('target.txt'));
}
public function testRecursive() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $dir=OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getNew();
$this->instance->addRecursive('/dir',$dir);
$this->assertTrue($this->instance->fileExists('/dir/lorem.txt'));
diff --git a/tests/lib/archive/tar.php b/tests/lib/archive/tar.php
index 2595b7cb195..51de004813a 100644
--- a/tests/lib/archive/tar.php
+++ b/tests/lib/archive/tar.php
@@ -8,17 +8,13 @@
require_once 'archive.php';
-if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')) {
- class Test_Archive_TAR extends Test_Archive{
- protected function getExisting() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
- return new OC_Archive_TAR($dir.'/data.tar.gz');
- }
+class Test_Archive_TAR extends Test_Archive {
+ protected function getExisting() {
+ $dir = OC::$SERVERROOT . '/tests/data';
+ return new OC_Archive_TAR($dir . '/data.tar.gz');
+ }
- protected function getNew() {
- return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
- }
+ protected function getNew() {
+ return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
}
-}else{
- abstract class Test_Archive_TAR extends Test_Archive{}
}
diff --git a/tests/lib/archive/zip.php b/tests/lib/archive/zip.php
index a7682e34180..adddf81ee1b 100644
--- a/tests/lib/archive/zip.php
+++ b/tests/lib/archive/zip.php
@@ -8,17 +8,13 @@
require_once 'archive.php';
-if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')) {
- class Test_Archive_ZIP extends Test_Archive{
- protected function getExisting() {
- $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
- return new OC_Archive_ZIP($dir.'/data.zip');
- }
+class Test_Archive_ZIP extends Test_Archive {
+ protected function getExisting() {
+ $dir = OC::$SERVERROOT . '/tests/data';
+ return new OC_Archive_ZIP($dir . '/data.zip');
+ }
- protected function getNew() {
- return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
- }
+ protected function getNew() {
+ return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
}
-}else{
- abstract class Test_Archive_ZIP extends Test_Archive{}
}