Changeset 8991
- Timestamp:
- 05/16/08 02:14:34 (2 months ago)
- Files:
-
- branches/dwhittle/1.1/lib/autoload/sfCoreAutoload.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/config/config/factories.yml (modified) (1 diff)
- branches/dwhittle/1.1/lib/debug/sfWebDebug.class.php (modified) (4 diffs)
- branches/dwhittle/1.1/lib/form/sfForm.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/log/sfWebDebugLogger.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelDatabaseSchema.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/new_schema.yml (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.xml (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.yml (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/sfPropelDatabaseSchemaTest.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/routing/sfPatternRouting.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/task/generator/skeleton/app/app/config/factories.yml (modified) (1 diff)
- branches/dwhittle/1.1/lib/user/sfBasicSecurityUser.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/validator/sfValidatorFile.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/view/sfViewCacheManager.class.php (modified) (6 diffs)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormIdentity.class.php (deleted)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormSelect.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormSelectRadio.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/yaml/sfYaml.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormIdentityTest.php (deleted)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectRadioTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/1.1/lib/autoload/sfCoreAutoload.class.php
r8701 r8991 416 416 'sfWidgetFormDate' => 'widget', 417 417 'sfWidgetFormDateTime' => 'widget', 418 'sfWidgetFormIdentity' => 'widget',419 418 'sfWidgetFormInput' => 'widget', 420 419 'sfWidgetFormInputCheckbox' => 'widget', branches/dwhittle/1.1/lib/config/config/factories.yml
r8240 r8991 88 88 class: sfWebDebugLogger # web debug logger class 89 89 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 93 94 sf_file_logger: 94 95 class: sfFileLogger 95 96 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 20 20 { 21 21 protected 22 $dispatcher = null, 22 23 $log = array(), 23 24 $maxPriority = 1000, 24 25 $types = array(), 25 26 $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 } 26 34 27 35 /** … … 310 318 // extensions 311 319 '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', 314 321 'apc' => extension_loaded('apc') && ini_get('apc.enabled') ? 'on' : 'off', 315 322 'memcache' => extension_loaded('memcache') ? 'on' : 'off', … … 362 369 363 370 /** 364 * Decoratesa chunk of HTML with cache information.365 * 366 * @param s tring The internalUri representing the content371 * Listens to the 'view.cache.filter_content' event to decorate a chunk of HTML with cache information. 372 * 373 * @param sfEvent A sfEvent instance 367 374 * @param string The HTML content 368 * @param boolean true if the content is new in the cache, false otherwise369 375 * 370 376 * @return string The decorated HTML string 371 377 */ 372 public function decorateContentWithDebug($internalUri, $content, $new = false) 373 { 374 $context = sfContext::getInstance(); 375 378 public function decorateContentWithDebug(sfEvent $event, $content) 379 { 376 380 // 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')) 378 382 { 379 383 return $content; 380 384 } 381 385 382 $ cache = $context->getViewCacheManager();386 $viewCacheManager = $event->getSubject(); 383 387 sfLoader::loadHelpers(array('Helper', 'Url', 'Asset', 'Tag')); 384 388 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']); 388 392 389 393 return ' … … 392 396 <div style="height: 16px; padding: 2px"><a href="#" onclick="sfWebDebugToggle(\'sub_main_info_'.$id.'\'); return false;"><strong>cache information</strong></a> <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> </div> 393 397 <div style="padding: 2px; display: none" id="sub_main_info_'.$id.'"> 394 [uri] '.htmlspecialchars($ internalUri, ENT_QUOTES, sfConfig::get('sf_charset')).'<br />395 [life time] '.$ cache->getLifeTime($internalUri).' seconds<br />398 [uri] '.htmlspecialchars($event['uri'], ENT_QUOTES, sfConfig::get('sf_charset')).'<br /> 399 [life time] '.$viewCacheManager->getLifeTime($event['uri']).' seconds<br /> 396 400 [last modified] '.(time() - $lastModified).' seconds<br /> 397 401 <br /> branches/dwhittle/1.1/lib/form/sfForm.class.php
r8885 r8991 115 115 public function renderGlobalErrors() 116 116 { 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()); 118 138 } 119 139 branches/dwhittle/1.1/lib/log/sfWebDebugLogger.class.php
r8360 r8991 38 38 $this->dispatcher = $dispatcher; 39 39 40 $class = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug'; 41 $this->webDebug = new $class($dispatcher); 42 40 43 $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);48 44 49 45 if (isset($options['xdebug_logging'])) branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelDatabaseSchema.class.php
r8851 r8991 642 642 $attributes_string .= ' inheritance="single">'."\n"; 643 643 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); 649 646 foreach ($column['inheritance'] as $key => $class) 650 647 { 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"); 653 649 } 654 650 $attributes_string .= ' </column>'."\n"; branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php
r8630 r8991 33 33 new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), 34 34 new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), 35 new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms') 35 36 )); 36 37 … … 67 68 $buildAll = new sfPropelBuildAllTask($this->dispatcher, $this->formatter); 68 69 $buildAll->setCommandApplication($this->commandApplication); 69 $buildAll->run( );70 $buildAll->run(array(), $options['skip-forms'] ? array('--skip-forms') : array()); 70 71 71 72 $loadData = new sfPropelLoadDataTask($this->dispatcher, $this->formatter); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllTask.class.php
r7416 r8991 31 31 $this->briefDescription = 'Generates Propel model, SQL and initializes the database'; 32 32 33 $this->addOptions(array( 34 new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms') 35 )); 36 33 37 $this->detailedDescription = <<<EOF 34 38 The [propel:build-all|INFO] task is a shortcut for three other tasks: … … 60 64 $buildSql->run(); 61 65 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 } 65 72 66 73 $insertSql = new sfPropelInsertSqlTask($this->dispatcher, $this->formatter); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/new_schema.yml
r8851 r8991 70 70 columns: 71 71 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 25 25 <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> 26 26 </table> 27 27 28 28 <table name="cd_user_i18n"> 29 29 <column name="description" type="longvarchar" /> … … 84 84 </table> 85 85 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 86 94 </database> branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.yml
r8851 r8991 53 53 ab_group_i18n: 54 54 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 48 48 require_once(dirname(__FILE__).'/../../../../yaml/sfYaml.class.php'); 49 49 50 $t = new my_lime_test( 277, new lime_output_color());50 $t = new my_lime_test(302, new lime_output_color()); 51 51 52 52 $t->diag('Classical YAML to XML conversion'); branches/dwhittle/1.1/lib/routing/sfPatternRouting.class.php
r8851 r8991 73 73 parent::initialize($dispatcher, $cache, $options); 74 74 75 if (!is_null($this->cache) && $cacheData = $this->cache->get(' data'))75 if (!is_null($this->cache) && $cacheData = $this->cache->get('symfony.routing.data')) 76 76 { 77 77 $this->cacheData = unserialize($cacheData); … … 469 469 { 470 470 $params = $this->fixDefaults($params); 471 471 472 472 if (!is_null($this->cache)) 473 473 { branches/dwhittle/1.1/lib/task/generator/skeleton/app/app/config/factories.yml
r8540 r8991 127 127 class: sfWebDebugLogger # web debug logger class 128 128 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 132 133 sf_file_logger: 133 134 class: sfFileLogger 134 135 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 230 230 } 231 231 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 232 238 // read data from storage 233 239 $this->authenticated = $storage->read(self::AUTH_NAMESPACE); branches/dwhittle/1.1/lib/validator/sfValidatorFile.class.php
r8536 r8991 316 316 public function __toString() 317 317 { 318 return $this->savedName;318 return is_null($this->savedName) ? '' : $this->savedName; 319 319 } 320 320 branches/dwhittle/1.1/lib/view/sfViewCacheManager.class.php
r8139 r8991 676 676 if (sfConfig::get('sf_web_debug')) 677 677 { 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(); 679 679 } 680 680 … … 704 704 if (sfConfig::get('sf_web_debug')) 705 705 { 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(); 707 707 } 708 708 … … 751 751 if (sfConfig::get('sf_web_debug')) 752 752 { 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(); 754 754 } 755 755 … … 777 777 if ($saved && sfConfig::get('sf_web_debug')) 778 778 { 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(); 780 780 } 781 781 … … 800 800 if ($saved && sfConfig::get('sf_web_debug')) 801 801 { 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 803 804 $this->context->getResponse()->setContent($content); 804 805 } … … 835 836 if (sfConfig::get('sf_web_debug')) 836 837 { 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 838 840 $this->context->getResponse()->setContent($content); 839 841 } branches/dwhittle/1.1/lib/widget/sfWidgetFormSelect.class.php
r8908 r8991 95 95 return $options; 96 96 } 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 } 97 107 } branches/dwhittle/1.1/lib/widget/sfWidgetFormSelectRadio.class.php
r5969 r8991 54 54 foreach ($choices as $key => $option) 55 55 { 56 $ attributes = array(56 $baseAttributes = array( 57 57 'name' => $name, 58 58 'type' => 'radio', … … 63 63 if (strval($key) == strval($value)) 64 64 { 65 $ attributes['checked'] = 'checked';65 $baseAttributes['checked'] = 'checked'; 66 66 } 67 67 68 68 $inputs[] = array( 69 'input' => $this->renderTag('input', $attributes),69 'input' => $this->renderTag('input', array_merge($baseAttributes,$attributes)), 70 70 'label' => $this->renderContentTag('label', $option, array('for' => $id)), 71 71 ); branches/dwhittle/1.1/lib/yaml/sfYaml.class.php
r8240 r8991 58 58 } 59 59 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 62 65 { 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 } 71 72 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; 90 74 } 91 75 … … 102 86 public static function dump($array, $inline = 2) 103 87 { 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'; 112 89 113 return $yaml->dump($array, $inline); 114 } 90 $yaml = new sfYamlDumper(); 91 92 return $yaml->dump($array, $inline); 115 93 } 116 94 } branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectRadioTest.php
r5969 r8991 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 2, new lime_output_color());13 $t = new lime_test(3, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 18 18 // ->render() 19 19 $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" /> <label for="foo_foo">bar</label></li> 22 <li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" /> <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" /> <label for="foo_foo">bar</label></li>'. 23 '<li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" /> <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 ' <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 ' <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'); 24 35 25 36 // choices as a callable branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectTest.php
r8908 r8991 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 4, new lime_output_color());13 $t = new lime_test(16, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 24 24 $t->is($css->matchSingle('#foo option[value="foobar"][selected="selected"]')->getValue(), 'foo', '->render() renders a select tag with the value selected'); 25 25 $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'); 26 34 27 35 // multiple select