move storage backend test cases to their own namespace

This commit is contained in:
Robin Appelman 2012-09-22 14:51:15 +02:00
parent 153cd802a9
commit 96b798a59f
9 changed files with 50 additions and 35 deletions

View File

@ -20,12 +20,14 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Test\Files\Storage;
$config = include('apps/files_external/tests/config.php');
if (!is_array($config) or !isset($config['amazons3']) or !$config['amazons3']['run']) {
abstract class Test_Filestorage_AmazonS3 extends Test_FileStorage{}
abstract class AmazonS3 extends Storage{}
return;
} else {
class Test_Filestorage_AmazonS3 extends Test_FileStorage {
class AmazonS3 extends Storage {
private $config;
private $id;
@ -38,7 +40,7 @@ if (!is_array($config) or !isset($config['amazons3']) or !$config['amazons3']['r
}
public function tearDown() {
$s3 = new AmazonS3(array('key' => $this->config['amazons3']['key'], 'secret' => $this->config['amazons3']['secret']));
$s3 = new \AmazonS3(array('key' => $this->config['amazons3']['key'], 'secret' => $this->config['amazons3']['secret']));
if ($s3->delete_all_objects($this->id)) {
$s3->delete_bucket($this->id);
}

View File

@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
namespace Test\Files\Storage;
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']) {
abstract class Test_Filestorage_FTP extends Test_FileStorage{}
abstract class FTP extends Storage{}
return;
}else{
class Test_Filestorage_FTP extends Test_FileStorage {
class FTP extends Storage {
private $config;
public function setUp() {
@ -22,7 +24,7 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']) {
}
public function tearDown() {
OCP\Files::rmdirr($this->instance->constructUrl(''));
\OCP\Files::rmdirr($this->instance->constructUrl(''));
}
}
}

View File

@ -20,12 +20,14 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Test\Files\Storage;
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['google']) or !$config['google']['run']) {
abstract class Test_Filestorage_Google extends Test_FileStorage{}
abstract class Google extends Storage{}
return;
}else{
class Test_Filestorage_Google extends Test_FileStorage {
class Google extends Storage {
private $config;

View File

@ -8,11 +8,13 @@
$config=include('apps/files_external/tests/config.php');
namespace Test\Files\Storage;
if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']) {
abstract class Test_Filestorage_SMB extends Test_FileStorage{}
abstract class SMB extends Storage{}
return;
}else{
class Test_Filestorage_SMB extends Test_FileStorage {
class SMB extends Storage {
private $config;
public function setUp() {
@ -23,7 +25,7 @@ if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']) {
}
public function tearDown() {
OCP\Files::rmdirr($this->instance->constructUrl(''));
\OCP\Files::rmdirr($this->instance->constructUrl(''));
}
}
}

View File

@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
namespace Test\Files\Storage;
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']) {
abstract class Test_Filestorage_SWIFT extends Test_FileStorage{}
abstract class SWIFT extends Storage{}
return;
}else{
class Test_Filestorage_SWIFT extends Test_FileStorage {
class SWIFT extends Storage {
private $config;
public function setUp() {

View File

@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
namespace Test\Files\Storage;
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']) {
abstract class Test_Filestorage_DAV extends Test_FileStorage{}
abstract class DAV extends Storage{}
return;
}else{
class Test_Filestorage_DAV extends Test_FileStorage {
class DAV extends Storage {
private $config;
public function setUp() {

View File

@ -20,7 +20,9 @@
*
*/
class Test_Filestorage_CommonTest extends Test_FileStorage {
namespace Test\Files\Storage;
class CommonTest extends Storage {
/**
* @var string tmpDir
*/
@ -34,7 +36,7 @@ class Test_Filestorage_CommonTest extends Test_FileStorage {
}
public function tearDown() {
OC_Helper::rmdirr($this->tmpDir);
\OC_Helper::rmdirr($this->tmpDir);
}
}

View File

@ -20,19 +20,19 @@
*
*/
class Test_Filestorage_Local extends Test_FileStorage {
namespace Test\Files\Storage;
class Local extends Storage {
/**
* @var string tmpDir
*/
private $tmpDir;
public function setUp() {
$this->tmpDir=OC_Helper::tmpFolder();
$this->tmpDir=\OC_Helper::tmpFolder();
$this->instance=new \OC\Files\Storage\Local(array('datadir'=>$this->tmpDir));
}
public function tearDown() {
OC_Helper::rmdirr($this->tmpDir);
\OC_Helper::rmdirr($this->tmpDir);
}
}
?>

View File

@ -20,7 +20,9 @@
*
*/
abstract class Test_FileStorage extends UnitTestCase {
namespace Test\Files\Storage;
abstract class Storage extends \UnitTestCase {
/**
* @var \OC\Files\Storage\Storage instance
*/
@ -83,7 +85,7 @@ abstract class Test_FileStorage extends UnitTestCase {
* test the various uses of file_get_contents and file_put_contents
*/
public function testGetPutContents() {
$sourceFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
$sourceFile=\OC::$SERVERROOT.'/tests/data/lorem.txt';
$sourceText=file_get_contents($sourceFile);
//fill a file with string data
@ -103,21 +105,21 @@ abstract class Test_FileStorage extends UnitTestCase {
$this->assertEqual('httpd/unix-directory',$this->instance->getMimeType('/'));
$this->assertEqual(false,$this->instance->getMimeType('/non/existing/file'));
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
$textFile=\OC::$SERVERROOT.'/tests/data/lorem.txt';
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile,'r'));
$this->assertEqual('text/plain',$this->instance->getMimeType('/lorem.txt'));
$pngFile=OC::$SERVERROOT.'/tests/data/logo-wide.png';
$pngFile=\OC::$SERVERROOT.'/tests/data/logo-wide.png';
$this->instance->file_put_contents('/logo-wide.png',file_get_contents($pngFile,'r'));
$this->assertEqual('image/png',$this->instance->getMimeType('/logo-wide.png'));
$svgFile=OC::$SERVERROOT.'/tests/data/logo-wide.svg';
$svgFile=\OC::$SERVERROOT.'/tests/data/logo-wide.svg';
$this->instance->file_put_contents('/logo-wide.svg',file_get_contents($svgFile,'r'));
$this->assertEqual('image/svg+xml',$this->instance->getMimeType('/logo-wide.svg'));
}
public function testCopyAndMove() {
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
$textFile=\OC::$SERVERROOT.'/tests/data/lorem.txt';
$this->instance->file_put_contents('/source.txt',file_get_contents($textFile));
$this->instance->copy('/source.txt','/target.txt');
$this->assertTrue($this->instance->file_exists('/target.txt'));
@ -130,7 +132,7 @@ abstract class Test_FileStorage extends UnitTestCase {
}
public function testLocal() {
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
$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));
@ -151,7 +153,7 @@ abstract class Test_FileStorage extends UnitTestCase {
}
public function testStat() {
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
$textFile=\OC::$SERVERROOT.'/tests/data/lorem.txt';
$ctimeStart=time();
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile));
$this->assertTrue($this->instance->isReadable('/lorem.txt'));
@ -198,7 +200,6 @@ abstract class Test_FileStorage extends UnitTestCase {
fclose($fh);
clearstatcache();
$mtimeEnd=time();
$originalCTime=$cTime;
$mTime=$this->instance->filemtime('/lorem.txt');
$this->assertTrue(($mtimeStart-1)<=$mTime);
$this->assertTrue($mTime<=($mtimeEnd+1));
@ -208,11 +209,11 @@ abstract class Test_FileStorage extends UnitTestCase {
}
public function testSearch() {
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
$textFile=\OC::$SERVERROOT.'/tests/data/lorem.txt';
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile,'r'));
$pngFile=OC::$SERVERROOT.'/tests/data/logo-wide.png';
$pngFile=\OC::$SERVERROOT.'/tests/data/logo-wide.png';
$this->instance->file_put_contents('/logo-wide.png',file_get_contents($pngFile,'r'));
$svgFile=OC::$SERVERROOT.'/tests/data/logo-wide.svg';
$svgFile=\OC::$SERVERROOT.'/tests/data/logo-wide.svg';
$this->instance->file_put_contents('/logo-wide.svg',file_get_contents($svgFile,'r'));
$result=$this->instance->search('logo');
$this->assertEqual(2,count($result));