// initializes testing framework $sf_root_dir = realpath(dirname(__FILE__) . '/../../../../'); // initialize database manager require_once $sf_root_dir . '/test/bootstrap/unit.php'; // start tests $t = new lime_test(31); // these tests check for the tags attachement consistency $t->diag('::cleanTagName'); $tag = TaggableToolkit::cleanTagName(''); $t->is($tag, '', 'empty string'); $tag = TaggableToolkit::cleanTagName('test'); $t->is($tag, 'test', 'single tag'); $tag = TaggableToolkit::cleanTagName('test1,test2'); $t->is($tag, 'test1 test2', 'double tag whitespace'); $tag = TaggableToolkit::cleanTagName('test1, test2'); $t->is($tag, 'test1 test2', 'double tag with whitespace'); $t->todo('test optional option parameter'); $t->diag('::explodeTagString'); $tag = TaggableToolkit::explodeTagString(''); $t->is($tag, '', 'empty string'); $tag = TaggableToolkit::explodeTagString('test1'); $t->is($tag, 'test1', 'single tag'); $tag = TaggableToolkit::explodeTagString('test1 test2'); $t->is($tag, 'test1 test2', 'single tag with whitespace'); $tag = TaggableToolkit::explodeTagString('test1,test2'); $t->is($tag, array('test1', 'test2'), 'double tag'); $tag = TaggableToolkit::explodeTagString(' test1 , test2'); $t->is($tag, array('test1', 'test2'), 'double dirty tag'); $tag = TaggableToolkit::explodeTagString(' test1 , test2');
/** * Removes a tag or a set of tags from the object. The * parameter might be an array of tags or a comma-separated string. * * @param mixed $tagname */ public function removeTag($tagname) { $tagname = TaggableToolkit::explodeTagString($tagname); if (is_array($tagname)) { foreach ($tagname as $tag) { $this->removeTag($tag); } } else { $tagname = TaggableToolkit::cleanTagName($tagname); $tags = $this->get_tags($this->getInvoker()); $saved_tags = $this->getSavedTags(); if (isset($tags[$tagname])) { unset($tags[$tagname]); $this->set_tags($this->getInvoker(), $tags); } if (isset($saved_tags[$tagname])) { unset($saved_tags[$tagname]); $this->set_saved_tags($this->getInvoker(), $saved_tags); $this->add_removed_tag($this->getInvoker(), $tagname); } } }