Development

Changeset 5489

You must first sign up to be able to contribute.

Changeset 5489

Show
Ignore:
Timestamp:
10/12/07 20:08:37 (1 year ago)
Author:
xavier
Message:

sfPropelActAsTaggableBehaviorPlugin : added an optionnal array parameter to the "getTags()" method + updated tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelActAsTaggableBehaviorPlugin/lib/sfPropelActAsTaggableBehavior.class.php

    r4507 r5489  
    213213   * @param      BaseObject  $object 
    214214   */ 
    215   public function getTags(BaseObject $object
     215  public function getTags(BaseObject $object, $options = array()
    216216  { 
    217217    $tags = array_merge(self::get_tags($object), $this->getSavedTags($object)); 
    218218    ksort($tags); 
     219 
     220    if (isset($options['serialized']) && (true === $options['serialized'])) 
     221    { 
     222      $tags = implode(', ', $tags); 
     223    } 
     224 
    219225    return $tags; 
    220226  } 
  • plugins/sfPropelActAsTaggableBehaviorPlugin/test/unit/sfPropelActAsTaggableBehaviorTest.php

    r5039 r5489  
    44 
    55// initializes testing framework 
    6 $app = 'frontend'; 
    7 include(dirname(__FILE__).'/../../../../test/bootstrap/functional.php'); 
     6$sf_root_dir = realpath(dirname(__FILE__).'/../../../../'); 
     7$apps_dir = glob($sf_root_dir.'/apps/*', GLOB_ONLYDIR); 
     8$app = substr($apps_dir[0], 
     9              strrpos($apps_dir[0], DIRECTORY_SEPARATOR) + 1, 
     10              strlen($apps_dir[0])); 
     11if (!$app) 
     12
     13  throw new Exception('No app has been detected in this project'); 
     14
     15 
     16require_once($sf_root_dir.'/test/bootstrap/functional.php'); 
     17require_once($sf_symfony_lib_dir.'/vendor/lime/lime.php'); 
     18 
     19if (!defined('TEST_CLASS') or !class_exists(TEST_CLASS)) 
     20
     21  // Don't run tests 
     22  return; 
     23
    824 
    925// initialize database manager 
     
    2238 
    2339// start tests 
    24 $t = new lime_test(32, new lime_output_color()); 
     40$t = new lime_test(33, new lime_output_color()); 
    2541 
    2642 
     
    131147$object2_tags = $object2->getTags(); 
    132148$t->ok((count($object2_tags) == 2) && (count($object_tags) == 3), 'removing one tag as no effect on the other tags of the object, neither on the other objects.'); 
     149 
     150$object2_tags = $object2->getTags(array('serialized' => true)); 
     151$t->ok($object2_tags == 'clever age, symfony', 'tags can be retrieved in a serialized form.'); 
    133152 
    134153unset($object, $object2, $object2_copy);