From 604b7e0a100b64ddeef7988e416645279f57ddaa Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Oct 2009 20:10:32 -0400 Subject: [PATCH 01/53] Splitting a long test for FormHelper up into smaller test cases. --- .../cases/libs/view/helpers/form.test.php | 372 +++++++++--------- 1 file changed, 193 insertions(+), 179 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 5712d81e8..7911f200c 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1499,50 +1499,6 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->input('email', array( - 'options' => array('è' => 'Firést', 'é' => 'Secoènd'), 'empty' => true) - ); - $expected = array( - 'div' => array('class' => 'input select'), - 'label' => array('for' => 'email'), - 'Email', - '/label', - array('select' => array('name' => 'data[email]', 'id' => 'email')), - array('option' => array('value' => '')), - '/option', - array('option' => array('value' => 'è')), - 'Firést', - '/option', - array('option' => array('value' => 'é')), - 'Secoènd', - '/option', - '/select', - '/div' - ); - $this->assertTags($result, $expected); - - $result = $this->Form->input('email', array( - 'options' => array('First', 'Second'), 'empty' => true) - ); - $expected = array( - 'div' => array('class' => 'input select'), - 'label' => array('for' => 'email'), - 'Email', - '/label', - array('select' => array('name' => 'data[email]', 'id' => 'email')), - array('option' => array('value' => '')), - '/option', - array('option' => array('value' => '0')), - 'First', - '/option', - array('option' => array('value' => '1')), - 'Second', - '/option', - '/select', - '/div' - ); - $this->assertTags($result, $expected); - $result = $this->Form->input('Contact.email', array( 'type' => 'file', 'class' => 'textbox' )); @@ -1559,84 +1515,6 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->input('Contact.created', array('type' => 'time', 'timeFormat' => 24)); - $result = explode(':', $result); - $this->assertPattern('/option value="23"/', $result[0]); - $this->assertNoPattern('/option value="24"/', $result[0]); - - $result = $this->Form->input('Contact.created', array('type' => 'time', 'timeFormat' => 24)); - $result = explode(':', $result); - $this->assertPattern('/option value="23"/', $result[0]); - $this->assertNoPattern('/option value="24"/', $result[0]); - - $result = $this->Form->input('Model.field', array( - 'type' => 'time', 'timeFormat' => 24, 'interval' => 15 - )); - $result = explode(':', $result); - $this->assertNoPattern('##', $result[1]); - $this->assertNoPattern('##', $result[1]); - $this->assertPattern('##', $result[1]); - - $result = $this->Form->input('Model.field', array( - 'type' => 'time', 'timeFormat' => 12, 'interval' => 15 - )); - $result = explode(':', $result); - $this->assertNoPattern('##', $result[1]); - $this->assertNoPattern('##', $result[1]); - $this->assertPattern('##', $result[1]); - - $result = $this->Form->input('prueba', array( - 'type' => 'time', 'timeFormat'=> 24 , 'dateFormat'=>'DMY' , 'minYear' => 2008, - 'maxYear' => date('Y') + 1 ,'interval' => 15 - )); - $result = explode(':', $result); - $this->assertNoPattern('##', $result[1]); - $this->assertNoPattern('##', $result[1]); - $this->assertPattern('##', $result[1]); - $this->assertPattern('##', $result[1]); - - $result = $this->Form->input('prueba', array( - 'type' => 'datetime', 'timeFormat'=> 24 , 'dateFormat'=>'DMY' , 'minYear' => 2008, - 'maxYear' => date('Y') + 1 ,'interval' => 15 - )); - $result = explode(':', $result); - $this->assertNoPattern('##', $result[1]); - $this->assertNoPattern('##', $result[1]); - $this->assertPattern('##', $result[1]); - $this->assertPattern('##', $result[1]); - - //related to ticket #5013 - $result = $this->Form->input('Contact.date', array( - 'type' => 'date', 'class' => 'customClass', 'onChange' => 'function(){}' - )); - $this->assertPattern('/class="customClass"/', $result); - $this->assertPattern('/onChange="function\(\)\{\}"/', $result); - - $result = $this->Form->input('Contact.date', array( - 'type' => 'date', 'id' => 'customId', 'onChange' => 'function(){}' - )); - $this->assertPattern('/id="customIdDay"/', $result); - $this->assertPattern('/id="customIdMonth"/', $result); - $this->assertPattern('/onChange="function\(\)\{\}"/', $result); - - $result = $this->Form->input('Model.field', array( - 'type' => 'datetime', 'timeFormat' => 24, 'id' => 'customID' - )); - $this->assertPattern('/id="customIDDay"/', $result); - $this->assertPattern('/id="customIDHour"/', $result); - $result = explode('assertPattern('/option value="23"/', $result[0]); - $this->assertNoPattern('/option value="24"/', $result[0]); - - $result = $this->Form->input('Model.field', array( - 'type' => 'datetime', 'timeFormat' => 12 - )); - $result = explode('assertPattern('/option value="12"/', $result[0]); - $this->assertNoPattern('/option value="13"/', $result[0]); - $this->Form->data = array('Contact' => array('phone' => 'Hello & World > weird chars')); $result = $this->Form->input('Contact.phone'); $expected = array( @@ -1653,7 +1531,6 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Form->data['Model']['0']['OtherModel']['field'] = 'My value'; $result = $this->Form->input('Model.0.OtherModel.field', array('id' => 'myId')); $expected = array( @@ -1770,6 +1647,199 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); + $this->Form->validationErrors['Model']['field'] = 'minLength'; + $result = $this->Form->input('Model.field', array('error' => array('minLength' => __('Le login doit contenir au moins 2 caractères', true)))); + $expected = array( + 'div' => array('class' => 'input text error'), + 'label' => array('for' => 'ModelField'), + 'Field', + '/label', + 'input' => array('type' => 'text', 'name' => 'data[Model][field]', 'value' => '', 'id' => 'ModelField', 'class' => 'form-error'), + array('div' => array('class' => 'error-message')), + 'Le login doit contenir au moins 2 caractères', + '/div', + '/div' + ); + $this->assertTags($result, $expected); + } +/** + * test form->input() with datetime, date and time types + * + * @return void + **/ + function testInputDatetime() { + extract($this->dateRegex); + $result = $this->Form->input('Contact.created', array('type' => 'time', 'timeFormat' => 24)); + $result = explode(':', $result); + $this->assertPattern('/option value="23"/', $result[0]); + $this->assertNoPattern('/option value="24"/', $result[0]); + + $result = $this->Form->input('Contact.created', array('type' => 'time', 'timeFormat' => 24)); + $result = explode(':', $result); + $this->assertPattern('/option value="23"/', $result[0]); + $this->assertNoPattern('/option value="24"/', $result[0]); + + $result = $this->Form->input('Model.field', array( + 'type' => 'time', 'timeFormat' => 24, 'interval' => 15 + )); + $result = explode(':', $result); + $this->assertNoPattern('##', $result[1]); + $this->assertNoPattern('##', $result[1]); + $this->assertPattern('##', $result[1]); + + $result = $this->Form->input('Model.field', array( + 'type' => 'time', 'timeFormat' => 12, 'interval' => 15 + )); + $result = explode(':', $result); + $this->assertNoPattern('##', $result[1]); + $this->assertNoPattern('##', $result[1]); + $this->assertPattern('##', $result[1]); + + $result = $this->Form->input('prueba', array( + 'type' => 'time', 'timeFormat'=> 24 , 'dateFormat'=>'DMY' , 'minYear' => 2008, + 'maxYear' => date('Y') + 1 ,'interval' => 15 + )); + $result = explode(':', $result); + $this->assertNoPattern('##', $result[1]); + $this->assertNoPattern('##', $result[1]); + $this->assertPattern('##', $result[1]); + $this->assertPattern('##', $result[1]); + + $result = $this->Form->input('prueba', array( + 'type' => 'datetime', 'timeFormat'=> 24 , 'dateFormat'=>'DMY' , 'minYear' => 2008, + 'maxYear' => date('Y') + 1 ,'interval' => 15 + )); + $result = explode(':', $result); + $this->assertNoPattern('##', $result[1]); + $this->assertNoPattern('##', $result[1]); + $this->assertPattern('##', $result[1]); + $this->assertPattern('##', $result[1]); + + //related to ticket #5013 + $result = $this->Form->input('Contact.date', array( + 'type' => 'date', 'class' => 'customClass', 'onChange' => 'function(){}' + )); + $this->assertPattern('/class="customClass"/', $result); + $this->assertPattern('/onChange="function\(\)\{\}"/', $result); + + $result = $this->Form->input('Contact.date', array( + 'type' => 'date', 'id' => 'customId', 'onChange' => 'function(){}' + )); + $this->assertPattern('/id="customIdDay"/', $result); + $this->assertPattern('/id="customIdMonth"/', $result); + $this->assertPattern('/onChange="function\(\)\{\}"/', $result); + + $result = $this->Form->input('Model.field', array( + 'type' => 'datetime', 'timeFormat' => 24, 'id' => 'customID' + )); + $this->assertPattern('/id="customIDDay"/', $result); + $this->assertPattern('/id="customIDHour"/', $result); + $result = explode('assertPattern('/option value="23"/', $result[0]); + $this->assertNoPattern('/option value="24"/', $result[0]); + + $result = $this->Form->input('Model.field', array( + 'type' => 'datetime', 'timeFormat' => 12 + )); + $result = explode('assertPattern('/option value="12"/', $result[0]); + $this->assertNoPattern('/option value="13"/', $result[0]); + + $this->Form->data = array('Contact' => array('created' => null)); + $result = $this->Form->input('Contact.created', array('empty' => 'Date Unknown')); + $expected = array( + 'div' => array('class' => 'input date'), + 'label' => array('for' => 'ContactCreatedMonth'), + 'Created', + '/label', + array('select' => array('name' => 'data[Contact][created][month]', 'id' => 'ContactCreatedMonth')), + array('option' => array('value' => '')), 'Date Unknown', '/option', + $monthsRegex, + '/select', '-', + array('select' => array('name' => 'data[Contact][created][day]', 'id' => 'ContactCreatedDay')), + array('option' => array('value' => '')), 'Date Unknown', '/option', + $daysRegex, + '/select', '-', + array('select' => array('name' => 'data[Contact][created][year]', 'id' => 'ContactCreatedYear')), + array('option' => array('value' => '')), 'Date Unknown', '/option', + $yearsRegex, + '/select', + '/div' + ); + $this->assertTags($result, $expected); + } +/** + * Test generating checkboxes in a loop. + * + * @return void + **/ + function testInputCheckboxesInLoop() { + for ($i = 1; $i < 5; $i++) { + $result = $this->Form->input("Contact.{$i}.email", array('type' => 'checkbox', 'value' => $i)); + $expected = array( + 'div' => array('class' => 'input checkbox'), + 'input' => array('type' => 'hidden', 'name' => "data[Contact][{$i}][email]", 'value' => '0', 'id' => "Contact{$i}Email_"), + array('input' => array('type' => 'checkbox', 'name' => "data[Contact][{$i}][email]", 'value' => $i, 'id' => "Contact{$i}Email")), + 'label' => array('for' => "Contact{$i}Email"), + 'Email', + '/label', + '/div' + ); + $this->assertTags($result, $expected); + } + } +/** + * test form->input() with select type inputs. + * + * @return void + **/ + function testInputSelectType() { + $result = $this->Form->input('email', array( + 'options' => array('è' => 'Firést', 'é' => 'Secoènd'), 'empty' => true) + ); + $expected = array( + 'div' => array('class' => 'input select'), + 'label' => array('for' => 'email'), + 'Email', + '/label', + array('select' => array('name' => 'data[email]', 'id' => 'email')), + array('option' => array('value' => '')), + '/option', + array('option' => array('value' => 'è')), + 'Firést', + '/option', + array('option' => array('value' => 'é')), + 'Secoènd', + '/option', + '/select', + '/div' + ); + $this->assertTags($result, $expected); + + $result = $this->Form->input('email', array( + 'options' => array('First', 'Second'), 'empty' => true) + ); + $expected = array( + 'div' => array('class' => 'input select'), + 'label' => array('for' => 'email'), + 'Email', + '/label', + array('select' => array('name' => 'data[email]', 'id' => 'email')), + array('option' => array('value' => '')), + '/option', + array('option' => array('value' => '0')), + 'First', + '/option', + array('option' => array('value' => '1')), + 'Second', + '/option', + '/select', + '/div' + ); + $this->assertTags($result, $expected); + $this->Form->data = array('Model' => array('user_id' => 'value')); $view =& ClassRegistry::getObject('view'); $view->viewVars['users'] = array('value' => 'good', 'other' => 'bad'); @@ -1841,33 +1911,6 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - extract($this->dateRegex); - - $this->Form->data = array('Contact' => array('created' => null)); - $view =& ClassRegistry::getObject('view'); - $view->viewVars['users'] = array('value' => 'good', 'other' => 'bad'); - $result = $this->Form->input('Contact.created', array('empty' => 'Date Unknown')); - $expected = array( - 'div' => array('class' => 'input date'), - 'label' => array('for' => 'ContactCreatedMonth'), - 'Created', - '/label', - array('select' => array('name' => 'data[Contact][created][month]', 'id' => 'ContactCreatedMonth')), - array('option' => array('value' => '')), 'Date Unknown', '/option', - $monthsRegex, - '/select', '-', - array('select' => array('name' => 'data[Contact][created][day]', 'id' => 'ContactCreatedDay')), - array('option' => array('value' => '')), 'Date Unknown', '/option', - $daysRegex, - '/select', '-', - array('select' => array('name' => 'data[Contact][created][year]', 'id' => 'ContactCreatedYear')), - array('option' => array('value' => '')), 'Date Unknown', '/option', - $yearsRegex, - '/select', - '/div' - ); - $this->assertTags($result, $expected); - $this->Form->data = array('User' => array('User' => array('value'))); $view =& ClassRegistry::getObject('view'); $view->viewVars['users'] = array('value' => 'good', 'other' => 'bad'); @@ -1891,35 +1934,6 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); - - $this->Form->validationErrors['Model']['field'] = 'minLength'; - $result = $this->Form->input('Model.field', array('error' => array('minLength' => __('Le login doit contenir au moins 2 caractères', true)))); - $expected = array( - 'div' => array('class' => 'input text error'), - 'label' => array('for' => 'ModelField'), - 'Field', - '/label', - 'input' => array('type' => 'text', 'name' => 'data[Model][field]', 'value' => '', 'id' => 'ModelField', 'class' => 'form-error'), - array('div' => array('class' => 'error-message')), - 'Le login doit contenir au moins 2 caractères', - '/div', - '/div' - ); - $this->assertTags($result, $expected); - - for ($i = 1; $i < 5; $i++) { - $result = $this->Form->input("Contact.{$i}.email", array('type' => 'checkbox', 'value' => $i)); - $expected = array( - 'div' => array('class' => 'input checkbox'), - 'input' => array('type' => 'hidden', 'name' => "data[Contact][{$i}][email]", 'value' => '0', 'id' => "Contact{$i}Email_"), - array('input' => array('type' => 'checkbox', 'name' => "data[Contact][{$i}][email]", 'value' => $i, 'id' => "Contact{$i}Email")), - 'label' => array('for' => "Contact{$i}Email"), - 'Email', - '/label', - '/div' - ); - $this->assertTags($result, $expected); - } } /** * testFormInputs method From 082156f9a1842b3d3c5e0afca48c4dba69ccab12 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Oct 2009 21:17:00 -0400 Subject: [PATCH 02/53] Fixing FormHelper::input() label's for attribute when a datetime type is created and dateFormat or timeFormat is set to NONE. Fixes #168 --- cake/libs/view/helpers/form.php | 16 ++++++++++------ cake/tests/cases/libs/view/helpers/form.test.php | 8 ++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 0a58cea16..e71fff9be 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -708,9 +708,13 @@ class FormHelper extends AppHelper { if ($label !== false) { $labelAttributes = $this->domId(array(), 'for'); - if (in_array($options['type'], array('date', 'datetime'))) { - $labelAttributes['for'] .= 'Month'; - } else if ($options['type'] === 'time') { + if ($options['type'] === 'date' || $options['type'] === 'datetime') { + if (isset($options['dateFormat']) && $options['dateFormat'] === 'NONE') { + $labelAttributes['for'] .= 'Hour'; + } else { + $labelAttributes['for'] .= 'Month'; + } + } elseif ($options['type'] === 'time') { $labelAttributes['for'] .= 'Hour'; } @@ -764,10 +768,10 @@ class FormHelper extends AppHelper { unset($options['dateFormat']); } - $type = $options['type']; - $before = $options['before']; + $type = $options['type']; + $before = $options['before']; $between = $options['between']; - $after = $options['after']; + $after = $options['after']; unset($options['type'], $options['before'], $options['between'], $options['after']); switch ($type) { diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 7911f200c..0a83d59c3 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1769,6 +1769,14 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + + $this->Form->data = array('Contact' => array('created' => null)); + $result = $this->Form->input('Contact.created', array('type' => 'datetime', 'dateFormat' => 'NONE')); + $this->assertPattern('/for\="ContactCreatedHour"/', $result); + + $this->Form->data = array('Contact' => array('created' => null)); + $result = $this->Form->input('Contact.created', array('type' => 'datetime', 'timeFormat' => 'NONE')); + $this->assertPattern('/for\="ContactCreatedMonth"/', $result); } /** * Test generating checkboxes in a loop. From 43dbf716241bc16c227b8e85ddae3e65bdce4c3e Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Thu, 15 Oct 2009 18:09:58 -0300 Subject: [PATCH 03/53] Doing a little optimization for php 5.1 <, also fixing tests on Windows. Fixes #155. --- cake/libs/session.php | 12 ++++++------ cake/tests/cases/libs/view/helpers/session.test.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/session.php b/cake/libs/session.php index 136865689..38697ae23 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -592,15 +592,15 @@ class CakeSession extends Object { function __regenerateId() { $oldSessionId = session_id(); if ($oldSessionId) { - $sessionpath = session_save_path(); - if (empty($sessionpath)) { - $sessionpath = "/tmp"; - } - if (session_id() != "" || isset($_COOKIE[session_name()])) { + if (session_id() != ''|| isset($_COOKIE[session_name()])) { setcookie(Configure::read('Session.cookie'), '', time() - 42000, $this->path); } session_regenerate_id(true); if (PHP_VERSION < 5.1) { + $sessionPath = session_save_path(); + if (empty($sessionPath)) { + $sessionPath = '/tmp'; + } $newSessid = session_id(); if (function_exists('session_write_close')) { @@ -610,7 +610,7 @@ class CakeSession extends Object { session_id($oldSessionId); session_start(); session_destroy(); - $file = $sessionpath . DS . "sess_$oldSessionId"; + $file = $sessionPath . DS . 'sess_' . $oldSessionId; @unlink($file); $this->__initSession(); session_id($newSessid); diff --git a/cake/tests/cases/libs/view/helpers/session.test.php b/cake/tests/cases/libs/view/helpers/session.test.php index 6f98c2acd..eb6e295e7 100644 --- a/cake/tests/cases/libs/view/helpers/session.test.php +++ b/cake/tests/cases/libs/view/helpers/session.test.php @@ -224,7 +224,7 @@ class SessionHelperTest extends CakeTestCase { ob_clean(); $this->assertPattern("/Missing Layout/", $result); - $this->assertPattern("/layouts\/does_not_exist.ctp/", $result); + $this->assertPattern("/layouts(\\\|\/)does_not_exist.ctp/", $result); } /** * testID method From a36c2ec5bbaa7176ebf3403120fb6bc39f3b9fd5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 16 Oct 2009 09:19:23 -0400 Subject: [PATCH 04/53] Removing self inclusions for test cases. Refs #174 --- cake/tests/cases/libs/model/model_integration.test.php | 3 +-- cake/tests/cases/libs/model/model_validation.test.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index e213187b6..cc1d8b20c 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -1,7 +1,7 @@ Date: Sun, 18 Oct 2009 22:05:17 -0400 Subject: [PATCH 05/53] Fixing FormHelper::__selectOptions incorrectly selecting options due to type juggling. Fixes #167 --- cake/libs/view/helpers/form.php | 2 +- .../tests/cases/libs/view/helpers/form.test.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index e71fff9be..e1f3c4422 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1721,7 +1721,7 @@ class FormHelper extends AppHelper { } if ($name !== null) { - if ((!$selectedIsEmpty && $selected == $name) || ($selectedIsArray && in_array($name, $selected))) { + if ((!$selectedIsEmpty && (string)$selected == (string)$name) || ($selectedIsArray && in_array($name, $selected))) { if ($attributes['style'] === 'checkbox') { $htmlOptions['checked'] = true; } else { diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 0a83d59c3..a0241322f 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -2687,6 +2687,23 @@ class FormHelperTest extends CakeTestCase { '/select' ); $this->assertTags($result, $expected); + + $this->Form->data = array('Model' => array('contact_id' => 228)); + $result = $this->Form->select( + 'Model.contact_id', + array('228' => '228 value', '228-1' => '228-1 value', '228-2' => '228-2 value'), + null, array('escape' => false), 'pick something' + ); + + $expected = array( + 'select' => array('name' => 'data[Model][contact_id]', 'id' => 'ModelContactId'), + array('option' => array('value' => '')), 'pick something', '/option', + array('option' => array('value' => '228', 'selected' => 'selected')), '228 value', '/option', + array('option' => array('value' => '228-1')), '228-1 value', '/option', + array('option' => array('value' => '228-2')), '228-2 value', '/option', + '/select' + ); + $this->assertTags($result, $expected); } /** * Tests that FormHelper::select() allows null to be passed in the $attributes parameter From 7ff3fcc4c4105e6a4475effff534f0429e1fe6aa Mon Sep 17 00:00:00 2001 From: jperras Date: Mon, 19 Oct 2009 12:51:06 -0400 Subject: [PATCH 06/53] Adding skip for non-existence of DateTimeZone class in time helper tests. --- cake/tests/cases/libs/view/helpers/time.test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 94da2a997..fbaff45ab 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -639,6 +639,8 @@ class TimeHelperTest extends CakeTestCase { * @return void */ function testUserOffset() { + $this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.'); + $timezoneServer = new DateTimeZone(date_default_timezone_get()); $timeServer = new DateTime('now', $timezoneServer); $yourTimezone = $timezoneServer->getOffset($timeServer) / HOUR; From ae342c6f2c9e88290cdc4316bff7848a3a4a908e Mon Sep 17 00:00:00 2001 From: jperras Date: Mon, 19 Oct 2009 13:17:07 -0400 Subject: [PATCH 07/53] Fixing skip in previous commit: if skip condition evaluates to true, to prevent a fatal error from being produced. --- cake/tests/cases/libs/view/helpers/time.test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index fbaff45ab..7fd5c1b15 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -639,7 +639,10 @@ class TimeHelperTest extends CakeTestCase { * @return void */ function testUserOffset() { - $this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.'); + if ($this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) { + return; + } + $timezoneServer = new DateTimeZone(date_default_timezone_get()); $timeServer = new DateTime('now', $timezoneServer); From 79e96e5aefa5095500b3efd45b2426bc88fc7143 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Oct 2009 16:36:44 -0400 Subject: [PATCH 08/53] Updating localePaths path. Fixes #184 --- cake/tests/cases/basics.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index 7baeeb60f..800cb7dc3 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -41,7 +41,7 @@ class BasicsTest extends CakeTestCase { */ function setUp() { $this->_localePaths = Configure::read('localePaths'); - Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale')); + Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' .DS )); $this->_language = Configure::read('Config.language'); } /** From 3922f136dab019cbfe93ddb828d6a0dcba8cc72a Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Oct 2009 20:54:02 -0400 Subject: [PATCH 09/53] Making DboMysqlTest pass when a connection with a prefix is used. Fixes #185 --- .../libs/model/datasources/dbo/dbo_mysql.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 691a86c1f..cf9cc833c 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -273,7 +273,7 @@ class DboMysqlTest extends CakeTestCase { $this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $this->model = new CakeTestModel(array( - 'name' => 'Tinyint', 'table' => $this->db->fullTableName('tinyint', false) + 'name' => 'Tinyint', 'table' => 'tinyint', 'ds' => 'test_suite' )); $result = $this->model->schema(); @@ -312,7 +312,7 @@ class DboMysqlTest extends CakeTestCase { $name = $this->db->fullTableName('simple'); $this->db->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1)); - $result = $this->db->index($name, false); + $result = $this->db->index('simple', false); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); @@ -322,7 +322,7 @@ class DboMysqlTest extends CakeTestCase { 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), ); - $result = $this->db->index($name, false); + $result = $this->db->index('with_a_key', false); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); @@ -333,7 +333,7 @@ class DboMysqlTest extends CakeTestCase { 'pointless_bool' => array('column' => 'bool', 'unique' => 0), 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), ); - $result = $this->db->index($name, false); + $result = $this->db->index('with_two_keys', false); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); @@ -345,7 +345,7 @@ class DboMysqlTest extends CakeTestCase { 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), ); - $result = $this->db->index($name, false); + $result = $this->db->index('with_compound_keys', false); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); @@ -358,7 +358,7 @@ class DboMysqlTest extends CakeTestCase { 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), 'other_way' => array('column' => array('small_int', 'bool'), 'unique' => 0), ); - $result = $this->db->index($name, false); + $result = $this->db->index('with_multiple_compound_keys', false); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); } From 0a79822b9de901de6f5098990beb4086d98901c3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Oct 2009 21:09:47 -0400 Subject: [PATCH 10/53] Expanding some doc blocks for DataSource. --- cake/libs/model/datasources/datasource.php | 34 +++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index b1b2baefb..c92f8aff6 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -287,42 +287,50 @@ class DataSource extends Object { return false; } /** + * Used to create new records. The "C" CRUD. + * * To-be-overridden in subclasses. * - * @param unknown_type $model - * @param unknown_type $fields - * @param unknown_type $values - * @return unknown + * @param Model $model The Model to be created. + * @param array $fields An Array of fields to be saved. + * @param array $values An Array of values to save. + * @return boolean success */ function create(&$model, $fields = null, $values = null) { return false; } /** + * Used to read records from the Datasource. The "R" in CRUD + * * To-be-overridden in subclasses. * - * @param unknown_type $model - * @param unknown_type $queryData - * @return unknown + * @param Model $model The model being read. + * @param array $queryData An array of query data used to find the data you want + * @return mixed */ function read(&$model, $queryData = array()) { return false; } /** + * Update a record(s) in the datasource. + * * To-be-overridden in subclasses. * - * @param unknown_type $model - * @param unknown_type $fields - * @param unknown_type $values - * @return unknown + * @param Model $model Instance of the model class being updated + * @param array $fields Array of fields to be updated + * @param array $values Array of values to be update $fields to. + * @return boolean Success */ function update(&$model, $fields = null, $values = null) { return false; } /** + * Delete a record(s) in the datasource. + * * To-be-overridden in subclasses. * - * @param unknown_type $model - * @param unknown_type $id + * @param Model $model The model class having record(s) deleted + * @param mixed $id Primary key of the model */ function delete(&$model, $id = null) { if ($id == null) { From a15289fba87f3b3b5a9add16efa3ac9250c85bd8 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Tue, 20 Oct 2009 16:16:31 -0200 Subject: [PATCH 11/53] Saving few Router::normalize() calls, will may increase performance. Fixes #179. --- cake/libs/controller/components/auth.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index a68e5b6f2..420305d57 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -421,10 +421,10 @@ class AuthComponent extends Object { return false; } $defaults = array( - 'loginAction' => Router::normalize(array( - 'controller'=> Inflector::underscore(Inflector::pluralize($this->userModel)), + 'loginAction' => array( + 'controller' => Inflector::underscore(Inflector::pluralize($this->userModel)), 'action' => 'login' - )), + ), 'sessionKey' => 'Auth.' . $this->userModel, 'logoutRedirect' => $this->loginAction, 'loginError' => __('Login failed. Invalid username or password.', true), From 072e1efc130fed9443783910fd6c4ddf884f40d3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 20 Oct 2009 16:11:31 -0400 Subject: [PATCH 12/53] Adding Datasource::enabled() Allows for checking a datasource's ability to be used before attempting to connect it. Added enabled() to all the core dbo's. Fixes whitescreen when trying to use a non installed database driver. Fixes #131 --- cake/libs/model/datasources/datasource.php | 10 ++++++++++ cake/libs/model/datasources/dbo/dbo_adodb.php | 12 +++++++++++- cake/libs/model/datasources/dbo/dbo_db2.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_firebird.php | 9 +++++++++ cake/libs/model/datasources/dbo/dbo_mssql.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_mysql.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_mysqli.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_odbc.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_postgres.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_sqlite.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_sybase.php | 8 ++++++++ cake/libs/model/datasources/dbo_source.php | 4 +++- 12 files changed, 97 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index c92f8aff6..fa7b6632d 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -364,6 +364,16 @@ class DataSource extends Object { function lastAffected($source = null) { return false; } +/** + * Check whether the conditions for the Datasource being available + * are satisfied. Often used from connect() to check for support + * before establishing a connection. + * + * @return boolean Whether or not the Datasources conditions for use are met. + **/ + function enabled() { + return true; + } /** * Returns true if the DataSource supports the given interface (method) * diff --git a/cake/libs/model/datasources/dbo/dbo_adodb.php b/cake/libs/model/datasources/dbo/dbo_adodb.php index 53d6f9601..45fa4048e 100644 --- a/cake/libs/model/datasources/dbo/dbo_adodb.php +++ b/cake/libs/model/datasources/dbo/dbo_adodb.php @@ -102,7 +102,9 @@ class DboAdodb extends DboSource { $adodb_driver = substr($config['connect'], 0, $persistent); $connect = 'PConnect'; } - + if (!$this->enabled()) { + return false; + } $this->_adodb = NewADOConnection($adodb_driver); $this->_adodbDataDict = NewDataDictionary($this->_adodb, $adodb_driver); @@ -114,6 +116,14 @@ class DboAdodb extends DboSource { $this->_adodbMetatyper = &$this->_adodb->execute('Select 1'); return $this->connected; } +/** + * Check that AdoDB is available. + * + * @return boolean + **/ + function enabled() { + return function_exists('NewADOConnection'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_db2.php b/cake/libs/model/datasources/dbo/dbo_db2.php index 4e65d3b43..0942dee85 100644 --- a/cake/libs/model/datasources/dbo/dbo_db2.php +++ b/cake/libs/model/datasources/dbo/dbo_db2.php @@ -136,6 +136,14 @@ class DboDb2 extends DboSource { } return $this->connected; } +/** + * Check that the DB2 extension is installed/loaded + * + * @return boolean + **/ + function enabled() { + return extension_loaded('ibm_db2'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_firebird.php b/cake/libs/model/datasources/dbo/dbo_firebird.php index d02c45b76..dc9cec15f 100644 --- a/cake/libs/model/datasources/dbo/dbo_firebird.php +++ b/cake/libs/model/datasources/dbo/dbo_firebird.php @@ -127,9 +127,18 @@ class DboFirebird extends DboSource { $connect = $config['connect']; $this->connected = false; + $this->connection = $connect($config['host'] . ':' . $config['database'], $config['login'], $config['password']); $this->connected = true; } +/** + * Check that the interbase extension is loaded + * + * @return boolean + **/ + function enabled() { + return extension_loaded('interbase'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index 1b1219d59..b93192f95 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -152,6 +152,14 @@ class DboMssql extends DboSource { } return $this->connected; } +/** + * Check that MsSQL is installed/loaded + * + * @return boolean + **/ + function enabled() { + return extension_loaded('mssql'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 2d97e141c..58433beca 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -388,6 +388,14 @@ class DboMysql extends DboMysqlBase { return $this->connected; } +/** + * Check whether the MySQL extension is installed/loaded + * + * @return boolean + **/ + function enabled() { + return extension_loaded('mysql'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index b0adf8d2e..bf9797d43 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -83,6 +83,14 @@ class DboMysqli extends DboMysqlBase { } return $this->connected; } +/** + * Check that MySQLi is installed/enabled + * + * @return boolean + **/ + function enabled() { + return extension_loaded('mysqli'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_odbc.php b/cake/libs/model/datasources/dbo/dbo_odbc.php index a8572a713..e68948668 100644 --- a/cake/libs/model/datasources/dbo/dbo_odbc.php +++ b/cake/libs/model/datasources/dbo/dbo_odbc.php @@ -105,6 +105,14 @@ class DboOdbc extends DboSource { return $this->connected; } +/** + * Check if the ODBC extension is installed/loaded + * + * @return boolean + **/ + function enabled() { + return extension_loaded('odbc'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 2298fc019..192355fd6 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -122,6 +122,14 @@ class DboPostgres extends DboSource { } return $this->connected; } +/** + * Check if PostgreSQL is enabled/loaded + * + * @return boolean + **/ + function enabled() { + return extension_loaded('pgsql'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index c365b6fe0..005ffc6fe 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -113,6 +113,14 @@ class DboSqlite extends DboSource { } return $this->connected; } +/** + * Check that SQLite is enabled/installed + * + * @return boolean + **/ + function enabled() { + return extension_loaded('sqlite'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo/dbo_sybase.php b/cake/libs/model/datasources/dbo/dbo_sybase.php index 4bed00e43..45e8fd057 100644 --- a/cake/libs/model/datasources/dbo/dbo_sybase.php +++ b/cake/libs/model/datasources/dbo/dbo_sybase.php @@ -102,6 +102,14 @@ class DboSybase extends DboSource { $this->connected = sybase_select_db($config['database'], $this->connection); return $this->connected; } +/** + * Check that one of the sybase extensions is installed + * + * @return boolean + **/ + function enabled() { + return extension_loaded('sybase') || extension_loaded('sybase_ct'); + } /** * Disconnects from database. * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 1b10243d9..013a5baee 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -91,7 +91,9 @@ class DboSource extends DataSource { } parent::__construct($config); $this->fullDebug = Configure::read() > 1; - + if (!$this->enabled()) { + return false; + } if ($autoConnect) { return $this->connect(); } else { From c6f783ebfe04e33eb7b342a6ed18ccc5986e3990 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 20 Oct 2009 22:19:32 -0400 Subject: [PATCH 13/53] Fixing issues with CakeTestCase test case and debug = 3. Fixes #189 --- cake/tests/cases/libs/cake_test_case.test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index 895eaaf40..930683c75 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -78,6 +78,7 @@ class CakeTestCaseTest extends CakeTestCase { * @return void */ function setUp() { + $this->_debug = Configure::read('debug'); $this->Case =& new SubjectCakeTestCase(); $reporter =& new MockCakeHtmlReporter(); $this->Case->setReporter($reporter); @@ -90,6 +91,7 @@ class CakeTestCaseTest extends CakeTestCase { * @return void */ function tearDown() { + Configure::write('debug', $this->_debug); unset($this->Case); unset($this->Reporter); } @@ -239,6 +241,8 @@ class CakeTestCaseTest extends CakeTestCase { * @return void **/ function testTestAction() { + Configure::write('debug', 2); + $_back = array( 'controller' => Configure::read('controllerPaths'), 'view' => Configure::read('viewPaths'), From 0e23fdfbb3d2889870215cfa459e5bbae87acbdb Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 21 Oct 2009 00:22:36 -0400 Subject: [PATCH 14/53] Fixing infinitely nesting stack frames when TreeBehavior::reorder() is called and the models $cacheQueries = true and there are a sizable number of records being manipulated. Test cases added. Fixes #188 --- cake/libs/model/behaviors/tree.php | 5 ++++- .../cases/libs/model/behaviors/tree.test.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index da23c193d..145d298e1 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -460,7 +460,7 @@ class TreeBehavior extends ModelBehavior { 'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive) ); if ($nextNode) { - list($nextNode)= array_values($nextNode); + list($nextNode) = array_values($nextNode); } else { return false; } @@ -640,6 +640,8 @@ class TreeBehavior extends ModelBehavior { $sort = $field . ' ' . $order; $nodes = $this->children($Model, $id, true, $fields, $sort, null, null, $recursive); + $cacheQueries = $Model->cacheQueries; + $Model->cacheQueries = false; if ($nodes) { foreach ($nodes as $node) { $id = $node[$Model->alias][$Model->primaryKey]; @@ -649,6 +651,7 @@ class TreeBehavior extends ModelBehavior { } } } + $Model->cacheQueries = $cacheQueries; return true; } /** diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php index 147da89ae..86834122b 100644 --- a/cake/tests/cases/libs/model/behaviors/tree.test.php +++ b/cake/tests/cases/libs/model/behaviors/tree.test.php @@ -1172,6 +1172,25 @@ class NumberTreeTest extends CakeTestCase { $sortedNodes = $this->Tree->find('list', array('order' => $leftField)); $this->assertIdentical($nodes, $sortedNodes); } +/** + * test reordering large-ish trees with cacheQueries = true. + * This caused infinite loops when moving down elements as stale data is returned + * from the memory cache + * + * @access public + * @return void + */ + function testReorderBigTreeWithQueryCaching() { + extract($this->settings); + $this->Tree =& new $modelClass(); + $this->Tree->initialize(2, 10); + + $original = $this->Tree->cacheQueries; + $this->Tree->cacheQueries = true; + $this->Tree->reorder(array('field' => 'name', 'direction' => 'DESC')); + $this->assertTrue($this->Tree->cacheQueries, 'cacheQueries was not restored after reorder(). %s'); + $this->Tree->cacheQueries = $original; + } /** * testGenerateTreeListWithSelfJoin method * From 0cc1d84737a1445e4f2972b70b658bfb56e60997 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Aug 2009 22:51:10 -0400 Subject: [PATCH 15/53] Removing use of e() from core and test suite. --- cake/console/libs/templates/skel/views/layouts/xml/default.ctp | 2 +- cake/tests/test_app/views/layouts/xml/default.ctp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/console/libs/templates/skel/views/layouts/xml/default.ctp b/cake/console/libs/templates/skel/views/layouts/xml/default.ctp index c68870298..566ca2158 100644 --- a/cake/console/libs/templates/skel/views/layouts/xml/default.ctp +++ b/cake/console/libs/templates/skel/views/layouts/xml/default.ctp @@ -1,2 +1,2 @@ -header()); ?> +header(); ?> \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/xml/default.ctp b/cake/tests/test_app/views/layouts/xml/default.ctp index c68870298..566ca2158 100644 --- a/cake/tests/test_app/views/layouts/xml/default.ctp +++ b/cake/tests/test_app/views/layouts/xml/default.ctp @@ -1,2 +1,2 @@ -header()); ?> +header(); ?> \ No newline at end of file From 8b419d2dd8b0e2fa4bfa1c3e549aeba5a31c80c1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Aug 2009 22:54:57 -0400 Subject: [PATCH 16/53] Removing use of ife() from core classes. --- cake/libs/validation.php | 2 +- cake/libs/view/helpers/javascript.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index be0d20c2a..6531d97d9 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -806,7 +806,7 @@ class Validation extends Object { $_this =& Validation::getInstance(); $_this->check = $check; $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=') . '\/0-9a-z]|(%[0-9a-f]{2}))'; - $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . ife($strict, '', '?') . + $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') . '(?:' . $_this->__pattern['ip'] . '|' . $_this->__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' . '(?:\/?|\/' . $validChars . '*)?' . '(?:\?' . $validChars . '*)?' . diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index 21eab7f44..aa8d7577f 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -678,7 +678,7 @@ class JavascriptHelper extends AppHelper { $val = 'null'; break; case (is_bool($val)): - $val = ife($val, 'true', 'false'); + $val = !empty($val) ? 'true' : 'false'; break; case (is_int($val)): $val = $val; From 0657afcf30763320664262bfd3f6fbfee0042c14 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 21 Oct 2009 13:03:24 -0400 Subject: [PATCH 17/53] Removing use of low() from core classes. Refs #6525 --- cake/basics.php | 2 +- cake/console/libs/api.php | 4 ++-- cake/console/libs/tasks/db_config.php | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index 5e387c553..8a9c7b527 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -467,7 +467,7 @@ if (!function_exists('file_put_contents')) { $expires = strtotime($expires, $now); } - switch (low($target)) { + switch (strtolower($target)) { case 'cache': $filename = CACHE . $path; break; diff --git a/cake/console/libs/api.php b/cake/console/libs/api.php index 87aefc10a..c370d7310 100644 --- a/cake/console/libs/api.php +++ b/cake/console/libs/api.php @@ -169,8 +169,8 @@ class ApiShell extends Shell { foreach ($commands as $cmd) { $this->out("{$cmd}\n\n"); } - } elseif (isset($commands[low($this->args[1])])) { - $this->out($commands[low($this->args[1])] . "\n\n"); + } elseif (isset($commands[strtolower($this->args[1])])) { + $this->out($commands[strtolower($this->args[1])] . "\n\n"); } else { $this->out("Command '" . $this->args[1] . "' not found"); } diff --git a/cake/console/libs/tasks/db_config.php b/cake/console/libs/tasks/db_config.php index d2f05393b..3126c00d9 100644 --- a/cake/console/libs/tasks/db_config.php +++ b/cake/console/libs/tasks/db_config.php @@ -109,7 +109,7 @@ class DbConfigTask extends Shell { $persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n'); } - if (low($persistent) == 'n') { + if (strtolower($persistent) == 'n') { $persistent = 'false'; } else { $persistent = 'true'; @@ -125,7 +125,7 @@ class DbConfigTask extends Shell { $port = $this->in('Port?', null, 'n'); } - if (low($port) == 'n') { + if (strtolower($port) == 'n') { $port = null; } $login = ''; @@ -158,7 +158,7 @@ class DbConfigTask extends Shell { $prefix = $this->in('Table Prefix?', null, 'n'); } - if (low($prefix) == 'n') { + if (strtolower($prefix) == 'n') { $prefix = null; } $encoding = ''; @@ -167,7 +167,7 @@ class DbConfigTask extends Shell { $encoding = $this->in('Table encoding?', null, 'n'); } - if (low($encoding) == 'n') { + if (strtolower($encoding) == 'n') { $encoding = null; } $schema = ''; @@ -178,7 +178,7 @@ class DbConfigTask extends Shell { } } - if (low($schema) == 'n') { + if (strtolower($schema) == 'n') { $schema = null; } @@ -190,7 +190,7 @@ class DbConfigTask extends Shell { $dbConfigs[] = $config; $doneYet = $this->in('Do you wish to add another database configuration?', null, 'n'); - if (low($doneYet == 'n')) { + if (strtolower($doneYet == 'n')) { $done = true; } } From 1ee9771efbe2f6dd0431ac5b025e0f6fd55b9b89 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 21 Oct 2009 13:12:03 -0400 Subject: [PATCH 18/53] Removing ife() from AclShell. Refs #6562 --- cake/console/libs/acl.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php index 5a7873da8..15b678404 100644 --- a/cake/console/libs/acl.php +++ b/cake/console/libs/acl.php @@ -225,7 +225,7 @@ class AclShell extends Shell { $this->_checkArgs(2, 'getPath'); $this->checkNodeType(); extract($this->__dataVars()); - $id = ife(is_numeric($this->args[1]), intval($this->args[1]), $this->args[1]); + $id = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1]; $nodes = $this->Acl->{$class}->getPath($id); if (empty($nodes)) { $this->error(sprintf(__("Supplied Node '%s' not found", true), $this->args[1]), __("No tree returned.", true)); @@ -304,7 +304,7 @@ class AclShell extends Shell { $this->checkNodeType(); extract($this->__dataVars()); if (isset($this->args[1]) && !is_null($this->args[1])) { - $key = ife(is_numeric($this->args[1]), $secondary_id, 'alias'); + $key = is_numeric($this->args[1]) ? $secondary_id : 'alias'; $conditions = array($class . '.' . $key => $this->args[1]); } else { $conditions = null; @@ -425,8 +425,8 @@ class AclShell extends Shell { foreach ($commands as $cmd) { $this->out("{$cmd}\n\n"); } - } elseif (isset($commands[low($this->args[0])])) { - $this->out($commands[low($this->args[0])] . "\n\n"); + } elseif (isset($commands[strtolower($this->args[0])])) { + $this->out($commands[strtolower($this->args[0])] . "\n\n"); } else { $this->out(sprintf(__("Command '%s' not found", true), $this->args[0])); } @@ -457,7 +457,7 @@ class AclShell extends Shell { return false; } extract($this->__dataVars($this->args[0])); - $key = (ife(is_numeric($this->args[1]), $secondary_id, 'alias')); + $key = is_numeric($this->args[1]) ? $secondary_id : 'alias'; $conditions = array($class . '.' . $key => $this->args[1]); $possibility = $this->Acl->{$class}->find('all', compact('conditions')); if (empty($possibility)) { @@ -472,8 +472,8 @@ class AclShell extends Shell { * @access private */ function __getParams() { - $aro = ife(is_numeric($this->args[0]), intval($this->args[0]), $this->args[0]); - $aco = ife(is_numeric($this->args[1]), intval($this->args[1]), $this->args[1]); + $aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0]; + $aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1]; if (is_string($aro) && preg_match('/^([\w]+)\.(.*)$/', $aro, $matches)) { $aro = array( @@ -512,7 +512,7 @@ class AclShell extends Shell { } $vars = array(); $class = ucwords($type); - $vars['secondary_id'] = ife(strtolower($class) == 'aro', 'foreign_key', 'object_id'); + $vars['secondary_id'] = strtolower($class) == 'aro' ? 'foreign_key' : 'object_id'; $vars['data_name'] = $type; $vars['table_name'] = $type . 's'; $vars['class'] = $class; From 4e8c268536081966f124cea7c5947fe341cc6d6a Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Wed, 21 Oct 2009 19:19:21 -0200 Subject: [PATCH 19/53] Making the test more clear by avoind +-2 days thing. Fixes #186. --- .../cases/libs/view/helpers/time.test.php | 62 ++++--------------- 1 file changed, 12 insertions(+), 50 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 7fd5c1b15..997d3092b 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -470,57 +470,19 @@ class TimeHelperTest extends CakeTestCase { * @return void */ function testIsThisWeek() { - switch (date('D')) { - case 'Mon' : - for ($i = 0; $i < 6; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+7 days")); - $this->assertFalse($this->Time->isThisWeek("-1 days")); - break; - case 'Tue' : - for ($i = -1; $i < 5; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+6 days")); - $this->assertFalse($this->Time->isThisWeek("-2 days")); - break; - case 'Wed' : - for ($i = -2; $i < 5; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+5 days")); - $this->assertFalse($this->Time->isThisWeek("-3 days")); - break; - case 'Thu' : - for ($i = -3; $i < 4; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+4 days")); - $this->assertFalse($this->Time->isThisWeek("-4 days")); - break; - case 'Fri' : - for ($i = -4; $i < 3; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+3 days")); - $this->assertFalse($this->Time->isThisWeek("-5 days")); - break; - case 'Sat' : - for ($i = -5; $i < 2; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+2 days")); - $this->assertFalse($this->Time->isThisWeek("-6 days")); - break; - case 'Sun' : - for ($i = -6; $i < 1; $i++) { - $this->assertTrue($this->Time->isThisWeek("+$i days")); - } - $this->assertFalse($this->Time->isThisWeek("+1 days")); - $this->assertFalse($this->Time->isThisWeek("-7 days")); - break; + // A map of days which goes from -1 day of week to +1 day of week + $map = array( + 'Mon' => array(-1, 7), 'Tue' => array(-2, 6), 'Wed' => array(-3, 5), + 'Thu' => array(-4, 4), 'Fri' => array(-5, 3), 'Sat' => array(-6, 2), + 'Sun' => array(-7, 1) + ); + $days = $map[date('D')]; + + for ($day = $days[0] + 1; $day < $days[1]; $day++) { + $this->assertTrue($this->Time->isThisWeek(($day > 0 ? '+' : '') . $day . ' days')); } + $this->assertFalse($this->Time->isThisWeek($days[0] . ' days')); + $this->assertFalse($this->Time->isThisWeek('+' . $days[1] . ' days')); } /** * testIsThisMonth method From 3dbae37aadc903f380647d9454e25635d3e560ab Mon Sep 17 00:00:00 2001 From: ceeram Date: Thu, 22 Oct 2009 12:34:25 +0200 Subject: [PATCH 20/53] fixing failing i18n testcase, caused by setting $category parameter for __c(), __dc() and __dcn() as LC_MONETARY instead of numeric value --- cake/tests/cases/libs/i18n.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/i18n.test.php b/cake/tests/cases/libs/i18n.test.php index 3aa5b2f57..01b271871 100644 --- a/cake/tests/cases/libs/i18n.test.php +++ b/cake/tests/cases/libs/i18n.test.php @@ -2557,7 +2557,7 @@ class I18nTest extends CakeTestCase { * @access private * @return void */ - function __domainCategorySingular($domain = 'test_plugin', $category = LC_MONETARY) { + function __domainCategorySingular($domain = 'test_plugin', $category = 3) { $singular = __dc($domain, 'Plural Rule 1', $category, true); return $singular; } @@ -2567,7 +2567,7 @@ class I18nTest extends CakeTestCase { * @access private * @return void */ - function __domainCategoryPlural($domain = 'test_plugin', $category = LC_MONETARY) { + function __domainCategoryPlural($domain = 'test_plugin', $category = 3) { $plurals = array(); for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category, true), (float)$number); @@ -2603,7 +2603,7 @@ class I18nTest extends CakeTestCase { * @access private * @return void */ - function __category($category = LC_MONETARY) { + function __category($category = 3) { $singular = __c('Plural Rule 1', $category, true); return $singular; } From d25497c52702e0962b85bc6f5692a948d0dbd17e Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 22 Oct 2009 13:51:55 -0400 Subject: [PATCH 21/53] Adding Skip to mb_strrpos test case. Skips the test if mbstring is installed and php version is 5.1.x. mb_strrpos had an incompatible function signature in these versions. --- cake/tests/cases/libs/multibyte.test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cake/tests/cases/libs/multibyte.test.php b/cake/tests/cases/libs/multibyte.test.php index 68950cc78..dd0ea371c 100644 --- a/cake/tests/cases/libs/multibyte.test.php +++ b/cake/tests/cases/libs/multibyte.test.php @@ -4786,6 +4786,10 @@ class MultibyteTest extends CakeTestCase { * @return void */ function testUsingMbStrrpos() { + $skip = extension_loaded('mbstring') && version_compare(PHP_VERSION, '5.2.0', '<'); + if ($this->skipIf($skip, '%s PHP version does not support $offset parameter in mb_strrpos().')) { + return; + } $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $find = 'F'; $result = mb_strrpos($string, $find); From c6999aea7f66bad6bd98e460351e045a0a6d4374 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 24 Oct 2009 10:46:28 -0400 Subject: [PATCH 22/53] Moving DboMysqli::describe() and DboMysql::describe() into DboMysqlBase. Removes duplicated method code. --- cake/libs/model/datasources/dbo/dbo_mysql.php | 68 +++++++++---------- .../libs/model/datasources/dbo/dbo_mysqli.php | 37 ---------- 2 files changed, 34 insertions(+), 71 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 58433beca..ef61cb675 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -85,6 +85,40 @@ class DboMysqlBase extends DboSource { 'binary' => array('name' => 'blob'), 'boolean' => array('name' => 'tinyint', 'limit' => '1') ); +/** + * Returns an array of the fields in given table name. + * + * @param string $tableName Name of database table to inspect + * @return array Fields in table. Keys are name and type + */ + function describe(&$model) { + $cache = parent::describe($model); + if ($cache != null) { + return $cache; + } + $fields = false; + $cols = $this->query('DESCRIBE ' . $this->fullTableName($model)); + + foreach ($cols as $column) { + $colKey = array_keys($column); + if (isset($column[$colKey[0]]) && !isset($column[0])) { + $column[0] = $column[$colKey[0]]; + } + if (isset($column[0])) { + $fields[$column[0]['Field']] = array( + 'type' => $this->column($column[0]['Type']), + 'null' => ($column[0]['Null'] == 'YES' ? true : false), + 'default' => $column[0]['Default'], + 'length' => $this->length($column[0]['Type']), + ); + if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) { + $fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']]; + } + } + } + $this->__cacheDescription($this->fullTableName($model, false), $fields); + return $fields; + } /** * Generates and executes an SQL UPDATE statement for given model, fields, and values. * @@ -442,40 +476,6 @@ class DboMysql extends DboMysqlBase { return $tables; } } -/** - * Returns an array of the fields in given table name. - * - * @param string $tableName Name of database table to inspect - * @return array Fields in table. Keys are name and type - */ - function describe(&$model) { - $cache = parent::describe($model); - if ($cache != null) { - return $cache; - } - $fields = false; - $cols = $this->query('DESCRIBE ' . $this->fullTableName($model)); - - foreach ($cols as $column) { - $colKey = array_keys($column); - if (isset($column[$colKey[0]]) && !isset($column[0])) { - $column[0] = $column[$colKey[0]]; - } - if (isset($column[0])) { - $fields[$column[0]['Field']] = array( - 'type' => $this->column($column[0]['Type']), - 'null' => ($column[0]['Null'] == 'YES' ? true : false), - 'default' => $column[0]['Default'], - 'length' => $this->length($column[0]['Type']), - ); - if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) { - $fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']]; - } - } - } - $this->__cacheDescription($this->fullTableName($model, false), $fields); - return $fields; - } /** * Returns a quoted and escaped string of $data for use in an SQL statement. * diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index bf9797d43..910504082 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -157,43 +157,6 @@ class DboMysqli extends DboMysqlBase { parent::listSources($tables); return $tables; } -/** - * Returns an array of the fields in given table name. - * - * @param string $tableName Name of database table to inspect - * @return array Fields in table. Keys are name and type - */ - function describe(&$model) { - - $cache = parent::describe($model); - if ($cache != null) { - return $cache; - } - - $fields = false; - $cols = $this->query('DESCRIBE ' . $this->fullTableName($model)); - - foreach ($cols as $column) { - $colKey = array_keys($column); - if (isset($column[$colKey[0]]) && !isset($column[0])) { - $column[0] = $column[$colKey[0]]; - } - if (isset($column[0])) { - $fields[$column[0]['Field']] = array( - 'type' => $this->column($column[0]['Type']), - 'null' => ($column[0]['Null'] == 'YES' ? true : false), - 'default' => $column[0]['Default'], - 'length' => $this->length($column[0]['Type']) - ); - if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) { - $fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']]; - } - } - } - - $this->__cacheDescription($this->fullTableName($model, false), $fields); - return $fields; - } /** * Returns a quoted and escaped string of $data for use in an SQL statement. * From 14bd47842ca767571596a1be159356dd8f66fb60 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 24 Oct 2009 11:06:27 -0400 Subject: [PATCH 23/53] Removing length() from DboMysqli, fixes incorrect float length parsing. Test case added. --- .../libs/model/datasources/dbo/dbo_mysqli.php | 19 ---------------- .../model/datasources/dbo/dbo_mysqli.test.php | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index 910504082..2742a7c31 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -298,25 +298,6 @@ class DboMysqli extends DboMysqlBase { } return 'text'; } -/** - * Gets the length of a database-native column description, or null if no length - * - * @param string $real Real database-layer column type (i.e. "varchar(255)") - * @return integer An integer representing the length of the column - */ - function length($real) { - $col = str_replace(array(')', 'unsigned'), '', $real); - $limit = null; - - if (strpos($col, '(') !== false) { - list($col, $limit) = explode('(', $col); - } - - if ($limit != null) { - return intval($limit); - } - return null; - } /** * Enter description here... * diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php index 3b19174c4..2e1e87a66 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php @@ -154,6 +154,7 @@ class MysqliTestModel extends Model { * @subpackage cake.tests.cases.libs.model.datasources.dbo */ class DboMysqliTest extends CakeTestCase { + var $fixtures = array('core.datatype'); /** * The Dbo instance to be tested * @@ -176,8 +177,6 @@ class DboMysqliTest extends CakeTestCase { * @access public */ function setUp() { - $db = ConnectionManager::getDataSource('test_suite'); - $this->db = new DboMysqliTestDb($db->config); $this->model = new MysqliTestModel(); } /** @@ -186,7 +185,8 @@ class DboMysqliTest extends CakeTestCase { * @access public */ function tearDown() { - unset($this->db); + unset($this->model); + ClassRegistry::flush(); } /** * testIndexDetection method @@ -195,7 +195,7 @@ class DboMysqliTest extends CakeTestCase { * @access public */ function testIndexDetection() { - $this->db->cacheSources = $this->db->testing = false; + $this->db->cacheSources = false; $name = $this->db->fullTableName('simple'); $this->db->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); @@ -298,12 +298,14 @@ class DboMysqliTest extends CakeTestCase { $this->assertEqual($result, $expected); } /** - * undocumented function + * test mysqli transactions * * @return void * @access public */ function testTransactions() { + $this->db->cacheSources = false; + $this->db->begin($this->model); $this->assertTrue($this->db->_transactionStarted); @@ -313,5 +315,15 @@ class DboMysqliTest extends CakeTestCase { $this->db->commit($this->model); $this->assertFalse($this->db->_transactionStarted); } +/** + * test that float values are correctly identified + * + * @return void + **/ + function testFloatParsing() { + $model =& new Model(array('ds' => 'test_suite', 'table' => 'datatypes', 'name' => 'Datatype')); + $result = $this->db->describe($model); + $this->assertEqual((string)$result['float_field']['length'], '5,2'); + } } ?> \ No newline at end of file From 72830cb125204f27b7055c8d8f41fa9bfef1a808 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 24 Oct 2009 11:26:06 -0400 Subject: [PATCH 24/53] Adding test case for model task Fixing missing case for float datatypes when generating fixtures. Fixes #204 --- cake/console/libs/tasks/model.php | 6 +- .../cases/console/libs/tasks/model.test.php | 90 +++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 cake/tests/cases/console/libs/tasks/model.test.php diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 779d088f8..2d75be9ba 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -99,6 +99,7 @@ class ModelTask extends Shell { if (count($connections) > 1) { $useDbConfig = $this->in(__('Use Database Config', true) .':', $connections, 'default'); } + $this->useDbConfig = $useDbConfig; $currentModelName = $this->getName($useDbConfig); $db =& ConnectionManager::getDataSource($useDbConfig); @@ -843,7 +844,7 @@ class ModelTask extends Shell { $out .= "\tvar \$table = '$useTable';\n"; } $schema = new CakeSchema(); - $data = $schema->read(array('models' => false)); + $data = $schema->read(array('models' => false, 'connection' => $this->useDbConfig)); if (!isset($data['tables'][$useTable])) { return false; @@ -865,6 +866,7 @@ class ModelTask extends Shell { $col = "\t\t'{$field}' => array('type'=>'" . $value['type'] . "', "; switch ($value['type']) { + case 'float': case 'integer': $insert = 1; break; @@ -898,7 +900,7 @@ class ModelTask extends Shell { $insert .= "feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.'"; break; } - $records[] = "\t\t'$field' => $insert"; + $records[] = "\t\t'$field' => $insert"; unset($value['type']); $col .= join(', ', $schema->__values($value)); } else { diff --git a/cake/tests/cases/console/libs/tasks/model.test.php b/cake/tests/cases/console/libs/tasks/model.test.php new file mode 100644 index 000000000..b273b69cc --- /dev/null +++ b/cake/tests/cases/console/libs/tasks/model.test.php @@ -0,0 +1,90 @@ +Dispatcher =& new TestModelTaskMockShellDispatcher(); + $this->Task =& new MockModelTask($this->Dispatcher); + $this->Task->Dispatch =& $this->Dispatcher; + } +/** + * tearDown method + * + * @return void + * @access public + */ + function tearDown() { + ClassRegistry::flush(); + } +/** + * test fixture generation with floats + * + * @return void + **/ + function testFixtureGeneration() { + $this->Task->useDbConfig = 'test_suite'; + $this->Task->setReturnValue('createFile', true); + $result = $this->Task->fixture('Datatype'); + $this->assertPattern('/float_field\' => 1/', $result); + + } +} +?> \ No newline at end of file From 79fdd8b341437287549ace1f413bd495e6db8d3e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 24 Oct 2009 12:53:22 -0400 Subject: [PATCH 25/53] Adding test to ensure blob integrity. Disproves #199 --- .../model/datasources/dbo/dbo_mysql.test.php | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index cf9cc833c..26a9bc9c0 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -153,6 +153,7 @@ class MysqlTestModel extends Model { * @subpackage cake.tests.cases.libs.model.datasources.dbo */ class DboMysqlTest extends CakeTestCase { + var $fixtures = array('core.binary_test'); /** * The Dbo instance to be tested * @@ -176,7 +177,6 @@ class DboMysqlTest extends CakeTestCase { */ function setUp() { $db = ConnectionManager::getDataSource('test_suite'); - $this->db = new DboMysqlTestDb($db->config); $this->model = new MysqlTestModel(); } /** @@ -185,7 +185,8 @@ class DboMysqlTest extends CakeTestCase { * @access public */ function tearDown() { - unset($this->db); + unset($this->model); + ClassRegistry::flush(); } /** * startCase @@ -269,7 +270,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testTinyintCasting() { - $this->db->cacheSources = $this->db->testing = false; + $this->db->cacheSources = false; $this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $this->model = new CakeTestModel(array( @@ -307,7 +308,7 @@ class DboMysqlTest extends CakeTestCase { * @access public */ function testIndexDetection() { - $this->db->cacheSources = $this->db->testing = false; + $this->db->cacheSources = false; $name = $this->db->fullTableName('simple'); $this->db->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); @@ -510,7 +511,7 @@ class DboMysqlTest extends CakeTestCase { */ function testAlterSchemaIndexes() { App::import('Core', 'Schema'); - $this->db->cacheSources = $this->db->testing = false; + $this->db->cacheSources = false; $schema1 =& new CakeSchema(array( 'name' => 'AlterTest1', @@ -574,5 +575,23 @@ class DboMysqlTest extends CakeTestCase { $this->db->query($this->db->dropSchema($schema1)); } +/** + * test saving and retrieval of blobs + * + * @return void + **/ + function testBlobSaving() { + $this->db->cacheSources = false; + $data = "GIF87ab + Ò4A¿¿¿ˇˇˇ,b + ¢îè©ÀÌ#¥⁄ã≥fi:¯Ü‚Héá¶jV∂ÓúÎL≥çÀóËıÎ…>ï≈ vFE%ÒâLFI<†µw˝±≈£7˘ç^H“≤« >Éâ*∑ÇnÖA•Ù|flêèj£:=ÿ6óUàµ5'∂®àA¬ñ∆ˆGE(gt’≈àÚyÁó«7 ‚VìöÇ√˙Ç™ + k”:;kÀAõ{*¡€Î˚˚[;;"; + + $model =& new AppModel(array('name' => 'BinaryTest', 'ds' => 'test_suite')); + $model->save(compact('data')); + + $result = $model->find('first'); + $this->assertEqual($result['BinaryTest']['data'], $data); + } } ?> \ No newline at end of file From 5a093e56272d614c7bb33adee0eb4dfd3cc701c1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 27 Oct 2009 13:22:34 -0400 Subject: [PATCH 26/53] Fixing issues in postgres with time columns and '' values. Tests added. Fixes #213 --- cake/libs/model/datasources/dbo/dbo_postgres.php | 1 + .../cases/libs/model/datasources/dbo/dbo_postgres.test.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 192355fd6..3ea5d8fa0 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -286,6 +286,7 @@ class DboPostgres extends DboSource { case 'date': case 'datetime': case 'timestamp': + case 'time': if ($data === '') { return $read ? 'NULL' : 'DEFAULT'; } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index aec59ba4c..ff6588668 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -291,11 +291,11 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->db2->value(null, 'boolean'), "NULL"); } /** - * test that date columns do not generate errors with null and nullish values. + * test that date and time columns do not generate errors with null and nullish values. * * @return void **/ - function testDateAsNull() { + function testDateAndTimeAsNull() { $this->assertEqual($this->db2->value(null, 'date'), 'NULL'); $this->assertEqual($this->db2->value('', 'date'), 'NULL'); @@ -304,6 +304,9 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->db2->value('', 'timestamp'), 'NULL'); $this->assertEqual($this->db2->value(null, 'timestamp'), 'NULL'); + + $this->assertEqual($this->db2->value('', 'time'), 'NULL'); + $this->assertEqual($this->db2->value(null, 'time'), 'NULL'); } /** * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans From 00d7c655ce57fd9b33250e3ba10441604a89bd87 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 27 Oct 2009 13:28:43 -0400 Subject: [PATCH 27/53] Improving documentation for PaginatorHelper::sort() Fixes #210 --- cake/libs/view/helpers/paginator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 7b5dd09a2..0e8505ecf 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -207,11 +207,13 @@ class PaginatorHelper extends AppHelper { return $this->__pagingLink('Next', $title, $options, $disabledTitle, $disabledOptions); } /** - * Generates a sorting link + * Generates a sorting link. Sets named parameters for the sort and direction. Handles + * direction switching automatically. * - * @param string $title Title for the link. - * @param string $key The name of the key that the recordset should be sorted. - * @param array $options Options for sorting link. See #options for list of keys. + * @param string $title Title for the link. + * @param string $key The name of the key that the recordset should be sorted. If $key is null + * $title will be used for the key, and a title will be generated by inflection. + * @param array $options Options for sorting link. See #options for list of keys. * @return string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified * key the returned link will sort by 'desc'. */ From 23ab84596aa2083acea08d7b33e275f4322b7f2b Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 27 Oct 2009 21:04:14 -0400 Subject: [PATCH 28/53] Adding discrete tests to Folder::addPathElement --- cake/tests/cases/libs/folder.test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index 6fad570de..0793630c2 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -215,6 +215,18 @@ class FolderTest extends CakeTestCase { $result = $Folder->delete($new); $this->assertTrue($result); } +/** + * test Adding path elements to a path + * + * @return void + **/ + function testAddPathElement() { + $result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path'); + $this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); + + $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path'); + $this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); + } /** * testFolderRead method * From ad305a890a9854f55b6da97d734f6e738a024066 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 27 Oct 2009 21:06:58 -0400 Subject: [PATCH 29/53] Applying optimization from 'ermayer' Reduces functions called from Folder::addPathElement() Fixes #178 --- cake/libs/folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 28f32672a..a5331f80f 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -302,7 +302,7 @@ class Folder extends Object { * @static */ function addPathElement($path, $element) { - return Folder::slashTerm($path) . $element; + return rtrim($path, DS) . DS . $element; } /** * Returns true if the File is in a given CakePath. From a31a2d264c2cd128de2db839fa2901680c7de2ba Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 29 Oct 2009 19:47:29 -0400 Subject: [PATCH 30/53] Fixing Debugger::log() . The method used protected properties only available in test cases. No stack trace was being logged when called either. Method has been updated to match its doc block better. Fixes #222 --- cake/libs/debugger.php | 12 ++---------- cake/tests/cases/libs/debugger.test.php | 1 + 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 1e942e5f6..a49b39abb 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -139,16 +139,8 @@ class Debugger extends Object { */ function log($var, $level = LOG_DEBUG) { $_this = Debugger::getInstance(); - $trace = $_this->trace(array('start' => 1, 'depth' => 2, 'format' => 'array')); - $source = null; - - if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) { - $stack = $trace[0]['object']->_reporter->_test_stack; - $source = sprintf('[%1$s, %3$s::%2$s()]' . "\n", - array_shift($stack), array_pop($stack), array_pop($stack)); - } - - CakeLog::write($level, $source . $_this->exportVar($var)); + $source = $_this->trace(array('start' => 1)) . "\n"; + CakeLog::write($level, "\n" . $source . $_this->exportVar($var)); } /** diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index 6f1f0162c..8f57cbbd0 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -226,6 +226,7 @@ class DebuggerTest extends CakeTestCase { Debugger::log(array('whatever', 'here')); $result = file_get_contents(TMP . 'logs' . DS . 'debug.log'); $this->assertPattern('/DebuggerTest\:\:testLog/', $result); + $this->assertPattern('/\[main\]/', $result); $this->assertPattern('/array/', $result); $this->assertPattern('/"whatever",/', $result); $this->assertPattern('/"here"/', $result); From 17edec84607ad1a347113278bddc3eed988c5e21 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 29 Oct 2009 20:14:36 -0400 Subject: [PATCH 31/53] Changin how HttpSocket parses query string parameters. Makes HttpSocket querystring parameter parsing more congruent with how PHP handles query string parameters in that it doesn't require urlencoded characters. Tests added. Fixes #156 --- cake/libs/http_socket.php | 2 +- cake/tests/cases/libs/http_socket.test.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 76d12d710..793618ece 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -672,7 +672,7 @@ class HttpSocket extends CakeSocket { foreach ($items as $item) { if (strpos($item, '=') !== false) { - list($key, $value) = explode('=', $item); + list($key, $value) = explode('=', $item, 2); } else { $key = $item; $value = null; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index b3fa948b1..2dbc193d9 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -878,6 +878,28 @@ class HttpSocketTest extends CakeTestCase { 'host' => 'www.google.com', 'port' => 8080, )); + + $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2%3Dvalue3'); + $this->assertIdentical($uri, array( + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'path' => '/', + 'query' => array( + 'param1' => 'value1', + 'param2' => 'value2=value3' + ) + )); + + $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2=value3'); + $this->assertIdentical($uri, array( + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'path' => '/', + 'query' => array( + 'param1' => 'value1', + 'param2' => 'value2=value3' + ) + )); } /** * Tests that HttpSocket::buildUri can turn all kinds of uri arrays (and strings) into fully or partially qualified URI's From 2e3bbe363dde2bfab61f783d4adea78d839e618c Mon Sep 17 00:00:00 2001 From: Gordon Pettey Date: Fri, 30 Oct 2009 16:30:11 -0400 Subject: [PATCH 32/53] Array coding convention and extraneous punctuation Signed-off-by: Mark Story --- cake/console/libs/tasks/controller.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cake/console/libs/tasks/controller.php b/cake/console/libs/tasks/controller.php index 736522a84..efc363106 100644 --- a/cake/console/libs/tasks/controller.php +++ b/cake/console/libs/tasks/controller.php @@ -267,10 +267,10 @@ class ControllerTask extends Shell { $actions .= "\tfunction {$admin}view(\$id = null) {\n"; $actions .= "\t\tif (!\$id) {\n"; if ($wannaUseSession) { - $actions .= "\t\t\t\$this->Session->setFlash(__('Invalid {$singularHumanName}.', true));\n"; - $actions .= "\t\t\t\$this->redirect(array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->Session->setFlash(__('Invalid {$singularHumanName}', true));\n"; + $actions .= "\t\t\t\$this->redirect(array('action' => 'index'));\n"; } else { - $actions .= "\t\t\t\$this->flash(__('Invalid {$singularHumanName}', true), array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->flash(__('Invalid {$singularHumanName}', true), array('action' => 'index'));\n"; } $actions .= "\t\t}\n"; $actions .= "\t\t\$this->set('" . $singularName . "', \$this->{$currentModelName}->read(null, \$id));\n"; @@ -285,9 +285,9 @@ class ControllerTask extends Shell { $actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n"; if ($wannaUseSession) { $actions .= "\t\t\t\t\$this->Session->setFlash(__('The " . $singularHumanName . " has been saved', true));\n"; - $actions .= "\t\t\t\t\$this->redirect(array('action'=>'index'));\n"; + $actions .= "\t\t\t\t\$this->redirect(array('action' => 'index'));\n"; } else { - $actions .= "\t\t\t\t\$this->flash(__('{$currentModelName} saved.', true), array('action'=>'index'));\n"; + $actions .= "\t\t\t\t\$this->flash(__('{$currentModelName} saved.', true), array('action' => 'index'));\n"; } $actions .= "\t\t\t} else {\n"; if ($wannaUseSession) { @@ -324,18 +324,18 @@ class ControllerTask extends Shell { $actions .= "\t\tif (!\$id && empty(\$this->data)) {\n"; if ($wannaUseSession) { $actions .= "\t\t\t\$this->Session->setFlash(__('Invalid {$singularHumanName}', true));\n"; - $actions .= "\t\t\t\$this->redirect(array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->redirect(array('action' => 'index'));\n"; } else { - $actions .= "\t\t\t\$this->flash(__('Invalid {$singularHumanName}', true), array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->flash(__('Invalid {$singularHumanName}', true), array('action' => 'index'));\n"; } $actions .= "\t\t}\n"; $actions .= "\t\tif (!empty(\$this->data)) {\n"; $actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n"; if ($wannaUseSession) { $actions .= "\t\t\t\t\$this->Session->setFlash(__('The " . $singularHumanName . " has been saved', true));\n"; - $actions .= "\t\t\t\t\$this->redirect(array('action'=>'index'));\n"; + $actions .= "\t\t\t\t\$this->redirect(array('action' => 'index'));\n"; } else { - $actions .= "\t\t\t\t\$this->flash(__('The " . $singularHumanName . " has been saved.', true), array('action'=>'index'));\n"; + $actions .= "\t\t\t\t\$this->flash(__('The " . $singularHumanName . " has been saved.', true), array('action' => 'index'));\n"; } $actions .= "\t\t\t} else {\n"; if ($wannaUseSession) { @@ -373,17 +373,17 @@ class ControllerTask extends Shell { $actions .= "\t\tif (!\$id) {\n"; if ($wannaUseSession) { $actions .= "\t\t\t\$this->Session->setFlash(__('Invalid id for {$singularHumanName}', true));\n"; - $actions .= "\t\t\t\$this->redirect(array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->redirect(array('action' => 'index'));\n"; } else { - $actions .= "\t\t\t\$this->flash(__('Invalid {$singularHumanName}', true), array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->flash(__('Invalid {$singularHumanName}', true), array('action' => 'index'));\n"; } $actions .= "\t\t}\n"; $actions .= "\t\tif (\$this->{$currentModelName}->del(\$id)) {\n"; if ($wannaUseSession) { $actions .= "\t\t\t\$this->Session->setFlash(__('{$singularHumanName} deleted', true));\n"; - $actions .= "\t\t\t\$this->redirect(array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->redirect(array('action' => 'index'));\n"; } else { - $actions .= "\t\t\t\$this->flash(__('{$singularHumanName} deleted', true), array('action'=>'index'));\n"; + $actions .= "\t\t\t\$this->flash(__('{$singularHumanName} deleted', true), array('action' => 'index'));\n"; } $actions .= "\t\t}\n"; $actions .= "\t}\n"; From 84a10904fb158a2f5ebbdc8e04ab06ad117138c5 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Fri, 30 Oct 2009 18:42:04 -0200 Subject: [PATCH 33/53] Fixing typo on variable name. --- cake/libs/configure.php | 2 +- cake/libs/view/helpers/cache.php | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 30aeaf56b..05cb2875e 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -254,7 +254,7 @@ class Configure extends Object { * 'key1' => 'value of the Configure::One[key1]', * 'key2' => 'value of the Configure::One[key2]' * ); - * + * * Configure::write(array( * 'One.key1' => 'value of the Configure::One[key1]', * 'One.key2' => 'value of the Configure::One[key2]' diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index afbf0ce57..8f43ecf9e 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -74,15 +74,15 @@ class CacheHelper extends AppHelper { $cacheTime = 0; $useCallbacks = false; if (is_array($this->cacheAction)) { - $contoller = Inflector::underscore($this->controllerName); + $controller = Inflector::underscore($this->controllerName); $check = str_replace('/', '_', $this->here); $replace = str_replace('/', '_', $this->base); $match = str_replace($this->base, '', $this->here); $match = str_replace('//', '/', $match); - $match = str_replace('/' . $contoller . '/', '', $match); + $match = str_replace('/' . $controller . '/', '', $match); $match = str_replace('/' . $this->controllerName . '/', '', $match); $check = str_replace($replace, '', $check); - $check = str_replace('_' . $contoller . '_', '', $check); + $check = str_replace('_' . $controller . '_', '', $check); $check = str_replace('_' . $this->controllerName . '_', '', $check); $check = Inflector::slug($check); $check = preg_replace('/^_+/', '', $check); @@ -171,7 +171,6 @@ class CacheHelper extends AppHelper { $outputResult = array_values($outputResult); } - if (!empty($fileResult)) { $i = 0; foreach ($fileResult as $cacheBlock) { @@ -193,24 +192,23 @@ class CacheHelper extends AppHelper { function __parseOutput($cache) { $count = 0; if (!empty($this->__match)) { - foreach ($this->__match as $found) { $original = $cache; $length = strlen($found); $position = 0; - for ($i = 1; $i <= 1; $i++) { - $position = strpos($cache, $found, $position); + for ($i = 1; $i <= 1; $i++) { + $position = strpos($cache, $found, $position); - if ($position !== false) { - $cache = substr($original, 0, $position); - $cache .= $this->__replace[$count]; - $cache .= substr($original, $position + $length); - } else { - break; - } + if ($position !== false) { + $cache = substr($original, 0, $position); + $cache .= $this->__replace[$count]; + $cache .= substr($original, $position + $length); + } else { + break; } - $count++; + } + $count++; } return $cache; } @@ -291,5 +289,4 @@ class CacheHelper extends AppHelper { return cache('views' . DS . $cache, $file, $timestamp); } } - ?> \ No newline at end of file From a91970b7b221628d7398f19286509222e33df666 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 13:41:16 -0400 Subject: [PATCH 34/53] Fixing security component test failures when run as part of a group. --- cake/tests/cases/libs/controller/components/security.test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index f744f2dce..0aa80c393 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -202,6 +202,7 @@ class SecurityComponentTest extends CakeTestCase { * @return void */ function testRequireSecureFail() { + $_SERVER['HTTPS'] = 'off'; $_SERVER['REQUEST_METHOD'] = 'POST'; $this->Controller->action = 'posted'; $this->Controller->Security->requireSecure('posted'); From 59566d4587fe365c6ddb215c3b06575d5c92de2e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 14:08:56 -0400 Subject: [PATCH 35/53] Updating component test case to no fail in group test. Updating controller group to only run controller classes. --- .../cases/libs/controller/component.test.php | 18 +++++++++++++++--- cake/tests/groups/controller.group.php | 7 +++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index e3f78b28c..8ab7227c2 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -353,6 +353,7 @@ class ComponentTest extends CakeTestCase { function testNestedComponentLoading() { $Controller =& new ComponentTestController(); $Controller->components = array('Apple'); + $Controller->uses = false; $Controller->constructClasses(); $Controller->Component->initialize($Controller); @@ -372,6 +373,7 @@ class ComponentTest extends CakeTestCase { function testComponentStartup() { $Controller =& new ComponentTestController(); $Controller->components = array('Apple'); + $Controller->uses = false; $Controller->constructClasses(); $Controller->Component->initialize($Controller); $Controller->beforeFilter(); @@ -391,6 +393,7 @@ class ComponentTest extends CakeTestCase { */ function testMultipleComponentInitialize() { $Controller =& new ComponentTestController(); + $Controller->uses = false; $Controller->components = array('Orange', 'Banana'); $Controller->constructClasses(); $Controller->Component->initialize($Controller); @@ -411,7 +414,7 @@ class ComponentTest extends CakeTestCase { $Controller =& new ComponentTestController(); $Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple'); - + $Controller->uses = false; $Controller->constructClasses(); $Controller->Component->initialize($Controller); @@ -443,8 +446,12 @@ class ComponentTest extends CakeTestCase { * @return void **/ function testComponentParamsNoDuplication() { + if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { + return; + } $Controller =& new ComponentTestController(); $Controller->components = array('Orange' => array('setting' => array('itemx'))); + $Controller->uses = false; $Controller->constructClasses(); $Controller->Component->initialize($Controller); @@ -459,6 +466,7 @@ class ComponentTest extends CakeTestCase { function testMutuallyReferencingComponents() { $Controller =& new ComponentTestController(); $Controller->components = array('MutuallyReferencingOne'); + $Controller->uses = false; $Controller->constructClasses(); $Controller->Component->initialize($Controller); @@ -483,6 +491,7 @@ class ComponentTest extends CakeTestCase { function testSomethingReferencingEmailComponent() { $Controller =& new ComponentTestController(); $Controller->components = array('SomethingWithEmail'); + $Controller->uses = false; $Controller->constructClasses(); $Controller->Component->initialize($Controller); $Controller->beforeFilter(); @@ -508,14 +517,17 @@ class ComponentTest extends CakeTestCase { * @access public */ function testDoubleLoadingOfSessionComponent() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController'); + if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { + return; + } $Controller =& new ComponentTestController(); - $Controller->uses = array(); + $Controller->uses = false; $Controller->components = array('Session'); $Controller->constructClasses(); $this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange'))); } + } ?> \ No newline at end of file diff --git a/cake/tests/groups/controller.group.php b/cake/tests/groups/controller.group.php index a76073c2a..2a4dcbe80 100644 --- a/cake/tests/groups/controller.group.php +++ b/cake/tests/groups/controller.group.php @@ -37,7 +37,7 @@ class ControllerGroupTest extends GroupTest { * @var string 'All cake/libs/controller/* (Not yet implemented)' * @access public */ - var $label = 'All Controllers and Components'; + var $label = 'Component, Controllers, Scaffold test cases.'; /** * LibControllerGroupTest method * @@ -45,7 +45,10 @@ class ControllerGroupTest extends GroupTest { * @return void */ function ControllerGroupTest() { - TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'controller'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'scaffold'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'pages_controller'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component'); } } ?> From 0637272bd2532f7b37c62764562be871df94d3c0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 14:25:33 -0400 Subject: [PATCH 36/53] Updating doc block on Controller to include more information about $uses. --- cake/libs/controller/controller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 6a582bfce..b1d3c4d72 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -73,6 +73,9 @@ class Controller extends Object { * * Example: var $uses = array('Product', 'Post', 'Comment'); * + * Can be set to array() to use no models. Can be set to false to + * use no models and prevent the merging of $uses with AppController + * * @var mixed A single name as a string or a list of names as an array. * @access protected * @link http://book.cakephp.org/view/53/components-helpers-and-uses From 24a75a27bf2eee0a6a50e2024452e89533c37b65 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 14:25:52 -0400 Subject: [PATCH 37/53] Updating Javacsript helper to use a real skipIf --- cake/tests/cases/libs/view/helpers/javascript.test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/javascript.test.php b/cake/tests/cases/libs/view/helpers/javascript.test.php index fceb01343..e44a0271a 100644 --- a/cake/tests/cases/libs/view/helpers/javascript.test.php +++ b/cake/tests/cases/libs/view/helpers/javascript.test.php @@ -218,8 +218,7 @@ class JavascriptTest extends CakeTestCase { * @return void */ function testFilteringAndTimestamping() { - if (!is_writable(JS)) { - echo "
JavaScript directory not writable, skipping JS asset timestamp tests
"; + if ($this->skipIf(!is_writable(JS), 'JavaScript directory not writable, skipping JS asset timestamp tests. %s')) { return; } From 76019513e1d7723116741ee9b2d10412490cc4b1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 14:33:53 -0400 Subject: [PATCH 38/53] Updating lib group to run non-mvc libs. Removing no_database group. It was redundant. --- cake/tests/groups/lib.group.php | 12 ++++- cake/tests/groups/no_database.group.php | 59 ------------------------- 2 files changed, 10 insertions(+), 61 deletions(-) delete mode 100644 cake/tests/groups/no_database.group.php diff --git a/cake/tests/groups/lib.group.php b/cake/tests/groups/lib.group.php index 07e6ab41b..999ba7da2 100644 --- a/cake/tests/groups/lib.group.php +++ b/cake/tests/groups/lib.group.php @@ -39,7 +39,7 @@ class LibGroupTest extends GroupTest { * @var string 'All cake/libs/* (Not yet implemented)' * @access public */ - var $label = 'All Libs'; + var $label = 'All core, non MVC element libs'; /** * LibGroupTest method * @@ -47,7 +47,15 @@ class LibGroupTest extends GroupTest { * @return void */ function LibGroupTest() { - TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_log'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'overloadable'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'sanitize'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'security'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'set'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'string'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'validation'); } } ?> \ No newline at end of file diff --git a/cake/tests/groups/no_database.group.php b/cake/tests/groups/no_database.group.php deleted file mode 100644 index f23f6be7f..000000000 --- a/cake/tests/groups/no_database.group.php +++ /dev/null @@ -1,59 +0,0 @@ - - * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) - * - * Licensed under The Open Group Test Suite License - * Redistributions of files must retain the above copyright notice. - * - * @filesource - * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) - * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.groups - * @since CakePHP(tm) v 1.2.0.4206 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License - */ -/** - * NoDatabaseGroupTest class - * - * This test group will run all test in the cases/libs directory. - * - * @package cake - * @subpackage cake.tests.groups - */ -class NoDatabaseGroupTest extends GroupTest { -/** - * label property - * - * @var string 'All tests without a database connection' - * @access public - */ - var $label = 'All Libs not requiring a database connection'; -/** - * NoDatabaseGroupTest method - * - * @access public - * @return void - */ - function NoDatabaseGroupTest() { - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'dispatcher'); - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'router'); - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector'); - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'validation'); - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'session'); - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'socket'); - TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view'); - } -} -?> \ No newline at end of file From 6b616b7171cce0eba4fbff88d9934378fe33e543 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 14:48:37 -0400 Subject: [PATCH 39/53] Adding skip for validation test, for DNS servers that reply for non-existant domains. --- cake/tests/cases/libs/validation.test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 98c3e6866..4c7721cbc 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -1584,6 +1584,10 @@ class ValidationTest extends CakeTestCase { * @return void */ function testEmailDeep() { + $found = gethostbynamel('example.abcd'); + if ($this->skipIf($found, 'Your DNS service responds for non-existant domains, skipping deep email checks. %s')) { + return; + } $this->assertTrue(Validation::email('abc.efg@cakephp.org', true)); $this->assertFalse(Validation::email('abc.efg@caphpkeinvalid.com', true)); $this->assertFalse(Validation::email('abc@example.abcd', true)); From 51244907d1e9e754528e3e66a88ac7366024890b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Oct 2009 14:55:04 -0400 Subject: [PATCH 40/53] Updating merge vars test to skip itself if run in a group context. Updating controller group. --- .../cases/libs/controller/controller_merge_vars.test.php | 9 ++++++++- cake/tests/groups/controller.group.php | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/cake/tests/cases/libs/controller/controller_merge_vars.test.php index b405d3eca..4ca4db328 100644 --- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -124,7 +124,14 @@ class MergePostsController extends MergeVarPluginAppController { * @package cake.tests.cases.libs.controller **/ class ControllerMergeVarsTestCase extends CakeTestCase { - +/** + * Skips the case if APP_CONTROLLER_EXISTS is defined + * + * @return void + **/ + function skip() { + $this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'APP_CONTROLLER_EXISTS cannot run. %s'); + } /** * end test * diff --git a/cake/tests/groups/controller.group.php b/cake/tests/groups/controller.group.php index 2a4dcbe80..8bbc801ac 100644 --- a/cake/tests/groups/controller.group.php +++ b/cake/tests/groups/controller.group.php @@ -49,6 +49,7 @@ class ControllerGroupTest extends GroupTest { TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'scaffold'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'pages_controller'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'controller_merge_vars'); } } ?> From 35fa099f6a4c735799bc46207c3181723aa22f95 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 Nov 2009 12:20:37 -0500 Subject: [PATCH 41/53] Updating ajax helper test to reflect changes in FormHelper parameter usage. --- cake/tests/cases/libs/view/helpers/ajax.test.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php index 233d1fa00..12cf40c85 100644 --- a/cake/tests/cases/libs/view/helpers/ajax.test.php +++ b/cake/tests/cases/libs/view/helpers/ajax.test.php @@ -165,6 +165,12 @@ class AjaxHelperTest extends CakeTestCase { $view =& new View(new AjaxTestController()); ClassRegistry::addObject('view', $view); ClassRegistry::addObject('PostAjaxTest', new PostAjaxTest()); + + $this->Ajax->Form->params = array( + 'plugin' => null, + 'action' => 'view', + 'controller' => 'users' + ); } /** * tearDown method From ac97dfd70d1b2b1ac7462a7024915976b43d0c4d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 Nov 2009 12:25:40 -0500 Subject: [PATCH 42/53] Fixing api shell test case. --- cake/tests/cases/console/libs/api.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/console/libs/api.test.php b/cake/tests/cases/console/libs/api.test.php index 2ad67d2a0..dc977006f 100644 --- a/cake/tests/cases/console/libs/api.test.php +++ b/cake/tests/cases/console/libs/api.test.php @@ -95,7 +95,7 @@ class ApiShellTest extends CakeTestCase { '3. beforeRender()', '4. constructClasses()', '5. disableCache()', - '6. flash($message, $url, $pause = 1)', + '6. flash($message, $url, $pause = 1, $layout = \'flash\')', '7. header($status)', '8. isAuthorized()', '9. loadModel($modelClass = null, $id = null)', From d956378d48fe599ea9560917bc15623e9239fe22 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 Nov 2009 12:31:41 -0500 Subject: [PATCH 43/53] Improving console group test suite. Still getting intermittant fails from controller task. --- .../cases/console/libs/tasks/model.test.php | 12 ++++++------ cake/tests/groups/console.group.php | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/cake/tests/cases/console/libs/tasks/model.test.php b/cake/tests/cases/console/libs/tasks/model.test.php index a8cccb151..431fb4130 100644 --- a/cake/tests/cases/console/libs/tasks/model.test.php +++ b/cake/tests/cases/console/libs/tasks/model.test.php @@ -21,7 +21,7 @@ * @since CakePHP v 1.2.6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -App::import('Core', 'Shell'); +App::import('Shell', 'Shell', false); if (!defined('DISABLE_AUTO_DISPATCH')) { define('DISABLE_AUTO_DISPATCH', true); @@ -34,9 +34,9 @@ if (!class_exists('ShellDispatcher')) { ob_end_clean(); } -if (!class_exists('TestTask')) { - require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php'; -} +require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php'; +require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'fixture.php'; +require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php'; Mock::generatePartial( 'ShellDispatcher', 'TestModelTaskMockShellDispatcher', @@ -216,9 +216,9 @@ class ModelTaskTest extends CakeTestCase { function testInteractiveFieldValidation() { $this->Task->initValidations(); $this->Task->interactive = true; - $this->Task->setReturnValueAt(0, 'in', '20'); + $this->Task->setReturnValueAt(0, 'in', '19'); $this->Task->setReturnValueAt(1, 'in', 'y'); - $this->Task->setReturnValueAt(2, 'in', '16'); + $this->Task->setReturnValueAt(2, 'in', '15'); $this->Task->setReturnValueAt(3, 'in', 'n'); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); diff --git a/cake/tests/groups/console.group.php b/cake/tests/groups/console.group.php index 491a7d5fd..3008303e2 100644 --- a/cake/tests/groups/console.group.php +++ b/cake/tests/groups/console.group.php @@ -46,7 +46,24 @@ class ConsoleGroupTest extends TestSuite { * @return void */ function ConsoleGroupTest() { - TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'console'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'cake'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'acl'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'api'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'bake'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'schema'); + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'shell'); + + $path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'tasks' . DS; + + TestManager::addTestFile($this, $path . 'controller'); + TestManager::addTestFile($this, $path . 'model'); + TestManager::addTestFile($this, $path . 'view'); + TestManager::addTestFile($this, $path . 'fixture'); + TestManager::addTestFile($this, $path . 'test'); + TestManager::addTestFile($this, $path . 'db_config'); + TestManager::addTestFile($this, $path . 'plugin'); + TestManager::addTestFile($this, $path . 'project'); + } } ?> \ No newline at end of file From d77761e03b6a213905479d91890cfe4d9b39976d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 Nov 2009 12:31:57 -0500 Subject: [PATCH 44/53] Fixing merged test from 1.2 --- cake/tests/cases/libs/view/helpers/form.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 231fee6f7..ecc84393d 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -2858,7 +2858,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->select( 'Model.contact_id', array('228' => '228 value', '228-1' => '228-1 value', '228-2' => '228-2 value'), - null, array('escape' => false), 'pick something' + null, array('escape' => false, 'empty' => 'pick something') ); $expected = array( From f033516fccdac2750508e76731188afc463a431d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 Nov 2009 12:53:47 -0500 Subject: [PATCH 45/53] Moving inflector test around, fixes group test fails. --- cake/tests/groups/lib.group.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/groups/lib.group.php b/cake/tests/groups/lib.group.php index 1e2fc11b4..4ca7bb73d 100644 --- a/cake/tests/groups/lib.group.php +++ b/cake/tests/groups/lib.group.php @@ -46,9 +46,9 @@ class LibGroupTest extends TestSuite { * @return void */ function LibGroupTest() { + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_log'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry'); - TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'overloadable'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'sanitize'); TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'security'); From b39df8ce2bd5d051758fb783a2dd684f8920c82a Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 Nov 2009 12:58:09 -0500 Subject: [PATCH 46/53] Removing reference to deprecated method. --- cake/tests/cases/libs/code_coverage_manager.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/code_coverage_manager.test.php b/cake/tests/cases/libs/code_coverage_manager.test.php index 97c22a915..74722ab4d 100644 --- a/cake/tests/cases/libs/code_coverage_manager.test.php +++ b/cake/tests/cases/libs/code_coverage_manager.test.php @@ -89,7 +89,7 @@ class CodeCoverageManagerTest extends CakeTestCase { App::import('Core', 'Folder'); $folder = new Folder(); $folder->cd($path); - $contents = $folder->ls(); + $contents = $folder->read(); /** * remove method From df4cd12d0fb7c6c8bdf91408baf30f87b9ded13c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Nov 2009 17:19:02 -0500 Subject: [PATCH 47/53] Fixing RequestHandler test case when app/views/posts/index.ctp is available. --- .../libs/controller/components/request_handler.test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php index cc702d48e..f8a971734 100644 --- a/cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/cake/tests/cases/libs/controller/components/request_handler.test.php @@ -561,7 +561,9 @@ class RequestHandlerComponentTest extends CakeTestCase { function testAjaxRedirectAsRequestAction() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->_init(); - App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS))); + App::build(array( + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) + ), true); $this->Controller->RequestHandler = new NoStopRequestHandler($this); $this->Controller->RequestHandler->expectOnce('_stop'); @@ -574,6 +576,7 @@ class RequestHandlerComponentTest extends CakeTestCase { $this->assertPattern('/posts index/', $result, 'RequestAction redirect failed.'); unset($_SERVER['HTTP_X_REQUESTED_WITH']); + App::build(); } } ?> \ No newline at end of file From 3b3ceddfdb39b07ade8744efd099de34d7b4e346 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Nov 2009 17:39:59 -0500 Subject: [PATCH 48/53] Fixing Email test to account for whitespace changes done on view files. --- .../cases/libs/controller/components/email.test.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index d010c0f08..1560080a1 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -408,8 +408,6 @@ HEADBLOC; This is the body of the message This email was sent using the CakePHP Framework, http://cakephp.org. - - TEXTBLOC; $html = << - EmailTest + Email Test @@ -425,7 +423,6 @@ TEXTBLOC;

This email was sent using the CakePHP Framework

- HTMLBLOC; $this->Controller->EmailTest->sendAs = 'text'; @@ -452,7 +449,7 @@ HTMLBLOC; - EmailTest + Email Test @@ -477,8 +474,6 @@ standards. This is the body of the message This email was sent using the CakePHP Framework, http://cakephp.org. - - TEXTBLOC; $this->Controller->EmailTest->sendAs = 'text'; From 4632402a2538736855ae2929fefad9aa58104ada Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Nov 2009 17:42:42 -0500 Subject: [PATCH 49/53] Fixing controller test to run when app/views/posts/index.ctp is present. --- cake/tests/cases/libs/controller/controller.test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index bd1041da9..4c200d1e9 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -772,7 +772,9 @@ class ControllerTest extends CakeTestCase { * @return void */ function testRender() { - App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS))); + App::build(array( + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) + ), true); $Controller =& new Controller(); $Controller->viewPath = 'posts'; @@ -797,6 +799,7 @@ class ControllerTest extends CakeTestCase { $Controller->ControllerComment->validationErrors = array(); ClassRegistry::flush(); + App::build(); } /** From d17c526dc345c4e6499bc61b56e06590206a9742 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Nov 2009 18:21:01 -0500 Subject: [PATCH 50/53] Fixing String::insert() when $data is an empty array. Which was happening in the dbo source tests. --- cake/libs/string.php | 3 +++ cake/tests/cases/libs/string.test.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/cake/libs/string.php b/cake/libs/string.php index d7bbf2036..15bd9cb6f 100644 --- a/cake/libs/string.php +++ b/cake/libs/string.php @@ -229,6 +229,9 @@ class String { $options += $defaults; $format = $options['format']; $data = (array)$data; + if (empty($data)) { + return ($options['clean']) ? String::cleanInsert($str, $options) : $str; + } if (!isset($format)) { $format = sprintf( diff --git a/cake/tests/cases/libs/string.test.php b/cake/tests/cases/libs/string.test.php index 52ac2867c..e17a5b895 100644 --- a/cake/tests/cases/libs/string.test.php +++ b/cake/tests/cases/libs/string.test.php @@ -71,6 +71,11 @@ class StringTest extends CakeTestCase { * @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')); From 4965ab5bdc43c1fbec974ea8a4b4add1a90bf16c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Nov 2009 19:52:03 -0500 Subject: [PATCH 51/53] Updating version numbers for 1.3.0-alpha --- cake/VERSION.txt | 2 +- cake/config/config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/VERSION.txt b/cake/VERSION.txt index 21634dae2..cf90295bd 100644 --- a/cake/VERSION.txt +++ b/cake/VERSION.txt @@ -17,4 +17,4 @@ // @license MIT License (http://www.opensource.org/licenses/mit-license.php) // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -1.3.0.0 \ No newline at end of file +1.3.0-alpha \ No newline at end of file diff --git a/cake/config/config.php b/cake/config/config.php index 8671c403c..754b623ae 100644 --- a/cake/config/config.php +++ b/cake/config/config.php @@ -19,5 +19,5 @@ * @since CakePHP(tm) v 1.1.11.4062 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -return $config['Cake.version'] = '1.3.0'; +return $config['Cake.version'] = '1.3.0-alpha'; ?> From bc8d920c0f27b60ae7ba5872678d4307aadb7160 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Nov 2009 19:53:59 -0500 Subject: [PATCH 52/53] Updating changelog link on home.ctp --- cake/libs/view/pages/home.ctp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index cdccae6d9..2bdfa48fd 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -27,7 +27,7 @@ if (Configure::read() == 0): endif; ?>

- + 0): Debugger::checkSessionKey(); @@ -139,7 +139,7 @@ You can also add some CSS styles for your pages at: APP/webroot/css.');
  • irc.freenode.net #cakephp
  • -
  • +
  • From a1ce9e662c67b399ae06e5e7fcbe7f1e11b18e5e Mon Sep 17 00:00:00 2001 From: phpnut Date: Tue, 3 Nov 2009 22:02:26 -0600 Subject: [PATCH 53/53] Fixing real issue for Ticket #137 Reverted changes replacing [ and ] with . --- cake/libs/controller/components/cookie.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index 5dbe38e67..085053fe7 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -215,7 +215,7 @@ class CookieComponent extends Object { foreach ($key as $name => $value) { if (strpos($name, '.') === false) { $this->__values[$name] = $value; - $this->__write(".$name", $value); + $this->__write("[$name]", $value); } else { $names = explode('.', $name, 2); @@ -223,7 +223,7 @@ class CookieComponent extends Object { $this->__values[$names[0]] = array(); } $this->__values[$names[0]] = Set::insert($this->__values[$names[0]], $names[1], $value); - $this->__write("." . implode('.', $names), $value); + $this->__write('[' . implode('][', $names) . ']', $value); } } $this->__encrypted = true; @@ -289,12 +289,12 @@ class CookieComponent extends Object { } if (strpos($key, '.') === false) { unset($this->__values[$key]); - $this->__delete(".$key"); + $this->__delete("[$key]"); return; } $names = explode('.', $key, 2); $this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]); - $this->__delete("." . implode('.', $names)); + $this->__delete('[' . implode('][', $names) . ']'); } /** @@ -315,11 +315,11 @@ class CookieComponent extends Object { if (is_array($value)) { foreach ($value as $key => $val) { unset($this->__values[$name][$key]); - $this->__delete(".$name.$key"); + $this->__delete("[$name][$key]"); } } unset($this->__values[$name]); - $this->__delete(".$name"); + $this->__delete("[$name]"); } } @@ -354,6 +354,11 @@ class CookieComponent extends Object { return $this->__expires; } $this->__reset = $this->__expires; + + if ($expires == 0) { + return $this->__expires = 0; + } + if (is_integer($expires) || is_numeric($expires)) { return $this->__expires = $now + intval($expires); }