Changeset 10833
- Timestamp:
- 08/13/08 13:33:13 (5 years ago)
- Files:
-
- branches/1.0/lib/util/sfToolkit.class.php (modified) (1 diff)
- branches/1.0/test/unit/util/sfToolkitTest.php (modified) (2 diffs)
- branches/1.1/lib/util/sfToolkit.class.php (modified) (1 diff)
- branches/1.1/test/unit/util/sfToolkitTest.php (modified) (2 diffs)
- branches/1.2/lib/util/sfToolkit.class.php (modified) (1 diff)
- branches/1.2/test/unit/util/sfToolkitTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/lib/util/sfToolkit.class.php
r10719 r10833 361 361 public static function replaceConstants($value) 362 362 { 363 return is_string($value) ? preg_replace ('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value;363 return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value; 364 364 } 365 365 branches/1.0/test/unit/util/sfToolkitTest.php
r10515 r10833 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(7 2, new lime_output_color());13 $t = new lime_test(75, new lime_output_color()); 14 14 15 15 // ::stringToArray() … … 82 82 sfConfig::set('bar', null); 83 83 $t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null'); 84 $t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 85 $t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 86 $t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 84 87 85 88 // ::isPathAbsolute() branches/1.1/lib/util/sfToolkit.class.php
r10719 r10833 382 382 public static function replaceConstants($value) 383 383 { 384 return is_string($value) ? preg_replace ('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value;384 return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value; 385 385 } 386 386 branches/1.1/test/unit/util/sfToolkitTest.php
r10516 r10833 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(10 4, new lime_output_color());13 $t = new lime_test(107, new lime_output_color()); 14 14 15 15 // ::stringToArray() … … 82 82 sfConfig::set('bar', null); 83 83 $t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null'); 84 $t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 85 $t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 86 $t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 84 87 85 88 // ::isPathAbsolute() branches/1.2/lib/util/sfToolkit.class.php
r10719 r10833 382 382 public static function replaceConstants($value) 383 383 { 384 return is_string($value) ? preg_replace ('/%(.+?)%/e', 'sfConfig::has(strtolower("\\1")) ? sfConfig::get(strtolower("\\1")) : "%\\1%"', $value) : $value;384 return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value; 385 385 } 386 386 branches/1.2/test/unit/util/sfToolkitTest.php
r10518 r10833 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(10 4, new lime_output_color());13 $t = new lime_test(107, new lime_output_color()); 14 14 15 15 // ::stringToArray() … … 82 82 sfConfig::set('bar', null); 83 83 $t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null'); 84 $t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 85 $t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 86 $t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined'); 84 87 85 88 // ::isPathAbsolute()