diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-11-05 12:06:59 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-11-05 12:06:59 +0100 |
commit | 1147dc977422e827a201fa081abd07721231d072 (patch) | |
tree | 203d47297c49545a67bbdd98cbe137b255a5d6d8 /tests/lib | |
parent | 88b91a7304f2de998f71a674f4f62e85f5b83e54 (diff) | |
parent | 135680e50bf760d55a1bcaaaa02f959bde396c52 (diff) | |
download | nextcloud-server-1147dc977422e827a201fa081abd07721231d072.tar.gz nextcloud-server-1147dc977422e827a201fa081abd07721231d072.zip |
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Conflicts:
lib/vcategories.php
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/archive.php | 18 | ||||
-rw-r--r-- | tests/lib/cache.php | 12 | ||||
-rw-r--r-- | tests/lib/cache/apc.php | 4 | ||||
-rw-r--r-- | tests/lib/cache/file.php | 2 | ||||
-rw-r--r-- | tests/lib/cache/xcache.php | 2 | ||||
-rw-r--r-- | tests/lib/group.php | 26 | ||||
-rw-r--r-- | tests/lib/share/share.php | 4 | ||||
-rw-r--r-- | tests/lib/streamwrappers.php | 8 | ||||
-rw-r--r-- | tests/lib/template.php | 8 | ||||
-rw-r--r-- | tests/lib/user/backend.php | 32 | ||||
-rw-r--r-- | tests/lib/util.php | 6 |
11 files changed, 61 insertions, 61 deletions
diff --git a/tests/lib/archive.php b/tests/lib/archive.php index 408dc2bbae8..cd2ca6630a5 100644 --- a/tests/lib/archive.php +++ b/tests/lib/archive.php @@ -26,16 +26,16 @@ abstract class Test_Archive extends UnitTestCase { 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'); + $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->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')); $rootContent=$this->instance->getFolder(''); - $expected=array('lorem.txt','logo-wide.png','dir/'); + $expected=array('lorem.txt','logo-wide.png', 'dir/'); $this->assertEqual(3, count($rootContent)); foreach($expected as $file) { $this->assertContains($file, $rootContent, 'cant find '. $file . ' in archive'); @@ -71,14 +71,14 @@ abstract class Test_Archive extends UnitTestCase { $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->instance->addFile('lorem.txt', 'foobar'); $this->assertEqual('foobar', $this->instance->getFile('lorem.txt')); } public function testReadStream() { $dir=OC::$SERVERROOT.'/tests/data'; $this->instance=$this->getExisting(); - $fh=$this->instance->getStream('lorem.txt','r'); + $fh=$this->instance->getStream('lorem.txt', 'r'); $this->assertTrue($fh); $content=fread($fh, $this->instance->filesize('lorem.txt')); fclose($fh); @@ -87,8 +87,8 @@ abstract class Test_Archive extends UnitTestCase { public function testWriteStream() { $dir=OC::$SERVERROOT.'/tests/data'; $this->instance=$this->getNew(); - $fh=$this->instance->getStream('lorem.txt','w'); - $source=fopen($dir.'/lorem.txt','r'); + $fh=$this->instance->getStream('lorem.txt', 'w'); + $source=fopen($dir.'/lorem.txt', 'r'); OCP\Files::streamCopy($source, $fh); fclose($source); fclose($fh); @@ -123,7 +123,7 @@ abstract class Test_Archive extends UnitTestCase { $this->instance=$this->getNew(); $this->instance->addFile('lorem.txt', $textFile); $this->assertFalse($this->instance->fileExists('target.txt')); - $this->instance->rename('lorem.txt','target.txt'); + $this->instance->rename('lorem.txt', 'target.txt'); $this->assertTrue($this->instance->fileExists('target.txt')); $this->assertFalse($this->instance->fileExists('lorem.txt')); $this->assertEqual(file_get_contents($textFile), $this->instance->getFile('target.txt')); diff --git a/tests/lib/cache.php b/tests/lib/cache.php index 7f3eb3ee6fa..1a1287ff135 100644 --- a/tests/lib/cache.php +++ b/tests/lib/cache.php @@ -13,7 +13,7 @@ abstract class Test_Cache extends UnitTestCase { protected $instance; public function tearDown() { - if($this->instance){ + if($this->instance) { $this->instance->clear(); } } @@ -26,22 +26,22 @@ abstract class Test_Cache extends UnitTestCase { $this->instance->set('value1', $value); $this->assertTrue($this->instance->hasKey('value1')); $received=$this->instance->get('value1'); - $this->assertEqual($value, $received,'Value recieved from cache not equal to the original'); + $this->assertEqual($value, $received, 'Value recieved from cache not equal to the original'); $value='ipsum lorum'; $this->instance->set('value1', $value); $received=$this->instance->get('value1'); - $this->assertEqual($value, $received,'Value not overwritten by second set'); + $this->assertEqual($value, $received, 'Value not overwritten by second set'); $value2='foobar'; $this->instance->set('value2', $value2); $received2=$this->instance->get('value2'); $this->assertTrue($this->instance->hasKey('value1')); $this->assertTrue($this->instance->hasKey('value2')); - $this->assertEqual($value, $received,'Value changed while setting other variable'); - $this->assertEqual($value2, $received2,'Second value not equal to original'); + $this->assertEqual($value, $received, 'Value changed while setting other variable'); + $this->assertEqual($value2, $received2, 'Second value not equal to original'); $this->assertFalse($this->instance->hasKey('not_set')); - $this->assertNull($this->instance->get('not_set'),'Unset value not equal to null'); + $this->assertNull($this->instance->get('not_set'), 'Unset value not equal to null'); $this->assertTrue($this->instance->remove('value1')); $this->assertFalse($this->instance->hasKey('value1')); diff --git a/tests/lib/cache/apc.php b/tests/lib/cache/apc.php index f68b97bcbd9..bb5eb483dbf 100644 --- a/tests/lib/cache/apc.php +++ b/tests/lib/cache/apc.php @@ -22,11 +22,11 @@ class Test_Cache_APC extends Test_Cache { public function setUp() { - if(!extension_loaded('apc')){ + if(!extension_loaded('apc')) { $this->markTestSkipped('The apc extension is not available.'); return; } - if(!ini_get('apc.enable_cli') && OC::$CLI){ + if(!ini_get('apc.enable_cli') && OC::$CLI) { $this->markTestSkipped('apc not available in CLI.'); return; } diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 47b18e5b9f4..d64627198e0 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -39,7 +39,7 @@ class Test_Cache_File extends Test_Cache { //set up temporary storage OC_Filesystem::clearMounts(); - OC_Filesystem::mount('OC_Filestorage_Temporary', array(),'/'); + OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); OC_User::clearBackends(); OC_User::useBackend(new OC_User_Dummy()); diff --git a/tests/lib/cache/xcache.php b/tests/lib/cache/xcache.php index c081036a31f..43bed2db037 100644 --- a/tests/lib/cache/xcache.php +++ b/tests/lib/cache/xcache.php @@ -22,7 +22,7 @@ class Test_Cache_XCache extends Test_Cache { public function setUp() { - if(!function_exists('xcache_get')){ + if(!function_exists('xcache_get')) { $this->markTestSkipped('The xcache extension is not available.'); return; } diff --git a/tests/lib/group.php b/tests/lib/group.php index 9ad397b94a6..7b9ca3414b0 100644 --- a/tests/lib/group.php +++ b/tests/lib/group.php @@ -50,15 +50,15 @@ class Test_Group extends UnitTestCase { $this->assertFalse(OC_Group::addToGroup($user1, $group1)); - $this->assertEqual(array($user1),OC_Group::usersInGroup($group1)); - $this->assertEqual(array(),OC_Group::usersInGroup($group2)); + $this->assertEqual(array($user1), OC_Group::usersInGroup($group1)); + $this->assertEqual(array(), OC_Group::usersInGroup($group2)); - $this->assertEqual(array($group1),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::getUserGroups($user2)); + $this->assertEqual(array($group1), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user2)); OC_Group::deleteGroup($group1); - $this->assertEqual(array(),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::usersInGroup($group1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::usersInGroup($group1)); $this->assertFalse(OC_Group::inGroup($user1, $group1)); } @@ -76,13 +76,13 @@ class Test_Group extends UnitTestCase { $this->assertEqual(array($group1), $backend1->getGroups()); $this->assertEqual(array(), $backend2->getGroups()); - $this->assertEqual(array($group1),OC_Group::getGroups()); + $this->assertEqual(array($group1), OC_Group::getGroups()); $this->assertTrue(OC_Group::groupExists($group1)); $this->assertFalse(OC_Group::groupExists($group2)); $backend1->createGroup($group2); - $this->assertEqual(array($group1, $group2),OC_Group::getGroups()); + $this->assertEqual(array($group1, $group2), OC_Group::getGroups()); $this->assertTrue(OC_Group::groupExists($group1)); $this->assertTrue(OC_Group::groupExists($group2)); @@ -101,14 +101,14 @@ class Test_Group extends UnitTestCase { $this->assertFalse(OC_Group::addToGroup($user1, $group1)); - $this->assertEqual(array($user1),OC_Group::usersInGroup($group1)); + $this->assertEqual(array($user1), OC_Group::usersInGroup($group1)); - $this->assertEqual(array($group1),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::getUserGroups($user2)); + $this->assertEqual(array($group1), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user2)); OC_Group::deleteGroup($group1); - $this->assertEqual(array(),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::usersInGroup($group1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::usersInGroup($group1)); $this->assertFalse(OC_Group::inGroup($user1, $group1)); } } diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 3cad3a28680..2cb6f7417d2 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -181,7 +181,7 @@ class Test_Share extends UnitTestCase { $this->assertEquals($message, $exception->getMessage()); } - // Owner grants share and update permission + // Owner grants share and update permission OC_User::setUserId($this->user1); $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_SHARE)); @@ -375,7 +375,7 @@ class Test_Share extends UnitTestCase { $this->assertTrue(in_array('test.txt', $to_test)); $this->assertTrue(in_array('test1.txt', $to_test)); - // Valid reshare + // Valid reshare $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE)); OC_User::setUserId($this->user4); $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php index f864a9e3611..89b2785fca6 100644 --- a/tests/lib/streamwrappers.php +++ b/tests/lib/streamwrappers.php @@ -22,7 +22,7 @@ class Test_StreamWrappers extends UnitTestCase { public function testFakeDir() { - $items=array('foo','bar'); + $items=array('foo', 'bar'); OC_FakeDirStream::$dirs['test']=$items; $dh=opendir('fakedir://test'); $result=array(); @@ -60,9 +60,9 @@ class Test_StreamWrappers extends UnitTestCase { //test callback $tmpFile=OC_Helper::TmpFile('.txt'); $file='close://'.$tmpFile; - OC_CloseStreamWrapper::$callBacks[$tmpFile]=array('Test_StreamWrappers','closeCallBack'); - $fh=fopen($file,'w'); - fwrite($fh,'asd'); + OC_CloseStreamWrapper::$callBacks[$tmpFile]=array('Test_StreamWrappers', 'closeCallBack'); + $fh=fopen($file, 'w'); + fwrite($fh, 'asd'); try{ fclose($fh); $this->fail('Expected exception'); diff --git a/tests/lib/template.php b/tests/lib/template.php index dadfdba5e0c..32ae4aca590 100644 --- a/tests/lib/template.php +++ b/tests/lib/template.php @@ -24,7 +24,7 @@ require_once("lib/template.php"); class Test_TemplateFunctions extends UnitTestCase { - public function testP(){ + public function testP() { // FIXME: do we need more testcases? $htmlString = "<script>alert('xss');</script>"; ob_start(); @@ -35,7 +35,7 @@ class Test_TemplateFunctions extends UnitTestCase { $this->assertEqual("<script>alert('xss');</script>", $result); } - public function testPNormalString(){ + public function testPNormalString() { $normalString = "This is a good string!"; ob_start(); p($normalString); @@ -46,7 +46,7 @@ class Test_TemplateFunctions extends UnitTestCase { } - public function testPrintUnescaped(){ + public function testPrintUnescaped() { $htmlString = "<script>alert('xss');</script>"; ob_start(); @@ -57,7 +57,7 @@ class Test_TemplateFunctions extends UnitTestCase { $this->assertEqual($htmlString, $result); } - public function testPrintUnescapedNormalString(){ + public function testPrintUnescapedNormalString() { $normalString = "This is a good string!"; ob_start(); print_unescaped($normalString); diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php index eb3aa91b683..0b744770ea2 100644 --- a/tests/lib/user/backend.php +++ b/tests/lib/user/backend.php @@ -23,10 +23,10 @@ /** * Abstract class to provide the basis of backend-specific unit test classes. * - * All subclasses MUST assign a backend property in setUp() which implements + * All subclasses MUST assign a backend property in setUp() which implements * user operations (add, remove, etc.). Test methods in this class will then be * run on each separate subclass and backend therein. - * + * * For an example see /tests/lib/user/dummy.php */ @@ -51,12 +51,12 @@ abstract class Test_User_Backend extends UnitTestCase { $name1=$this->getUser(); $name2=$this->getUser(); - $this->backend->createUser($name1,''); + $this->backend->createUser($name1, ''); $count=count($this->backend->getUsers())-$startCount; $this->assertEqual(1, $count); $this->assertTrue((array_search($name1, $this->backend->getUsers())!==false)); $this->assertFalse((array_search($name2, $this->backend->getUsers())!==false)); - $this->backend->createUser($name2,''); + $this->backend->createUser($name2, ''); $count=count($this->backend->getUsers())-$startCount; $this->assertEqual(2, $count); $this->assertTrue((array_search($name1, $this->backend->getUsers())!==false)); @@ -76,24 +76,24 @@ abstract class Test_User_Backend extends UnitTestCase { $this->assertFalse($this->backend->userExists($name1)); $this->assertFalse($this->backend->userExists($name2)); - $this->backend->createUser($name1,'pass1'); - $this->backend->createUser($name2,'pass2'); + $this->backend->createUser($name1, 'pass1'); + $this->backend->createUser($name2, 'pass2'); $this->assertTrue($this->backend->userExists($name1)); $this->assertTrue($this->backend->userExists($name2)); - $this->assertTrue($this->backend->checkPassword($name1,'pass1')); - $this->assertTrue($this->backend->checkPassword($name2,'pass2')); + $this->assertTrue($this->backend->checkPassword($name1, 'pass1')); + $this->assertTrue($this->backend->checkPassword($name2, 'pass2')); - $this->assertFalse($this->backend->checkPassword($name1,'pass2')); - $this->assertFalse($this->backend->checkPassword($name2,'pass1')); + $this->assertFalse($this->backend->checkPassword($name1, 'pass2')); + $this->assertFalse($this->backend->checkPassword($name2, 'pass1')); - $this->assertFalse($this->backend->checkPassword($name1,'dummy')); - $this->assertFalse($this->backend->checkPassword($name2,'foobar')); + $this->assertFalse($this->backend->checkPassword($name1, 'dummy')); + $this->assertFalse($this->backend->checkPassword($name2, 'foobar')); - $this->backend->setPassword($name1,'newpass1'); - $this->assertFalse($this->backend->checkPassword($name1,'pass1')); - $this->assertTrue($this->backend->checkPassword($name1,'newpass1')); - $this->assertFalse($this->backend->checkPassword($name2,'newpass1')); + $this->backend->setPassword($name1, 'newpass1'); + $this->assertFalse($this->backend->checkPassword($name1, 'pass1')); + $this->assertTrue($this->backend->checkPassword($name1, 'newpass1')); + $this->assertFalse($this->backend->checkPassword($name2, 'newpass1')); } } diff --git a/tests/lib/util.php b/tests/lib/util.php index a8e5b810265..27635cb8055 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -10,7 +10,7 @@ class Test_Util extends UnitTestCase { // Constructor function Test_Util() { - date_default_timezone_set("UTC"); + date_default_timezone_set("UTC"); } function testFormatDate() { @@ -36,10 +36,10 @@ class Test_Util extends UnitTestCase { $goodString = "This is an harmless string."; $result = OC_Util::sanitizeHTML($goodString); $this->assertEquals("This is an harmless string.", $result); - } + } function testGenerate_random_bytes() { $result = strlen(OC_Util::generate_random_bytes(59)); $this->assertEquals(59, $result); - } + } }
\ No newline at end of file |