Development

Changeset 4094

You must first sign up to be able to contribute.

Changeset 4094

Show
Ignore:
Timestamp:
05/24/07 03:50:47 (6 years ago)
Author:
xavier
Message:

some fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelActAsTaggableBehaviorPlugin/README

    r4085 r4094  
    171171 * '''tags''': tags that have been attached to the object, but not yet saved. Contract: tags are disjoin of (saved_tags union removed_tags) 
    172172 * '''saved_tags''': tags that are presently saved in the database 
    173  * '''removed_tags''': tags that are presently saved in the database, but which will be removed at the next save(). Contract: removed_tags are included in saved_tags 
     173 * '''removed_tags''': tags that are presently saved in the database, but which will be removed at the next save(). Contract: removed_tags are disjoin of (tags union saved_tags) 
    174174 
    175175When required, the saved_tags namespace is filled with the tags previously present in the database. The tagging methods have an action on these three namespaces, which are serialized in the database after the Propel object gets saved. 
  • plugins/sfPropelActAsTaggableBehaviorPlugin/lib/sfPropelActAsTaggableBehavior.class.php

    r4085 r4094  
    2929 * The plugin associates a parameterHolder to Propel objects, with 3 namespaces: 
    3030 *  
    31  * - tags : tags that have been attached to the object, but not yet saved. 
    32  *          contract : tags are disjoin of (saved_tags union removed_tags) 
    33  *  
    34  * - saved_tags : tags that are presently saved in the database 
    35  *  
    36  * - removed_tags : tags that are presently saved in the database, but which  
    37  *                  will be removed at the next save() 
    38  *                  contract : removed_tags are included in saved_tags 
     31 * - tags: 
     32 *     Tags that have been attached to the object, but not yet saved. 
     33 *     Contract: tags are disjoin of (saved_tags union removed_tags) 
     34 *  
     35 * - saved_tags: 
     36 *     Tags that are presently saved in the database 
     37 *  
     38 * - removed_tags: 
     39 *     Tags that are presently saved in the database, but which will be removed  
     40 *     at the next save() 
     41 *     Contract: removed_tags are disjoin of (tags union saved_tags) 
    3942 *  
    4043 *  
     
    8285    self::clear_tags($object); 
    8386    self::getTagsHolder($object)->add($tags, 'tags'); 
     87  } 
     88   
     89  private static function add_saved_tag(BaseObject $object, $tag) 
     90  { 
     91    self::getTagsHolder($object)->set($tag, $tag, 'saved_tags'); 
    8492  } 
    8593   
     
    154162        unset($removed_tags[$tagname]); 
    155163        self::set_removed_tags($object, $removed_tags); 
     164        self::add_saved_tag($object, $tagname); 
    156165      } 
    157166      else 
  • plugins/sfPropelActAsTaggableBehaviorPlugin/test/unit/sfPropelActAsTaggableBehaviorTest.php

    r4085 r4094  
    8383$t->ok(!$object->hasTag(), 'tags can all be removed at once'); 
    8484 
     85$object = _create_object(); 
     86$object->addTag('toto,tutu,tata'); 
     87$object->save(); 
     88$id = $object->getPrimaryKey(); 
     89$object = call_user_func(array(_create_object()->getPeer(), 'retrieveByPk'), $id); 
     90$object->removeTag('tata'); 
     91$object->addTag('tata'); 
     92$object->save(); 
     93$object = call_user_func(array(_create_object()->getPeer(), 'retrieveByPk'), $id); 
     94$object_tags = $object->getTags(); 
     95$t->ok(count($object_tags) == 3, 'when removing one previously saved tags, then restoring it, and then saving it again, tags are not duplicated'); 
     96 
     97$object = _create_object(); 
     98$object->addTag('toto,tutu,tata'); 
     99$object->save(); 
     100$object->removeAllTags(); 
     101$object->addTag('toto,tutu,tata'); 
     102$object->save(); 
     103$id = $object->getPrimaryKey(); 
     104$object = call_user_func(array(_create_object()->getPeer(), 'retrieveByPk'), $id); 
     105$object_tags = $object->getTags(); 
     106$t->ok(count($object_tags) == 3, 'when removing all previously saved tags, then restoring it, and then saving it again, tags are not duplicated'); 
    85107 
    86108unset($object, $object2, $object2_copy); 
    87  
     109die(); 
    88110 
    89111// these tests check the various methods for applying tags to an object