diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-05-15 23:49:41 +0200 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-05-15 23:49:41 +0200 |
commit | 3c779b0632809718b3f39403fdb68b7e160b5a0b (patch) | |
tree | fc839ff3ed0a229dc6c887b467d7402359d9aac0 /tests | |
parent | 990f23c0249682043c9e0dd42f33c478e2aa9131 (diff) | |
parent | dfddaf8fbf5ff515f26ff462c7ba6166b3d0ed18 (diff) | |
download | nextcloud-server-3c779b0632809718b3f39403fdb68b7e160b5a0b.tar.gz nextcloud-server-3c779b0632809718b3f39403fdb68b7e160b5a0b.zip |
Merge branch 'master' into hooks
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/autoloader.php | 65 | ||||
-rw-r--r-- | tests/lib/files/cache/cache.php | 7 | ||||
-rw-r--r-- | tests/lib/files/cache/permissions.php | 6 | ||||
-rw-r--r-- | tests/lib/public/contacts.php | 2 | ||||
-rw-r--r-- | tests/lib/template.php | 7 | ||||
-rw-r--r-- | tests/lib/vobject.php | 19 |
6 files changed, 92 insertions, 14 deletions
diff --git a/tests/lib/autoloader.php b/tests/lib/autoloader.php index e769bf3bcf6..0e7d606ccf6 100644 --- a/tests/lib/autoloader.php +++ b/tests/lib/autoloader.php @@ -6,14 +6,69 @@ * See the COPYING-README file. */ -class Test_AutoLoader extends PHPUnit_Framework_TestCase { +namespace Test; - public function testLeadingSlashOnClassName(){ - $this->assertTrue(class_exists('\OC\Files\Storage\Local')); +class AutoLoader extends \PHPUnit_Framework_TestCase { + /** + * @var \OC\Autoloader $loader + */ + private $loader; + + public function setUp() { + $this->loader = new \OC\AutoLoader(); + } + + public function testLeadingSlashOnClassName() { + $this->assertEquals(array('files/storage/local.php'), $this->loader->findClass('\OC\Files\Storage\Local')); + } + + public function testNoLeadingSlashOnClassName() { + $this->assertEquals(array('files/storage/local.php'), $this->loader->findClass('OC\Files\Storage\Local')); + } + + public function testLegacyPath() { + $this->assertEquals(array('legacy/files.php', 'files.php'), $this->loader->findClass('OC_Files')); + } + + public function testClassPath() { + $this->loader->registerClass('Foo\Bar', 'foobar.php'); + $this->assertEquals(array('foobar.php'), $this->loader->findClass('Foo\Bar')); + } + + public function testPrefixNamespace() { + $this->loader->registerPrefix('Foo', 'foo'); + $this->assertEquals(array('foo/Foo/Bar.php'), $this->loader->findClass('Foo\Bar')); } - public function testNoLeadingSlashOnClassName(){ - $this->assertTrue(class_exists('OC\Files\Storage\Local')); + public function testPrefix() { + $this->loader->registerPrefix('Foo_', 'foo'); + $this->assertEquals(array('foo/Foo/Bar.php'), $this->loader->findClass('Foo_Bar')); } + public function testLoadTestNamespace() { + $this->assertEquals(array('tests/lib/foo/bar.php'), $this->loader->findClass('Test\Foo\Bar')); + } + + public function testLoadTest() { + $this->assertEquals(array('tests/lib/foo/bar.php'), $this->loader->findClass('Test_Foo_Bar')); + } + + public function testLoadCoreNamespace() { + $this->assertEquals(array('foo/bar.php'), $this->loader->findClass('OC\Foo\Bar')); + } + + public function testLoadCore() { + $this->assertEquals(array('legacy/foo/bar.php', 'foo/bar.php'), $this->loader->findClass('OC_Foo_Bar')); + } + + public function testLoadPublicNamespace() { + $this->assertEquals(array('public/foo/bar.php'), $this->loader->findClass('OCP\Foo\Bar')); + } + + public function testLoadAppNamespace() { + $result = $this->loader->findClass('OCA\Files\Foobar'); + $this->assertEquals(2, count($result)); + $this->assertStringEndsWith('apps/files/foobar.php', $result[0]); + $this->assertStringEndsWith('apps/files/lib/foobar.php', $result[1]); + } } diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php index 250842805e5..4051a6e234b 100644 --- a/tests/lib/files/cache/cache.php +++ b/tests/lib/files/cache/cache.php @@ -162,10 +162,11 @@ class Cache extends \PHPUnit_Framework_TestCase { $file4 = 'folder/foo/1'; $file5 = 'folder/foo/2'; $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar'); + $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $this->cache->put($file1, $data); - $this->cache->put($file2, $data); - $this->cache->put($file3, $data); + $this->cache->put($file1, $folderData); + $this->cache->put($file2, $folderData); + $this->cache->put($file3, $folderData); $this->cache->put($file4, $data); $this->cache->put($file5, $data); diff --git a/tests/lib/files/cache/permissions.php b/tests/lib/files/cache/permissions.php index 56dbbc4518e..7e6e11e2eb2 100644 --- a/tests/lib/files/cache/permissions.php +++ b/tests/lib/files/cache/permissions.php @@ -14,8 +14,8 @@ class Permissions extends \PHPUnit_Framework_TestCase { */ private $permissionsCache; - function setUp(){ - $this->permissionsCache=new \OC\Files\Cache\Permissions('dummy'); + function setUp() { + $this->permissionsCache = new \OC\Files\Cache\Permissions('dummy'); } function testSimple() { @@ -23,8 +23,10 @@ class Permissions extends \PHPUnit_Framework_TestCase { $user = uniqid(); $this->assertEquals(-1, $this->permissionsCache->get(1, $user)); + $this->assertNotContains($user, $this->permissionsCache->getUsers(1)); $this->permissionsCache->set(1, $user, 1); $this->assertEquals(1, $this->permissionsCache->get(1, $user)); + $this->assertContains($user, $this->permissionsCache->getUsers(1)); $this->assertEquals(-1, $this->permissionsCache->get(2, $user)); $this->assertEquals(-1, $this->permissionsCache->get(1, $user . '2')); diff --git a/tests/lib/public/contacts.php b/tests/lib/public/contacts.php index ce5d762226b..d6008876a00 100644 --- a/tests/lib/public/contacts.php +++ b/tests/lib/public/contacts.php @@ -19,8 +19,6 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ -OC::autoload('OCP\Contacts'); - class Test_Contacts extends PHPUnit_Framework_TestCase { diff --git a/tests/lib/template.php b/tests/lib/template.php index 6e88d4c07fc..fd12119da58 100644 --- a/tests/lib/template.php +++ b/tests/lib/template.php @@ -20,10 +20,13 @@ * */ -OC::autoload('OC_Template'); - class Test_TemplateFunctions extends PHPUnit_Framework_TestCase { + public function setUp() { + $loader = new \OC\Autoloader(); + $loader->load('OC_Template'); + } + public function testP() { // FIXME: do we need more testcases? $htmlString = "<script>alert('xss');</script>"; diff --git a/tests/lib/vobject.php b/tests/lib/vobject.php index 1103a4b3297..f28d22a1fcd 100644 --- a/tests/lib/vobject.php +++ b/tests/lib/vobject.php @@ -10,10 +10,29 @@ class Test_VObject extends PHPUnit_Framework_TestCase { public function setUp() { Sabre\VObject\Property::$classMap['SUMMARY'] = 'OC\VObject\StringProperty'; + Sabre\VObject\Property::$classMap['ORG'] = 'OC\VObject\CompoundProperty'; } function testStringProperty() { $property = Sabre\VObject\Property::create('SUMMARY', 'Escape;this,please'); $this->assertEquals("SUMMARY:Escape\;this\,please\r\n", $property->serialize()); } + + function testCompoundProperty() { + + $arr = array( + 'ABC, Inc.', + 'North American Division', + 'Marketing;Sales', + ); + + $property = Sabre\VObject\Property::create('ORG'); + $property->setParts($arr); + + $this->assertEquals('ABC\, Inc.;North American Division;Marketing\;Sales', $property->value); + $this->assertEquals('ORG:ABC\, Inc.;North American Division;Marketing\;Sales' . "\r\n", $property->serialize()); + $this->assertEquals(3, count($property->getParts())); + $parts = $property->getParts(); + $this->assertEquals('Marketing;Sales', $parts[2]); + } }
\ No newline at end of file |