summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-05-21 23:35:19 +0200
committerRobin Appelman <icewind@owncloud.com>2013-05-21 23:35:19 +0200
commit81fd1badc3feb72c3a4e597c670e8adcdca525da (patch)
treedda3deee50551ebdffa8a9021b528ac29fdbf369 /tests
parentd7beac6d6f3ad588cee6c5ba8a2145b42fa184a2 (diff)
parentfb4d8ddf0a76da7e9f806b837f9cf23699671f75 (diff)
downloadnextcloud-server-81fd1badc3feb72c3a4e597c670e8adcdca525da.tar.gz
nextcloud-server-81fd1badc3feb72c3a4e597c670e8adcdca525da.zip
merge master into filecache_mtime
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/app.php8
-rw-r--r--tests/lib/archive/tar.php2
-rw-r--r--tests/lib/archive/zip.php2
-rw-r--r--tests/lib/autoloader.php74
-rw-r--r--tests/lib/files/cache/cache.php9
-rw-r--r--tests/lib/files/cache/permissions.php6
-rw-r--r--tests/lib/files/cache/updater.php14
-rw-r--r--tests/lib/files/mapper.php52
-rw-r--r--tests/lib/files/mount.php58
-rw-r--r--tests/lib/files/mount/manager.php67
-rw-r--r--tests/lib/files/storage/storage.php9
-rw-r--r--tests/lib/public/contacts.php2
-rw-r--r--tests/lib/streamwrappers.php4
-rw-r--r--tests/lib/template.php7
-rw-r--r--tests/lib/util.php14
-rw-r--r--tests/lib/vcategories.php11
-rw-r--r--tests/lib/vobject.php38
17 files changed, 296 insertions, 81 deletions
diff --git a/tests/lib/app.php b/tests/lib/app.php
index c452d752c9f..5396db8143e 100644
--- a/tests/lib/app.php
+++ b/tests/lib/app.php
@@ -64,6 +64,14 @@ class Test_App extends PHPUnit_Framework_TestCase {
}
+ public function testIsAppVersionCompatibleShouldWorkForPreAlpha(){
+ $oc = array(5, 0, 3);
+ $app = '4.93';
+
+ $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
public function testIsAppVersionCompatibleShouldFailOneVersionNumbers(){
$oc = array(4, 3, 1);
$app = '5';
diff --git a/tests/lib/archive/tar.php b/tests/lib/archive/tar.php
index 51de004813a..e66a8740879 100644
--- a/tests/lib/archive/tar.php
+++ b/tests/lib/archive/tar.php
@@ -8,6 +8,7 @@
require_once 'archive.php';
+if (!OC_Util::runningOnWindows()) {
class Test_Archive_TAR extends Test_Archive {
protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data';
@@ -18,3 +19,4 @@ class Test_Archive_TAR extends Test_Archive {
return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
}
}
+}
diff --git a/tests/lib/archive/zip.php b/tests/lib/archive/zip.php
index adddf81ee1b..e049a899d88 100644
--- a/tests/lib/archive/zip.php
+++ b/tests/lib/archive/zip.php
@@ -8,6 +8,7 @@
require_once 'archive.php';
+if (!OC_Util::runningOnWindows()) {
class Test_Archive_ZIP extends Test_Archive {
protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data';
@@ -18,3 +19,4 @@ class Test_Archive_ZIP extends Test_Archive {
return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
}
}
+} \ No newline at end of file
diff --git a/tests/lib/autoloader.php b/tests/lib/autoloader.php
new file mode 100644
index 00000000000..0e7d606ccf6
--- /dev/null
+++ b/tests/lib/autoloader.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test;
+
+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 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 edcd1c487d0..1612a673838 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);
@@ -244,4 +245,4 @@ class Cache extends \PHPUnit_Framework_TestCase {
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->cache = new \OC\Files\Cache\Cache($this->storage);
}
-} \ No newline at end of file
+}
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/files/cache/updater.php b/tests/lib/files/cache/updater.php
index 7a79f45a203..dad3cd7e650 100644
--- a/tests/lib/files/cache/updater.php
+++ b/tests/lib/files/cache/updater.php
@@ -42,18 +42,17 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
+ \OC\Files\Filesystem::tearDown();
if (!self::$user) {
- if (!\OC\Files\Filesystem::getView()) {
- self::$user = uniqid();
- \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
- } else {
- self::$user = \OC_User::getUser();
- }
+ self::$user = uniqid();
}
+ \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
+ \OC_Hook::clear('OC_Filesystem');
+
\OC_Hook::connect('OC_Filesystem', 'post_write', '\OC\Files\Cache\Updater', 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Updater', 'deleteHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Updater', 'renameHook');
@@ -137,11 +136,10 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->cache->inCache('foo.txt'));
$this->assertTrue($this->cache->inCache('bar.txt'));
$cachedData = $this->cache->get('bar.txt');
- $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
$mtime = $cachedData['mtime'];
$cachedData = $this->cache->get('');
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
- $this->assertEquals($mtime, $cachedData['mtime']);
}
}
diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php
new file mode 100644
index 00000000000..e3859bc0f23
--- /dev/null
+++ b/tests/lib/files/mapper.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\Files;
+
+class Mapper extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var \OC\Files\Mapper
+ */
+ private $mapper = null;
+
+ public function setUp() {
+ $this->mapper = new \OC\Files\Mapper('D:/');
+ }
+
+ public function testSlugifyPath() {
+ // with extension
+ $this->assertEquals('D:/text.txt', $this->mapper->slugifyPath('D:/text.txt'));
+ $this->assertEquals('D:/text-2.txt', $this->mapper->slugifyPath('D:/text.txt', 2));
+ $this->assertEquals('D:/a/b/text.txt', $this->mapper->slugifyPath('D:/a/b/text.txt'));
+
+ // without extension
+ $this->assertEquals('D:/text', $this->mapper->slugifyPath('D:/text'));
+ $this->assertEquals('D:/text-2', $this->mapper->slugifyPath('D:/text', 2));
+ $this->assertEquals('D:/a/b/text', $this->mapper->slugifyPath('D:/a/b/text'));
+
+ // with double dot
+ $this->assertEquals('D:/text-text.txt', $this->mapper->slugifyPath('D:/text.text.txt'));
+ $this->assertEquals('D:/text-text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2));
+ $this->assertEquals('D:/a/b/text-text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt'));
+ }
+}
diff --git a/tests/lib/files/mount.php b/tests/lib/files/mount.php
deleted file mode 100644
index a3dc06cc668..00000000000
--- a/tests/lib/files/mount.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-namespace Test\Files;
-
-use \OC\Files\Storage\Temporary;
-
-class LongId extends Temporary {
- public function getId() {
- return 'long:' . str_repeat('foo', 50) . parent::getId();
- }
-}
-
-class Mount extends \PHPUnit_Framework_TestCase {
- public function setup() {
- \OC_Util::setupFS();
- \OC\Files\Mount::clear();
- }
-
- public function testFind() {
- $this->assertNull(\OC\Files\Mount::find('/'));
-
- $rootMount = new \OC\Files\Mount(new Temporary(array()), '/');
- $this->assertEquals($rootMount, \OC\Files\Mount::find('/'));
- $this->assertEquals($rootMount, \OC\Files\Mount::find('/foo/bar'));
-
- $storage = new Temporary(array());
- $mount = new \OC\Files\Mount($storage, '/foo');
- $this->assertEquals($rootMount, \OC\Files\Mount::find('/'));
- $this->assertEquals($mount, \OC\Files\Mount::find('/foo/bar'));
-
- $this->assertEquals(1, count(\OC\Files\Mount::findIn('/')));
- new \OC\Files\Mount(new Temporary(array()), '/bar');
- $this->assertEquals(2, count(\OC\Files\Mount::findIn('/')));
-
- $id = $mount->getStorageId();
- $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id));
-
- $mount2 = new \OC\Files\Mount($storage, '/foo/bar');
- $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findByStorageId($id));
- }
-
- public function testLong() {
- $storage = new LongId(array());
- $mount = new \OC\Files\Mount($storage, '/foo');
-
- $id = $mount->getStorageId();
- $storageId = $storage->getId();
- $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id));
- $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($storageId));
- $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId(md5($storageId)));
- }
-}
diff --git a/tests/lib/files/mount/manager.php b/tests/lib/files/mount/manager.php
new file mode 100644
index 00000000000..154c35ccead
--- /dev/null
+++ b/tests/lib/files/mount/manager.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Files\Mount;
+
+use \OC\Files\Storage\Temporary;
+
+class LongId extends Temporary {
+ public function getId() {
+ return 'long:' . str_repeat('foo', 50) . parent::getId();
+ }
+}
+
+class Manager extends \PHPUnit_Framework_TestCase {
+ /**
+ * @var \OC\Files\Mount\Manager
+ */
+ private $manager;
+
+ public function setup() {
+ $this->manager = new \OC\Files\Mount\Manager();
+ }
+
+ public function testFind() {
+ $this->assertNull($this->manager->find('/'));
+
+ $rootMount = new \OC\Files\Mount\Mount(new Temporary(array()), '/');
+ $this->manager->addMount($rootMount);
+ $this->assertEquals($rootMount, $this->manager->find('/'));
+ $this->assertEquals($rootMount, $this->manager->find('/foo/bar'));
+
+ $storage = new Temporary(array());
+ $mount1 = new \OC\Files\Mount\Mount($storage, '/foo');
+ $this->manager->addMount($mount1);
+ $this->assertEquals($rootMount, $this->manager->find('/'));
+ $this->assertEquals($mount1, $this->manager->find('/foo/bar'));
+
+ $this->assertEquals(1, count($this->manager->findIn('/')));
+ $mount2 = new \OC\Files\Mount\Mount(new Temporary(array()), '/bar');
+ $this->manager->addMount($mount2);
+ $this->assertEquals(2, count($this->manager->findIn('/')));
+
+ $id = $mount1->getStorageId();
+ $this->assertEquals(array($mount1), $this->manager->findByStorageId($id));
+
+ $mount3 = new \OC\Files\Mount\Mount($storage, '/foo/bar');
+ $this->manager->addMount($mount3);
+ $this->assertEquals(array($mount1, $mount3), $this->manager->findByStorageId($id));
+ }
+
+ public function testLong() {
+ $storage = new LongId(array());
+ $mount = new \OC\Files\Mount\Mount($storage, '/foo');
+ $this->manager->addMount($mount);
+
+ $id = $mount->getStorageId();
+ $storageId = $storage->getId();
+ $this->assertEquals(array($mount), $this->manager->findByStorageId($id));
+ $this->assertEquals(array($mount), $this->manager->findByStorageId($storageId));
+ $this->assertEquals(array($mount), $this->manager->findByStorageId(md5($storageId)));
+ }
+}
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index f78f66d8b8a..0e22f26ae83 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -224,8 +224,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
}
public function testSearchInSubFolder() {
- $this->instance->mkdir('sub')
- ;
+ $this->instance->mkdir('sub');
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
$this->instance->file_put_contents('/sub/lorem.txt', file_get_contents($textFile, 'r'));
$pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png';
@@ -258,4 +257,10 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$content = stream_get_contents($fh);
$this->assertEquals(file_get_contents($textFile), $content);
}
+
+ public function testTouchCreateFile(){
+ $this->assertFalse($this->instance->file_exists('foo'));
+ $this->instance->touch('foo');
+ $this->assertTrue($this->instance->file_exists('foo'));
+ }
}
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/streamwrappers.php b/tests/lib/streamwrappers.php
index 2237ee7d378..c7e51ccfa48 100644
--- a/tests/lib/streamwrappers.php
+++ b/tests/lib/streamwrappers.php
@@ -77,10 +77,10 @@ class Test_StreamWrappers extends PHPUnit_Framework_TestCase {
}
public function testOC() {
- \OC\Files\Mount::clear();
+ \OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
$storage->file_put_contents('foo.txt', 'asd');
- new \OC\Files\Mount($storage, '/');
+ \OC\Files\Filesystem::mount($storage, array(), '/');
$this->assertTrue(file_exists('oc:///foo.txt'));
$this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
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/util.php b/tests/lib/util.php
index b904c359807..1f253825920 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -47,4 +47,16 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$email = \OCP\Util::getDefaultEmailAddress("no-reply");
$this->assertEquals('no-reply@localhost.localdomain', $email);
}
-} \ No newline at end of file
+
+ function testGetDefaultEmailAddressFromConfig() {
+ OC_Config::setValue('mail_domain', 'example.com');
+ $email = \OCP\Util::getDefaultEmailAddress("no-reply");
+ $this->assertEquals('no-reply@example.com', $email);
+ OC_Config::deleteKey('mail_domain');
+ }
+
+ function testGetInstanceIdGeneratesValidId() {
+ OC_Config::deleteKey('instanceid');
+ $this->assertStringStartsWith('oc', OC_Util::getInstanceId());
+ }
+}
diff --git a/tests/lib/vcategories.php b/tests/lib/vcategories.php
index e79dd49870c..df5f600f20d 100644
--- a/tests/lib/vcategories.php
+++ b/tests/lib/vcategories.php
@@ -81,6 +81,17 @@ class Test_VCategories extends PHPUnit_Framework_TestCase {
}
+ public function testrenameCategory() {
+ $defcategories = array('Friends', 'Family', 'Wrok', 'Other');
+ $catmgr = new OC_VCategories($this->objectType, $this->user, $defcategories);
+
+ $this->assertTrue($catmgr->rename('Wrok', 'Work'));
+ $this->assertTrue($catmgr->hasCategory('Work'));
+ $this->assertFalse($catmgr->hasCategory('Wrok'));
+ $this->assertFalse($catmgr->rename('Wrok', 'Work'));
+
+ }
+
public function testAddToCategory() {
$objids = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
diff --git a/tests/lib/vobject.php b/tests/lib/vobject.php
new file mode 100644
index 00000000000..f28d22a1fcd
--- /dev/null
+++ b/tests/lib/vobject.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+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