diff --git a/lib/Cake/Console/cake.php b/lib/Cake/Console/cake.php index d21afb15c..4c8188b2c 100644 --- a/lib/Cake/Console/cake.php +++ b/lib/Cake/Console/cake.php @@ -22,4 +22,3 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php'); return ShellDispatcher::run($argv); - diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 9fefdb540..cca49a5bf 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -172,6 +172,9 @@ class CookieComponent extends Component { public function __construct(ComponentCollection $collection, $settings = array()) { $this->key = Configure::read('Security.salt'); parent::__construct($collection, $settings); + if (isset($this->time)) { + $this->_expire($this->time); + } } /** diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index 59dee3433..735a50d63 100755 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -566,11 +566,7 @@ class EmailComponent extends Component { $headers = array(); if ($this->delivery == 'smtp') { - if (is_array($this->to)) { - $headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); - } else { - $headers['To'] = $this->_formatAddress($this->to); - } + $headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->to)); } $headers['From'] = $this->_formatAddress($this->from); @@ -585,11 +581,11 @@ class EmailComponent extends Component { } if (!empty($this->cc)) { - $headers['cc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->cc)); + $headers['Cc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->cc)); } if (!empty($this->bcc) && $this->delivery != 'smtp') { - $headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->bcc)); + $headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->bcc)); } if ($this->delivery == 'smtp') { $headers['Subject'] = $this->_encode($this->subject); diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 0ee6bcdec..e05e1bcdc 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -319,8 +319,10 @@ class I18n { $this->__domains[$domain][$this->__lang][$this->category] = array(); return $domain; } - - if ($head = $this->__domains[$domain][$this->__lang][$this->category][""]) { + + if (isset($this->__domains[$domain][$this->__lang][$this->category][""])) { + $head = $this->__domains[$domain][$this->__lang][$this->category][""]; + foreach (explode("\n", $head) as $line) { $header = strtok($line,":"); $line = trim(strtok("\n")); diff --git a/lib/Cake/Model/Behavior/AclBehavior.php b/lib/Cake/Model/Behavior/AclBehavior.php index b03586657..c04abca6d 100644 --- a/lib/Cake/Model/Behavior/AclBehavior.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -87,7 +87,7 @@ class AclBehavior extends ModelBehavior { } $data = array( 'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null, - 'model' => $model->alias, + 'model' => $model->name, 'foreign_key' => $model->id ); if (!$created) { diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 3f2f5160c..46df9f8a6 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -845,7 +845,7 @@ class Router { } elseif (isset($url[$prefix]) && !$url[$prefix]) { unset($url[$prefix]); } - if (isset($url[$prefix]) && strpos($url['action'], $prefix) === 0) { + if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) { $url['action'] = substr($url['action'], strlen($prefix) + 1); } } diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index c81f30ac3..156d0be20 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -158,6 +158,9 @@ class CakeTestFixture { * @return boolean True on success, false on failure */ public function drop(&$db) { + if (empty($this->fields)) { + return false; + } $this->Schema->build(array($this->table => $this->fields)); return ( $db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 8a9bc0cc2..448917f22 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -688,7 +688,7 @@ class Helper extends Object { } $habtmKey = $this->field(); - if (empty($result) && isset($data[$habtmKey][$habtmKey])) { + if (empty($result) && isset($data[$habtmKey][$habtmKey]) && is_array($data[$habtmKey])) { $result = $data[$habtmKey][$habtmKey]; } elseif (empty($result) && isset($data[$habtmKey]) && is_array($data[$habtmKey])) { if (ClassRegistry::isKeySet($habtmKey)) { diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 948f4f3b7..ea336fca5 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -240,8 +240,12 @@ class FormHelper extends AppHelper { $options); $this->_inputDefaults = $options['inputDefaults']; unset($options['inputDefaults']); - - if (empty($options['url']) || is_array($options['url'])) { + if ($options['action'] === null && $options['url'] === null) { + $options['action'] = $this->request->here; + if (!isset($options['id'])) { + $options['id'] = $this->domId($this->request['action'] . 'Form'); + } + } elseif (empty($options['url']) || is_array($options['url'])) { if (empty($options['url']['controller'])) { if (!empty($model) && $model != $this->defaultModel) { $options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model)); diff --git a/lib/Cake/View/Helper/JqueryEngineHelper.php b/lib/Cake/View/Helper/JqueryEngineHelper.php index dd4ec62e7..91e22d033 100644 --- a/lib/Cake/View/Helper/JqueryEngineHelper.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -265,7 +265,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { unset($options['update']); } $callbacks = array('success', 'error', 'beforeSend', 'complete'); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $callbacks[] = 'data'; unset($options['dataExpression']); } diff --git a/lib/Cake/View/Helper/MootoolsEngineHelper.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php index f6ba42e87..37c61b6c9 100644 --- a/lib/Cake/View/Helper/MootoolsEngineHelper.php +++ b/lib/Cake/View/Helper/MootoolsEngineHelper.php @@ -252,7 +252,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { } $options['url'] = $url; $options = $this->_prepareCallbacks('request', $options); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $callbacks[] = 'data'; unset($options['dataExpression']); } elseif (!empty($data)) { diff --git a/lib/Cake/View/Helper/NumberHelper.php b/lib/Cake/View/Helper/NumberHelper.php index aaa6d4c65..f2449a4ea 100644 --- a/lib/Cake/View/Helper/NumberHelper.php +++ b/lib/Cake/View/Helper/NumberHelper.php @@ -40,16 +40,16 @@ class NumberHelper extends AppHelper { */ protected $_currencies = array( 'USD' => array( - 'before' => '$', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => ',', - 'decimals' => '.', 'negative' => '()', 'escape' => true + 'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after', + 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true ), 'GBP' => array( - 'before'=>'£', 'after' => 'p', 'zero' => 0, 'places' => 2, 'thousands' => ',', - 'decimals' => '.', 'negative' => '()','escape' => false + 'wholeSymbol'=>'£', 'wholePosition' => 'before', 'fractionSymbol' => 'p', 'fractionPosition' => 'after', + 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()','escape' => false ), 'EUR' => array( - 'before'=>'€', 'after' => false, 'zero' => 0, 'places' => 2, 'thousands' => '.', - 'decimals' => ',', 'negative' => '()', 'escape' => false + 'wholeSymbol'=>'€', 'wholePosition' => 'before', 'fractionSymbol' => false, 'fractionPosition' => 'after', + 'zero' => 0, 'places' => 2, 'thousands' => '.', 'decimals' => ',', 'negative' => '()', 'escape' => false ) ); @@ -60,8 +60,8 @@ class NumberHelper extends AppHelper { * @access protected */ protected $_currencyDefaults = array( - 'before'=>'', 'after' => '', 'zero' => '0', 'places' => 2, 'thousands' => ',', - 'decimals' => '.','negative' => '()', 'escape' => true + 'wholeSymbol'=>'', 'wholePosition' => 'before', 'fractionSymbol' => '', 'fractionPosition' => 'after', + 'zero' => '0', 'places' => 2, 'thousands' => ',', 'decimals' => '.','negative' => '()', 'escape' => true ); /** @@ -192,26 +192,32 @@ class NumberHelper extends AppHelper { $options = array_merge($default, $options); - $result = null; + if (isset($options['before']) && $options['before'] !== '') { + $options['wholeSymbol'] = $options['before']; + } + if (isset($options['after']) && !$options['after'] !== '') { + $options['fractionSymbol'] = $options['after']; + } + $result = $options['before'] = $options['after'] = null; + + $symbolKey = 'whole'; if ($number == 0 ) { if ($options['zero'] !== 0 ) { return $options['zero']; } - $options['after'] = null; } elseif ($number < 1 && $number > -1 ) { - if ($options['after'] !== false) { + if ($options['fractionSymbol'] !== false) { $multiply = intval('1' . str_pad('', $options['places'], '0')); $number = $number * $multiply; - $options['before'] = null; $options['places'] = null; + $symbolKey = 'fraction'; } - } elseif (empty($options['before'])) { - $options['before'] = null; - } else { - $options['after'] = null; } + $position = $options[$symbolKey.'Position'] != 'after' ? 'before' : 'after'; + $options[$position] = $options[$symbolKey.'Symbol']; + $abs = abs($number); $result = $this->format($abs, $options); diff --git a/lib/Cake/View/Helper/PrototypeEngineHelper.php b/lib/Cake/View/Helper/PrototypeEngineHelper.php index 3f198c27f..79c5ac17a 100644 --- a/lib/Cake/View/Helper/PrototypeEngineHelper.php +++ b/lib/Cake/View/Helper/PrototypeEngineHelper.php @@ -45,10 +45,8 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { 'error' => 'onFailure' ), 'sortable' => array( - 'start' => 'onStart', 'sort' => 'onChange', 'complete' => 'onUpdate', - 'distance' => 'snap', ), 'drag' => array( 'snapGrid' => 'snap', @@ -243,7 +241,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { } $safe = array_keys($this->_callbackArguments['request']); $options = $this->_prepareCallbacks('request', $options, $safe); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $safe[] = 'parameters'; unset($options['dataExpression']); } @@ -259,6 +257,9 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { * * #### Note: Requires scriptaculous to be loaded. * + * The scriptaculous implementation of sortables does not suppot the 'start' + * and 'distance' options. + * * @param array $options Array of options for the sortable. * @return string Completed sortable script. * @access public @@ -327,10 +328,14 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { unset($options['handle']); if (isset($options['min']) && isset($options['max'])) { - $options['range'] = array($options['min'], $options['max']); + $options['range'] = sprintf('$R(%s,%s)', $options['min'], $options['max']); unset($options['min'], $options['max']); } - $optionString = $this->_processOptions('slider', $options); + $options = $this->_mapOptions('slider', $options); + $options = $this->_prepareCallbacks('slider', $options); + $optionString = $this->_parseOptions( + $options, array_merge(array_keys($this->_callbackArguments['slider']), array('range')) + ); if (!empty($optionString)) { $optionString = ', {' . $optionString . '}'; } diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index bf8e67235..269c4b9f0 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -103,6 +103,15 @@ class TimeHelper extends AppHelper { return sprintf("%02d", date('Y', $this->__time) / 100); case 'D': return '%m/%d/%y'; + case 'e': + if (DS === '/') { + return '%e'; + } + $day = date('j', $this->__time); + if ($day < 10) { + $day = ' ' . $day; + } + return $day; case 'eS' : return date('jS', $this->__time); case 'b': diff --git a/lib/Cake/View/elements/email/html/default.ctp b/lib/Cake/View/elements/email/html/default.ctp index 3ab3f4cc6..cc94f2746 100644 --- a/lib/Cake/View/elements/email/html/default.ctp +++ b/lib/Cake/View/elements/email/html/default.ctp @@ -20,6 +20,6 @@ $content = explode("\n", $content); foreach ($content as $line): - echo '
' . $line . '
'; + echo '' . $line . "
\n"; endforeach; ?> \ No newline at end of file diff --git a/lib/Cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php index b0bf9e33d..433f3bb5e 100644 --- a/lib/Cake/tests/cases/libs/cache.test.php +++ b/lib/Cake/tests/cases/libs/cache.test.php @@ -401,6 +401,6 @@ class CacheTest extends CakeTestCase { $settings = Cache::settings('file_config'); $this->assertEquals('test_file_', $settings['prefix']); - $this->assertEquals(31536000, $settings['duration']); + $this->assertEquals(strtotime('+1 year') - time(), $settings['duration']); } } diff --git a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php index ee7edbd2d..edfe8e888 100644 --- a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php +++ b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php @@ -389,6 +389,10 @@ class CakeTestFixtureTest extends CakeTestCase { $return = $Fixture->drop($this->criticDb); $this->assertFalse($return); + + unset($Fixture->fields); + $return = $Fixture->drop($this->criticDb); + $this->assertFalse($return); } /** diff --git a/lib/Cake/tests/cases/libs/controller/components/email.test.php b/lib/Cake/tests/cases/libs/controller/components/email.test.php index 344b6de9c..788378467 100755 --- a/lib/Cake/tests/cases/libs/controller/components/email.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/email.test.php @@ -745,6 +745,8 @@ HTMLBLOC; function testSendDebug() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; + $this->Controller->EmailTest->cc = 'cc@example.com'; + $this->Controller->EmailTest->bcc = 'bcc@example.com'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = 'noreply@example.com'; $this->Controller->EmailTest->template = null; @@ -757,6 +759,8 @@ HTMLBLOC; $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); + $this->assertPattern('/Cc: cc@example.com\n/', $result); + $this->assertPattern('/Bcc: bcc@example.com\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); diff --git a/lib/Cake/tests/cases/libs/model/model_validation.test.php b/lib/Cake/tests/cases/libs/model/model_validation.test.php index 0da3c18e9..5e146c9ea 100644 --- a/lib/Cake/tests/cases/libs/model/model_validation.test.php +++ b/lib/Cake/tests/cases/libs/model/model_validation.test.php @@ -129,13 +129,14 @@ class ModelValidationTest extends BaseModelTest { $TestModel = new ValidationTest1(); $TestModel->validate = $validate = array( 'title' => array( - 'rule' => 'customValidator', + 'rule' => 'alphaNumeric', 'required' => true ), 'name' => array( - 'rule' => 'allowEmpty', + 'rule' => 'alphaNumeric', 'required' => true )); + $TestModel->set(array('title' => '$$', 'name' => '##')); $TestModel->invalidFields(array('fieldList' => array('title'))); $expected = array( 'title' => 'This field cannot be left blank' @@ -173,9 +174,9 @@ class ModelValidationTest extends BaseModelTest { */ function testInvalidFieldsWhitelist() { $TestModel = new ValidationTest1(); - $TestModel->validate = $validate = array( + $TestModel->validate = array( 'title' => array( - 'rule' => 'customValidator', + 'rule' => 'alphaNumeric', 'required' => true ), 'name' => array( @@ -184,7 +185,7 @@ class ModelValidationTest extends BaseModelTest { )); $TestModel->whitelist = array('name'); - $TestModel->save(array('name' => '#$$#')); + $TestModel->save(array('name' => '#$$#', 'title' => '$$$$')); $expected = array('name' => 'This field cannot be left blank'); $this->assertEqual($TestModel->validationErrors, $expected); diff --git a/lib/Cake/tests/cases/libs/router.test.php b/lib/Cake/tests/cases/libs/router.test.php index 436d07770..e7f07c69a 100644 --- a/lib/Cake/tests/cases/libs/router.test.php +++ b/lib/Cake/tests/cases/libs/router.test.php @@ -1596,6 +1596,10 @@ class RouterTest extends CakeTestCase { $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; $this->assertEqual($result, $expected); + + $result = Router::url(array('action' => 'protectededit', 1, 'protected' => true)); + $expected = '/protected/images/protectededit/1'; + $this->assertEqual($result, $expected); $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; diff --git a/lib/Cake/tests/cases/libs/view/helpers/form.test.php b/lib/Cake/tests/cases/libs/view/helpers/form.test.php index bfd9a3e8a..c4f4f6dda 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/form.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/form.test.php @@ -674,6 +674,7 @@ class FormHelperTest extends CakeTestCase { $this->Form = new FormHelper($this->View); $this->Form->Html = new HtmlHelper($this->View); $this->Form->request = new CakeRequest(null, false); + $this->Form->request->here = '/contacts/add'; $this->Form->request['action'] = 'add'; $this->Form->request->webroot = ''; $this->Form->request->base = ''; @@ -5553,6 +5554,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request->data['Contact']['id'] = 1; + $this->Form->request->here = '/contacts/edit/1'; $this->Form->request['action'] = 'edit'; $result = $this->Form->create('Contact'); $expected = array( @@ -5567,6 +5569,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request->data['Contact']['id'] = 1; + $this->Form->request->here = '/contacts/edit/1'; $this->Form->request['action'] = 'edit'; $result = $this->Form->create('Contact', array('type' => 'file')); $expected = array( @@ -5581,7 +5584,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request->data['ContactNonStandardPk']['pk'] = 1; - $result = $this->Form->create('ContactNonStandardPk'); + $result = $this->Form->create('ContactNonStandardPk', array('url' => array('action' => 'edit'))); $expected = array( 'form' => array( 'id' => 'ContactNonStandardPkEditForm', 'method' => 'post', @@ -5667,6 +5670,33 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + + $this->Form->request->here = '/contacts/add/Contact:1'; + $result = $this->Form->create(); + $expected = array( + 'form' => array( + 'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/contacts/add/Contact:1', + 'accept-charset' => 'utf-8' + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); + + $this->Form->request['action'] = 'delete'; + $this->Form->request->here = '/contacts/delete/10/User:42'; + $result = $this->Form->create(); + $expected = array( + 'form' => array( + 'id' => 'ContactDeleteForm', 'method' => 'post', 'action' => '/contacts/delete/10/User:42', + 'accept-charset' => 'utf-8' + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); } /** @@ -5860,7 +5890,8 @@ class FormHelperTest extends CakeTestCase { */ function testGetFormWithFalseModel() { $encoding = strtolower(Configure::read('App.encoding')); - $result = $this->Form->create(false, array('type' => 'get')); + $this->Form->request['controller'] = 'contact_test'; + $result = $this->Form->create(false, array('type' => 'get', 'url' => array('controller' => 'contact_test'))); $expected = array('form' => array( 'id' => 'addForm', 'method' => 'get', 'action' => '/contact_test/add', diff --git a/lib/Cake/tests/cases/libs/view/helpers/number.test.php b/lib/Cake/tests/cases/libs/view/helpers/number.test.php index d25e59a21..12b220cc1 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/number.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/number.test.php @@ -115,7 +115,7 @@ class NumberHelperTest extends CakeTestCase { $expected = '£100,100,100.00'; $this->assertEqual($expected, $result); - $result = $this->Number->currency($value, '', array('thousands' =>' ', 'after' => '€', 'decimals' => ',', 'zero' => 'Gratuit')); + $result = $this->Number->currency($value, '', array('thousands' =>' ', 'wholeSymbol' => '€', 'wholePosition' => 'after', 'decimals' => ',', 'zero' => 'Gratuit')); $expected = '100 100 100,00€'; $this->assertEqual($expected, $result); @@ -130,6 +130,42 @@ class NumberHelperTest extends CakeTestCase { $result = $this->Number->currency(0.5, NULL, array('after'=>'øre')); $expected = '50øre'; $this->assertEqual($expected,$result); + + $result = $this->Number->currency(1, null, array('wholeSymbol' => '$ ')); + $expected = '$ 1.00'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(1, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after')); + $expected = '1.00 $'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents')); + $expected = '20cents'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents', 'fractionPosition' => 'before')); + $expected = 'cents20'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(311, 'USD', array('wholePosition' => 'after')); + $expected = '311.00$'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.2, 'EUR'); + $expected = '€0,20'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after')); + $expected = '12.00 dollars'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after')); + $expected = '12 cents'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.5, null, array('fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$')); + $expected = '$0.50'; + $this->assertEqual($result, $expected); } /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php index 49f9c0e4a..90b6462d6 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -276,13 +276,11 @@ class PrototypeEngineHelperTest extends CakeTestCase { function testSortable() { $this->Proto->get('#myList'); $result = $this->Proto->sortable(array( - 'distance' => 5, - 'start' => 'onStart', 'complete' => 'onComplete', 'sort' => 'onSort', 'wrapCallbacks' => false )); - $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onStart:onStart, onUpdate:onComplete, snap:5});'; + $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onUpdate:onComplete});'; $this->assertEqual($result, $expected); } @@ -356,9 +354,11 @@ class PrototypeEngineHelperTest extends CakeTestCase { 'handle' => '#handle', 'change' => 'change();', 'complete' => 'complete();', - 'value' => 4 + 'value' => 4, + 'min' => 10, + 'max' => 100 )); - $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, sliderValue:4});'; + $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});'; $this->assertEqual($result, $expected); } diff --git a/lib/Cake/tests/cases/libs/view/helpers/time.test.php b/lib/Cake/tests/cases/libs/view/helpers/time.test.php index e18e90316..08bacf297 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/time.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/time.test.php @@ -738,6 +738,25 @@ class TimeHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test convert %e on windows. + * + * @return void + */ + function testConvertPercentE() { + if ($this->skipIf(DS !== '\\', 'Cannot run windows tests on non-windows OS')) { + return; + } + $time = strtotime('Thu Jan 14 11:43:39 2010'); + $result = $this->Time->convertSpecifiers('%e', $time); + $expected = '14'; + $this->assertEqual($result, $expected); + + $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); + $expected = ' 1'; + $this->assertEqual($result, $expected); + } + /** * test formatting dates taking in account preferred i18n locale file *