$object_2_2->addTag('tag2,tag7'); $object_2_2->save(); $tagged_with_tag4 = TagPeer::getTaggedWith('tag4'); $t->ok(count($tagged_with_tag4) == 2, 'getTaggedWith() returns objects tagged with one specific tag.'); $tagged_with_tag7 = TagPeer::getTaggedWith('tag7'); $t->ok(count($tagged_with_tag7) == 5, 'getTaggedWith() can return several object types.'); $tagged_with_tag17 = TagPeer::getTaggedWith(array('tag1', 'tag7')); $t->ok(count($tagged_with_tag17) == 3, 'getTaggedWith() returns objects tagged with several specific tags.'); $tagged_with_tag127 = TagPeer::getTaggedWith('tag1, tag2, tag7', array('nb_common_tags' => 2)); $t->ok(count($tagged_with_tag127) == 6, 'the "nb_common_tags" option of getTaggedWith() returns objects tagged with a certain number of tags within a set of specific tags.'); // these tests check the isTaggable() method $t->diag('detecting if a model is taggable or not'); $t->ok(deppPropelActAsTaggableToolkit::isTaggable(TEST_CLASS) === true, 'it is possible to tell if a model is taggable from its name.'); $object = _create_object(); $t->ok(deppPropelActAsTaggableToolkit::isTaggable($object) === true, 'it is possible to tell if a model is taggable from one of its instances.'); $t->ok(deppPropelActAsTaggableToolkit::isTaggable('Tristan\'s cat') === false, 'Tristan\'s cat is not taggable, and that is fine.'); TagPeer::doDeleteAll(); TaggingPeer::doDeleteAll(); call_user_func(array(_create_object()->getPeer(), 'doDeleteAll')); // these tests check for the application of triple tags $t->diag('applying triple tagging'); $t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns:key=value') === array('ns:key=value', 'ns', 'key', 'value'), 'triple extracted successfully.'); $t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns:key') === array('ns:key', null, null, null), 'ns:key is not a triple.'); $t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns') === array('ns', null, null, null), 'ns is not a triple.'); $object = _create_object(); $object->addTag('tutu'); $object->save(); $object = _create_object(); $object->addTag('ns:key=value'); $object->addTag('ns:key=tutu'); $object->addTag('ns:key=titi');