Skip to content

Commit

Permalink
Fixing String::insert() when $data is an empty array. Which was happe…
Browse files Browse the repository at this point in the history
…ning in the dbo source tests.
  • Loading branch information
markstory committed Nov 3, 2009
1 parent 4632402 commit d17c526
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cake/libs/string.php
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions cake/tests/cases/libs/string.test.php
Expand Up @@ -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'));
Expand Down

0 comments on commit d17c526

Please sign in to comment.