mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
This commit is contained in:
commit
42b3f993b9
24 changed files with 179 additions and 53 deletions
|
@ -22,4 +22,3 @@
|
|||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php');
|
||||
|
||||
return ShellDispatcher::run($argv);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 . '}';
|
||||
}
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
$content = explode("\n", $content);
|
||||
|
||||
foreach ($content as $line):
|
||||
echo '<p> ' . $line . '</p>';
|
||||
echo '<p> ' . $line . "</p>\n";
|
||||
endforeach;
|
||||
?>
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue