Development

Changeset 8991 for branches

You must first sign up to be able to contribute.

Changeset 8991 for branches

Show
Ignore:
Timestamp:
05/16/08 02:14:34 (4 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.1/lib/autoload/sfCoreAutoload.class.php

    r8701 r8991  
    416416  'sfWidgetFormDate' => 'widget', 
    417417  'sfWidgetFormDateTime' => 'widget', 
    418   'sfWidgetFormIdentity' => 'widget', 
    419418  'sfWidgetFormInput' => 'widget', 
    420419  'sfWidgetFormInputCheckbox' => 'widget', 
  • branches/dwhittle/1.1/lib/config/config/factories.yml

    r8240 r8991  
    8888          class: sfWebDebugLogger           # web debug logger class 
    8989          param: 
    90             level:          debug           # error level for web debug toolbar 
    91             condition:      %SF_WEB_DEBUG%  # switch on or off based on setting 
    92             xdebug_logging: true            # enable xdebug profiling 
     90            level:           debug           # error level for web debug toolbar 
     91            condition:       %SF_WEB_DEBUG%  # switch on or off based on setting 
     92            xdebug_logging:  true            # enable xdebug profiling 
     93            web_debug_class: sfWebDebug      # web debug class 
    9394        sf_file_logger: 
    9495          class: sfFileLogger 
    9596          param: 
    96             level:  debug                                       # error level for log file 
    97             file:   %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log  # path to log file 
     97            level:           debug                                       # error level for log file 
     98            file:            %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log  # path to log file 
     99            xdebug_logging:  true 
  • branches/dwhittle/1.1/lib/debug/sfWebDebug.class.php

    r8650 r8991  
    2020{ 
    2121  protected 
     22    $dispatcher  = null, 
    2223    $log         = array(), 
    2324    $maxPriority = 1000, 
    2425    $types       = array(), 
    2526    $lastTimeLog = -1; 
     27 
     28  public function __construct(sfEventDispatcher $dispatcher) 
     29  { 
     30    $this->dispatcher = $dispatcher; 
     31 
     32    $this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug')); 
     33  } 
    2634 
    2735  /** 
     
    310318      // extensions 
    311319      'xdebug'        => (sfConfig::get('sf_xdebug', true) && extension_loaded('xdebug'))   ? 'on' : 'off', 
    312       'syck'          => extension_loaded('syck')                                           ? 'on' : 'off', 
    313       'tokenizer'    => function_exists('token_get_all')                                    ? 'on' : 'off', 
     320      'tokenizer'     => function_exists('token_get_all')                                    ? 'on' : 'off', 
    314321      'apc'           => extension_loaded('apc') && ini_get('apc.enabled')                  ? 'on' : 'off', 
    315322      'memcache'      => extension_loaded('memcache')                                       ? 'on' : 'off', 
     
    362369 
    363370  /** 
    364    * Decorates a chunk of HTML with cache information. 
    365    * 
    366    * @param string  The internalUri representing the content 
     371   * Listens to the 'view.cache.filter_content' event to decorate a chunk of HTML with cache information. 
     372   * 
     373   * @param sfEvent A sfEvent instance 
    367374   * @param string  The HTML content 
    368    * @param boolean true if the content is new in the cache, false otherwise 
    369375   * 
    370376   * @return string The decorated HTML string 
    371377   */ 
    372   public function decorateContentWithDebug($internalUri, $content, $new = false) 
    373   { 
    374     $context = sfContext::getInstance(); 
    375  
     378  public function decorateContentWithDebug(sfEvent $event, $content) 
     379  { 
    376380    // don't decorate if not html or if content is null 
    377     if (!sfConfig::get('sf_web_debug') || !$content || false === strpos($context->getResponse()->getContentType(), 'html')) 
     381    if (!sfConfig::get('sf_web_debug') || !$content || false === strpos($event['response']->getContentType(), 'html')) 
    378382    { 
    379383      return $content; 
    380384    } 
    381385 
    382     $cache = $context->getViewCacheManager(); 
     386    $viewCacheManager = $event->getSubject(); 
    383387    sfLoader::loadHelpers(array('Helper', 'Url', 'Asset', 'Tag')); 
    384388 
    385     $bgColor      = $new ? '#9ff' : '#ff9'; 
    386     $lastModified = $cache->getLastModified($internalUri); 
    387     $id           = md5($internalUri); 
     389    $bgColor      = $event['new'] ? '#9ff' : '#ff9'; 
     390    $lastModified = $viewCacheManager->getLastModified($event['uri']); 
     391    $id           = md5($event['uri']); 
    388392 
    389393    return ' 
     
    392396      <div style="height: 16px; padding: 2px"><a href="#" onclick="sfWebDebugToggle(\'sub_main_info_'.$id.'\'); return false;"><strong>cache information</strong></a>&nbsp;<a href="#" onclick="sfWebDebugToggle(\'sub_main_'.$id.'\'); document.getElementById(\'main_'.$id.'\').style.border = \'none\'; return false;">'.image_tag(sfConfig::get('sf_web_debug_web_dir').'/images/close.png').'</a>&nbsp;</div> 
    393397        <div style="padding: 2px; display: none" id="sub_main_info_'.$id.'"> 
    394         [uri]&nbsp;'.htmlspecialchars($internalUri, ENT_QUOTES, sfConfig::get('sf_charset')).'<br /> 
    395         [life&nbsp;time]&nbsp;'.$cache->getLifeTime($internalUri).'&nbsp;seconds<br /> 
     398        [uri]&nbsp;'.htmlspecialchars($event['uri'], ENT_QUOTES, sfConfig::get('sf_charset')).'<br /> 
     399        [life&nbsp;time]&nbsp;'.$viewCacheManager->getLifeTime($event['uri']).'&nbsp;seconds<br /> 
    396400        [last&nbsp;modified]&nbsp;'.(time() - $lastModified).'&nbsp;seconds<br /> 
    397401        &nbsp;<br />&nbsp; 
  • branches/dwhittle/1.1/lib/form/sfForm.class.php

    r8885 r8991  
    115115  public function renderGlobalErrors() 
    116116  { 
    117     return $this->widgetSchema->getFormFormatter()->formatErrorsForRow($this->widgetSchema->getGlobalErrors($this->getErrorSchema())); 
     117    return $this->widgetSchema->getFormFormatter()->formatErrorsForRow($this->getGlobalErrors()); 
     118  } 
     119 
     120  /** 
     121   * Returns true if the form has some global errors. 
     122   * 
     123   * @return Boolean true if the form has some global errors, false otherwise 
     124   */ 
     125  public function hasGlobalErrors() 
     126  { 
     127    return (Boolean) count($this->getGlobalErrors()); 
     128  } 
     129 
     130  /** 
     131   * Gets the global errors associated with the form. 
     132   * 
     133   * @return array An array of global errors 
     134   */ 
     135  public function getGlobalErrors() 
     136  { 
     137    return $this->widgetSchema->getGlobalErrors($this->getErrorSchema()); 
    118138  } 
    119139 
  • branches/dwhittle/1.1/lib/log/sfWebDebugLogger.class.php

    r8360 r8991  
    3838    $this->dispatcher = $dispatcher; 
    3939 
     40    $class = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug'; 
     41    $this->webDebug = new $class($dispatcher); 
     42 
    4043    $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent')); 
    41  
    42     if(is_null($this->webDebug)) 
    43     { 
    44       $this->webDebug = $this->context->has('sf_web_debug') ? $this->context->get('sf_web_debug') : new sfWebDebug(); 
    45     } 
    46  
    47     $this->context->set('sf_web_debug', $this->webDebug); 
    4844 
    4945    if (isset($options['xdebug_logging'])) 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelDatabaseSchema.class.php

    r8851 r8991  
    642642        $attributes_string .= ' inheritance="single">'."\n"; 
    643643 
    644         $extended_package = isset($this->database[$tb_name]['_attributes']['package']) ? 
    645           $this->database[$tb_name]['_attributes']['package'] : 
    646           $this->database['_attributes']['package']; 
    647         $extended_class = $this->database[$tb_name]['_attributes']['phpName']; 
    648  
     644        $extended_package = isset($this->database[$tb_name]['_attributes']['package']) ? $this->database[$tb_name]['_attributes']['package'] : $this->database['_attributes']['package']; 
     645        $extended_class = isset($this->database[$tb_name]['_attributes']['phpName']) ? $this->database[$tb_name]['_attributes']['phpName'] : sfInflector::camelize($tb_name); 
    649646        foreach ($column['inheritance'] as $key => $class) 
    650647        { 
    651           $attributes_string .= sprintf('      <inheritance extends="%s.%s" key="%s" class="%s" />%s', 
    652             $extended_package, $extended_class, $key, $class, "\n"); 
     648          $attributes_string .= sprintf('      <inheritance extends="%s.%s" key="%s" class="%s" />%s', $extended_package, $extended_class, $key, $class, "\n"); 
    653649        } 
    654650        $attributes_string .= '    </column>'."\n"; 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php

    r8630 r8991  
    3333      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), 
    3434      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), 
     35      new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms') 
    3536    )); 
    3637 
     
    6768    $buildAll = new sfPropelBuildAllTask($this->dispatcher, $this->formatter); 
    6869    $buildAll->setCommandApplication($this->commandApplication); 
    69     $buildAll->run(); 
     70    $buildAll->run(array(), $options['skip-forms'] ? array('--skip-forms') : array()); 
    7071 
    7172    $loadData = new sfPropelLoadDataTask($this->dispatcher, $this->formatter); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllTask.class.php

    r7416 r8991  
    3131    $this->briefDescription = 'Generates Propel model, SQL and initializes the database'; 
    3232 
     33    $this->addOptions(array( 
     34      new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms') 
     35    )); 
     36 
    3337    $this->detailedDescription = <<<EOF 
    3438The [propel:build-all|INFO] task is a shortcut for three other tasks: 
     
    6064    $buildSql->run(); 
    6165 
    62     $buildForms = new sfPropelBuildFormsTask($this->dispatcher, $this->formatter); 
    63     $buildForms->setCommandApplication($this->commandApplication); 
    64     $buildForms->run(); 
     66    if (!$options['skip-forms']) 
     67    { 
     68      $buildForms = new sfPropelBuildFormsTask($this->dispatcher, $this->formatter); 
     69      $buildForms->setCommandApplication($this->commandApplication); 
     70      $buildForms->run(); 
     71    } 
    6572 
    6673    $insertSql = new sfPropelInsertSqlTask($this->dispatcher, $this->formatter); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/new_schema.yml

    r8851 r8991  
    7070    columns: 
    7171      motto:          longvarchar 
     72   
     73  History: 
     74    tableName:      history 
     75    columns: 
     76      id: 
     77      type:         { type: varchar(64) } 
     78    inheritance: 
     79      column:       type 
     80      classes: 
     81        new_user:   History_NewUser 
     82        new_page:   History_NewPage 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.xml

    r8851 r8991  
    2525    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> 
    2626  </table> 
    27    
     27 
    2828  <table name="cd_user_i18n"> 
    2929    <column name="description" type="longvarchar" /> 
     
    8484  </table> 
    8585 
     86  <table name="history"> 
     87    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> 
     88    <column name="type" type="varchar" size="64" inheritance="single"> 
     89      <inheritance extends="lib.model.History" key="new_user" class="History_NewUser" /> 
     90      <inheritance extends="lib.model.History" key="new_page" class="History_NewPage" /> 
     91    </column> 
     92  </table> 
     93 
    8694</database> 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.yml

    r8851 r8991  
    5353  ab_group_i18n: 
    5454    motto:            longvarchar 
     55   
     56  history: 
     57    _attributes:    { phpName: History } 
     58    id: 
     59    type:           { type: varchar(64) } 
     60    _inheritance: 
     61      column:       type 
     62      classes: 
     63        new_user:   History_NewUser 
     64        new_page:   History_NewPage 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/sfPropelDatabaseSchemaTest.php

    r8851 r8991  
    4848require_once(dirname(__FILE__).'/../../../../yaml/sfYaml.class.php'); 
    4949 
    50 $t = new my_lime_test(277, new lime_output_color()); 
     50$t = new my_lime_test(302, new lime_output_color()); 
    5151 
    5252$t->diag('Classical YAML to XML conversion'); 
  • branches/dwhittle/1.1/lib/routing/sfPatternRouting.class.php

    r8851 r8991  
    7373    parent::initialize($dispatcher, $cache, $options); 
    7474 
    75     if (!is_null($this->cache) && $cacheData = $this->cache->get('data')) 
     75    if (!is_null($this->cache) && $cacheData = $this->cache->get('symfony.routing.data')) 
    7676    { 
    7777      $this->cacheData = unserialize($cacheData); 
     
    469469  { 
    470470    $params = $this->fixDefaults($params); 
    471  
     471     
    472472    if (!is_null($this->cache)) 
    473473    { 
  • branches/dwhittle/1.1/lib/task/generator/skeleton/app/app/config/factories.yml

    r8540 r8991  
    127127          class: sfWebDebugLogger           # web debug logger class 
    128128          param: 
    129             level:          debug           # error level for web debug toolbar 
    130             condition:      %SF_WEB_DEBUG%  # switch on or off based on setting 
    131             xdebug_logging: true            # enable xdebug profiling 
     129            level:           debug           # error level for web debug toolbar 
     130            condition:       %SF_WEB_DEBUG%  # switch on or off based on setting 
     131            xdebug_logging:  true            # enable xdebug profiling 
     132            web_debug_class: sfWebDebug      # web debug class 
    132133        sf_file_logger: 
    133134          class: sfFileLogger 
    134135          param: 
    135             level:  debug                                       # error level for log file 
    136             file:   %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log  # path to log file 
     136            level:           debug                                       # error level for log file 
     137            file:            %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log  # path to log file 
     138            xdebug_logging:  true 
  • branches/dwhittle/1.1/lib/user/sfBasicSecurityUser.class.php

    r7989 r8991  
    230230    } 
    231231 
     232    // force the max lifetime for session garbage collector to be greater than timeout 
     233    if (ini_get('session.gc_maxlifetime') < $this->options['timeout']) 
     234    { 
     235      ini_set('session.gc_maxlifetime', $this->options['timeout']); 
     236    } 
     237 
    232238    // read data from storage 
    233239    $this->authenticated = $storage->read(self::AUTH_NAMESPACE); 
  • branches/dwhittle/1.1/lib/validator/sfValidatorFile.class.php

    r8536 r8991  
    316316  public function __toString() 
    317317  { 
    318     return $this->savedName; 
     318    return is_null($this->savedName) ? '' : $this->savedName; 
    319319  } 
    320320 
  • branches/dwhittle/1.1/lib/view/sfViewCacheManager.class.php

    r8139 r8991  
    676676    if (sfConfig::get('sf_web_debug')) 
    677677    { 
    678       $content = $this->context->get('sf_web_debug')->decorateContentWithDebug($uri, $content, false); 
     678      $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $content)->getReturnValue(); 
    679679    } 
    680680 
     
    704704    if (sfConfig::get('sf_web_debug')) 
    705705    { 
    706       $content = $this->context->get('sf_web_debug')->decorateContentWithDebug($uri, $content, true); 
     706      $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $content)->getReturnValue(); 
    707707    } 
    708708 
     
    751751    if (sfConfig::get('sf_web_debug')) 
    752752    { 
    753       $content = $this->context->get('sf_web_debug')->decorateContentWithDebug($uri, $content, false); 
     753      $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $content)->getReturnValue(); 
    754754    } 
    755755 
     
    777777    if ($saved && sfConfig::get('sf_web_debug')) 
    778778    { 
    779       $content = $this->context->get('sf_web_debug')->decorateContentWithDebug($uri, $content, true); 
     779      $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $content)->getReturnValue(); 
    780780    } 
    781781 
     
    800800    if ($saved && sfConfig::get('sf_web_debug')) 
    801801    { 
    802       $content = $this->context->get('sf_web_debug')->decorateContentWithDebug($uri, $this->context->getResponse()->getContent(), true); 
     802      $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $this->context->getResponse()->getContent())->getReturnValue(); 
     803 
    803804      $this->context->getResponse()->setContent($content); 
    804805    } 
     
    835836      if (sfConfig::get('sf_web_debug')) 
    836837      { 
    837         $content = $this->context->get('sf_web_debug')->decorateContentWithDebug($uri, $this->context->getResponse()->getContent(), false); 
     838        $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $this->context->getResponse()->getContent())->getReturnValue(); 
     839 
    838840        $this->context->getResponse()->setContent($content); 
    839841      } 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormSelect.class.php

    r8908 r8991  
    9595    return $options; 
    9696  } 
     97 
     98  /** 
     99   * @see sfWidget 
     100   * 
     101   * We always generate an attribute for the value. 
     102   */ 
     103  protected function attributesToHtmlCallback($k, $v) 
     104  { 
     105    return is_null($v) || ('' === $v && 'value' != $k) ? '' : sprintf(' %s="%s"', $k, $this->escapeOnce($v)); 
     106  } 
    97107} 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormSelectRadio.class.php

    r5969 r8991  
    5454    foreach ($choices as $key => $option) 
    5555    { 
    56       $attributes = array( 
     56      $baseAttributes = array( 
    5757        'name'  => $name, 
    5858        'type'  => 'radio', 
     
    6363      if (strval($key) == strval($value)) 
    6464      { 
    65         $attributes['checked'] = 'checked'; 
     65        $baseAttributes['checked'] = 'checked'; 
    6666      } 
    6767 
    6868      $inputs[] = array( 
    69         'input' => $this->renderTag('input', $attributes), 
     69        'input' => $this->renderTag('input', array_merge($baseAttributes,$attributes)), 
    7070        'label' => $this->renderContentTag('label', $option, array('for' => $id)), 
    7171      ); 
  • branches/dwhittle/1.1/lib/yaml/sfYaml.class.php

    r8240 r8991  
    5858    } 
    5959 
    60     // syck is prefered over sfYamlParser 
    61     if (function_exists('syck_load')) 
     60    require_once dirname(__FILE__).'/sfYamlParser.class.php'; 
     61 
     62    $yaml = new sfYamlParser(); 
     63 
     64    try 
    6265    { 
    63       try 
    64       { 
    65         $retval = syck_load($input); 
    66       } 
    67       catch (Exception $e) 
    68       { 
    69         throw new InvalidArgumentException(sprintf('Syck failed to parse %s, error was: "%s"', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 
    70       } 
     66      $ret = $yaml->parse($input); 
     67    } 
     68    catch (Exception $e) 
     69    { 
     70      throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 
     71    } 
    7172 
    72       return is_array($retval) ? $retval : array(); 
    73     } 
    74     else 
    75     { 
    76       require_once dirname(__FILE__).'/sfYamlParser.class.php'; 
    77       $yaml = new sfYamlParser(); 
    78  
    79       try 
    80       { 
    81         $ret = $yaml->parse($input); 
    82       } 
    83       catch (Exception $e) 
    84       { 
    85         throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 
    86       } 
    87  
    88       return $ret; 
    89     } 
     73    return $ret; 
    9074  } 
    9175 
     
    10286  public static function dump($array, $inline = 2) 
    10387  { 
    104     if (function_exists('syck_dump')) 
    105     { 
    106       return syck_dump($array); 
    107     } 
    108     else 
    109     { 
    110       require_once dirname(__FILE__).'/sfYamlDumper.class.php'; 
    111       $yaml = new sfYamlDumper(); 
     88    require_once dirname(__FILE__).'/sfYamlDumper.class.php'; 
    11289 
    113       return $yaml->dump($array, $inline); 
    114     } 
     90    $yaml = new sfYamlDumper(); 
     91 
     92    return $yaml->dump($array, $inline); 
    11593  } 
    11694} 
  • branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectRadioTest.php

    r5969 r8991  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(2, new lime_output_color()); 
     13$t = new lime_test(3, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    1818// ->render() 
    1919$t->diag('->render()'); 
    20 $w = new sfWidgetFormSelectRadio(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'))); 
    21 $output = '<ul class="radio_list"><li><input name="foo" type="radio" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">bar</label></li> 
    22 <li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" />&nbsp;<label for="foo_foobar">foo</label></li></ul>'; 
    23 $t->is($w->render('foo', 'foobar'), $output, '->render() renders a select tag with the value selected'); 
     20$w = new sfWidgetFormSelectRadio(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'), 'separator' => '')); 
     21$output = '<ul class="radio_list">'. 
     22'<li><input name="foo" type="radio" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">bar</label></li>'. 
     23'<li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" />&nbsp;<label for="foo_foobar">foo</label></li>'. 
     24'</ul>'; 
     25$t->is($w->render('foo', 'foobar'), $output, '->render() renders a radio tag with the value checked'); 
     26 
     27//regression for ticket #3528 
     28$onChange = '<ul class="radio_list">'. 
     29'<li><input name="foo" type="radio" value="foo" id="foo_foo" onChange="alert(42)" />'. 
     30'&nbsp;<label for="foo_foo">bar</label></li>'. 
     31'<li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" onChange="alert(42)" />'. 
     32'&nbsp;<label for="foo_foobar">foo</label></li>'. 
     33'</ul>'; 
     34$t->is($w->render('foo', 'foobar', array('onChange' => 'alert(42)')), $onChange, '->render() renders a radio tag using extra attributes'); 
    2435 
    2536// choices as a callable 
  • branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectTest.php

    r8908 r8991  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(14, new lime_output_color()); 
     13$t = new lime_test(16, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    2424$t->is($css->matchSingle('#foo option[value="foobar"][selected="selected"]')->getValue(), 'foo', '->render() renders a select tag with the value selected'); 
    2525$t->is(count($css->matchAll('#foo option')->getNodes()), 2, '->render() renders all choices as option tags'); 
     26 
     27// value attribute is always mandatory 
     28$w = new sfWidgetFormSelect(array('choices' => array('' => 'bar'))); 
     29$t->like($w->render('foo', 'foobar'), '/<option value="">/', '->render() always generate a value attribute, even for empty keys'); 
     30 
     31// other attributes are removed is empty 
     32$w = new sfWidgetFormSelect(array('choices' => array('' => 'bar'))); 
     33$t->like($w->render('foo', 'foobar', array('class' => '', 'style' => null)), '/<option value="">/', '->render() always generate a value attribute, even for empty keys'); 
    2634 
    2735// multiple select