Skip to content
Permalink
Browse files

Fixing String::insert() when $data is an empty array. Which was happe…

…ning in the dbo source tests.
  • Loading branch information...
markstory committed Nov 3, 2009
1 parent 4632402 commit d17c526dc345c4e6499bc61b56e06590206a9742
Showing with 8 additions and 0 deletions.
  1. +3 −0 cake/libs/string.php
  2. +5 −0 cake/tests/cases/libs/string.test.php
@@ -229,6 +229,9 @@ function insert($str, $data, $options = array()) {
$options += $defaults;
$format = $options['format'];
$data = (array)$data;
if (empty($data)) {
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
}
if (!isset($format)) {
$format = sprintf(
@@ -71,6 +71,11 @@ function testMultipleUuidGeneration() {
* @return void
*/
function testInsert() {
$string = 'some string';
$expected = 'some string';
$result = String::insert($string, array());
$this->assertEqual($result, $expected);
$string = '2 + 2 = :sum. Cake is :adjective.';
$expected = '2 + 2 = 4. Cake is yummy.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'));

0 comments on commit d17c526

Please sign in to comment.
You can’t perform that action at this time.