diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2013-09-19 11:27:13 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2013-09-19 11:27:13 +0200 |
commit | 314ca843e81c2e26e83d58391e313503e0f30ebd (patch) | |
tree | 93b4258186ee2ad517882346f59cd8c477c43e8d /tests/lib | |
parent | 76f8be3b7aadbb2c78f6c341ef8919973275efc8 (diff) | |
download | nextcloud-server-314ca843e81c2e26e83d58391e313503e0f30ebd.tar.gz nextcloud-server-314ca843e81c2e26e83d58391e313503e0f30ebd.zip |
Updated method names and added a few more tests.
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/tags.php | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/tests/lib/tags.php b/tests/lib/tags.php index 06baebc0af7..16a03f5645a 100644 --- a/tests/lib/tags.php +++ b/tests/lib/tags.php @@ -48,7 +48,7 @@ class Test_Tags extends PHPUnit_Framework_TestCase { $tagMgr = new OC\Tags($this->user); $tagMgr->loadTagsFor($this->objectType, $defaultTags); - $this->assertEquals(4, count($tagMgr->tags())); + $this->assertEquals(4, count($tagMgr->getTags())); } public function testAddTags() { @@ -65,7 +65,37 @@ class Test_Tags extends PHPUnit_Framework_TestCase { $this->assertFalse($tagMgr->add('Family')); $this->assertFalse($tagMgr->add('fAMILY')); - $this->assertEquals(4, count($tagMgr->tags())); + $this->assertEquals(4, count($tagMgr->getTags())); + } + + public function testAddMultiple() { + $tags = array('Friends', 'Family', 'Work', 'Other'); + + $tagMgr = new OC\Tags($this->user); + $tagMgr->loadTagsFor($this->objectType); + + foreach($tags as $tag) { + $this->assertFalse($tagMgr->hasTag($tag)); + } + + $result = $tagMgr->addMultiple($tags); + $this->assertTrue((bool)$result); + + foreach($tags as $tag) { + $this->assertTrue($tagMgr->hasTag($tag)); + } + + $this->assertEquals(4, count($tagMgr->getTags())); + } + + public function testIsEmpty() { + $tagMgr = new OC\Tags($this->user); + $tagMgr->loadTagsFor($this->objectType); + + $this->assertEquals(0, count($tagMgr->getTags())); + $this->assertTrue($tagMgr->isEmpty()); + $tagMgr->add('Tag'); + $this->assertFalse($tagMgr->isEmpty()); } public function testdeleteTags() { @@ -73,13 +103,13 @@ class Test_Tags extends PHPUnit_Framework_TestCase { $tagMgr = new OC\Tags($this->user); $tagMgr->loadTagsFor($this->objectType, $defaultTags); - $this->assertEquals(4, count($tagMgr->tags())); + $this->assertEquals(4, count($tagMgr->getTags())); $tagMgr->delete('family'); - $this->assertEquals(3, count($tagMgr->tags())); + $this->assertEquals(3, count($tagMgr->getTags())); $tagMgr->delete(array('Friends', 'Work', 'Other')); - $this->assertEquals(0, count($tagMgr->tags())); + $this->assertEquals(0, count($tagMgr->getTags())); } @@ -105,8 +135,8 @@ class Test_Tags extends PHPUnit_Framework_TestCase { $tagMgr->tagAs($id, 'Family'); } - $this->assertEquals(1, count($tagMgr->tags())); - $this->assertEquals(9, count($tagMgr->idsForTag('Family'))); + $this->assertEquals(1, count($tagMgr->getTags())); + $this->assertEquals(9, count($tagMgr->getIdsForTag('Family'))); } /** @@ -121,13 +151,20 @@ class Test_Tags extends PHPUnit_Framework_TestCase { $tagMgr->loadTagsFor($this->objectType); foreach($objIds as $id) { - $this->assertTrue(in_array($id, $tagMgr->idsForTag('Family'))); + $this->assertTrue(in_array($id, $tagMgr->getIdsForTag('Family'))); $tagMgr->unTag($id, 'Family'); - $this->assertFalse(in_array($id, $tagMgr->idsForTag('Family'))); + $this->assertFalse(in_array($id, $tagMgr->getIdsForTag('Family'))); } - $this->assertEquals(1, count($tagMgr->tags())); - $this->assertEquals(0, count($tagMgr->idsForTag('Family'))); + $this->assertEquals(1, count($tagMgr->getTags())); + $this->assertEquals(0, count($tagMgr->getIdsForTag('Family'))); + } + + public function testFavorite() { + $tagMgr = new OC\Tags($this->user); + $tagMgr->loadTagsFor($this->objectType); + $this->assertTrue($tagMgr->addToFavorites(1)); + $this->assertTrue($tagMgr->removeFromFavorites(1)); } } |