summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-09-19 11:27:13 +0200
committerThomas Tanghus <thomas@tanghus.net>2013-09-23 23:39:36 +0200
commit1bbeb12e2e8acc47b94c23d6a17332fb45c2a97e (patch)
tree1c010a46b2e7f6e94bed4b79116544c76547e262 /tests
parentb63acdb12599c4ad062d7509c0079fad0b1ccfa2 (diff)
downloadnextcloud-server-1bbeb12e2e8acc47b94c23d6a17332fb45c2a97e.tar.gz
nextcloud-server-1bbeb12e2e8acc47b94c23d6a17332fb45c2a97e.zip
Updated method names and added a few more tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/tags.php59
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));
}
}