Merge branch '2.0' into 2.1

Conflicts:
	lib/Cake/Test/Case/BasicsTest.php
This commit is contained in:
mark_story 2011-11-19 20:40:07 -05:00
commit 21cd3f00ac
21 changed files with 495 additions and 385 deletions

View file

@ -0,0 +1,40 @@
# $Id$
#
# Copyright 2005-2011, Cake Software Foundation, Inc.
#
# Licensed under The MIT License
# Redistributions of files must retain the above copyright notice.
# MIT License (http://www.opensource.org/licenses/mit-license.php)
CREATE TABLE acos (
id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INTEGER(10) DEFAULT NULL,
model VARCHAR(255) DEFAULT '',
foreign_key INTEGER(10) UNSIGNED DEFAULT NULL,
alias VARCHAR(255) DEFAULT '',
lft INTEGER(10) DEFAULT NULL,
rght INTEGER(10) DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE TABLE aros_acos (
id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
aro_id INTEGER(10) UNSIGNED NOT NULL,
aco_id INTEGER(10) UNSIGNED NOT NULL,
_create CHAR(2) NOT NULL DEFAULT 0,
_read CHAR(2) NOT NULL DEFAULT 0,
_update CHAR(2) NOT NULL DEFAULT 0,
_delete CHAR(2) NOT NULL DEFAULT 0,
PRIMARY KEY(id)
);
CREATE TABLE aros (
id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INTEGER(10) DEFAULT NULL,
model VARCHAR(255) DEFAULT '',
foreign_key INTEGER(10) UNSIGNED DEFAULT NULL,
alias VARCHAR(255) DEFAULT '',
lft INTEGER(10) DEFAULT NULL,
rght INTEGER(10) DEFAULT NULL,
PRIMARY KEY (id)
);

View file

@ -0,0 +1,26 @@
# $Id$
#
# Copyright 2005-2011, Cake Software Foundation, Inc.
#
# Licensed under The MIT License
# Redistributions of files must retain the above copyright notice.
# MIT License (http://www.opensource.org/licenses/mit-license.php)
CREATE TABLE i18n (
id int(10) NOT NULL auto_increment,
locale varchar(6) NOT NULL,
model varchar(255) NOT NULL,
foreign_key int(10) NOT NULL,
field varchar(255) NOT NULL,
content mediumtext,
PRIMARY KEY (id),
# UNIQUE INDEX I18N_LOCALE_FIELD(locale, model, foreign_key, field),
# INDEX I18N_LOCALE_ROW(locale, model, foreign_key),
# INDEX I18N_LOCALE_MODEL(locale, model),
# INDEX I18N_FIELD(model, foreign_key, field),
# INDEX I18N_ROW(model, foreign_key),
INDEX locale (locale),
INDEX model (model),
INDEX row_id (foreign_key),
INDEX field (field)
);

View file

@ -0,0 +1,16 @@
# $Id$
#
# Copyright 2005-2011, Cake Software Foundation, Inc.
# 1785 E. Sahara Avenue, Suite 490-204
# Las Vegas, Nevada 89104
#
# Licensed under The MIT License
# Redistributions of files must retain the above copyright notice.
# MIT License (http://www.opensource.org/licenses/mit-license.php)
CREATE TABLE cake_sessions (
id varchar(255) NOT NULL default '',
data text,
expires int(11) default NULL,
PRIMARY KEY (id)
);

View file

@ -337,8 +337,7 @@ class AuthComponent extends Component {
}
/**
* Attempts to introspect the correct values for object properties including
* $userModel and $sessionKey.
* Attempts to introspect the correct values for object properties.
*
* @return boolean
*/

View file

@ -185,6 +185,8 @@ class ExceptionRenderer {
try {
$this->controller->set($error->getAttributes());
$this->_outputMessage($this->template);
} catch (MissingViewException $e) {
$this->_outputMessage('error500');
} catch (Exception $e) {
$this->_outputMessageSafe('error500');
}

View file

@ -396,6 +396,7 @@ class CakeRoute {
}
$namedConfig = Router::namedConfig();
$prefixes = Router::prefixes();
$greedyNamed = $namedConfig['greedyNamed'];
$allowedNamedParams = $namedConfig['rules'];
@ -429,7 +430,8 @@ class CakeRoute {
// pull out named params if named params are greedy or a rule exists.
if (
($greedyNamed || isset($allowedNamedParams[$key])) &&
($value !== false && $value !== null)
($value !== false && $value !== null) &&
(!in_array($key, $prefixes))
) {
$named[$key] = $value;
continue;

View file

@ -683,61 +683,21 @@ class BasicsTest extends CakeTestCase {
*/
public function testDebug() {
ob_start();
debug('this-is-a-test');
debug('this-is-a-test', false);
$result = ob_get_clean();
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
this-is-a-test
</pre>
</div>
EXPECTED;
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'this-is-a-test'
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>');
$result = ob_get_clean();
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
&#039;&lt;div&gt;this-is-a-test&lt;/div&gt;&#039;
</pre>
</div>
EXPECTED;
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 8);
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', true);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
@ -745,7 +705,7 @@ $expected = <<<EXPECTED
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$this->assertEquals($expected, $result);
ob_start();
@ -788,43 +748,15 @@ $expectedHtml = <<<EXPECTED
</div>
EXPECTED;
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 17);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', null);
$result = ob_get_clean();
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
&#039;&lt;div&gt;this-is-a-test&lt;/div&gt;&#039;
</pre>
</div>
EXPECTED;
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
}
$this->assertEquals($expected, $result);
@ -841,16 +773,14 @@ $expectedHtml = <<<EXPECTED
EXPECTED;
$expectedText = <<<EXPECTED
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 17);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
}
$this->assertEquals($expected, $result);
@ -858,28 +788,24 @@ EXPECTED;
debug('<div>this-is-a-test</div>', false);
$result = ob_get_clean();
$expected = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 8);
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', false, true);
$result = ob_get_clean();
$expected = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 8);
$this->assertEquals($expected, $result);
ob_start();
@ -887,13 +813,11 @@ EXPECTED;
$result = ob_get_clean();
$expected = <<<EXPECTED
########## DEBUG ##########
'<div>this-is-a-test</div>'
###########################
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 8);
$this->assertEquals($expected, $result);
}

View file

@ -553,11 +553,11 @@ class PaginatorComponentTest extends CakeTestCase {
'paramType' => 'named'
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEqual(Set::extract($result, '{n}.PaginatorAuthor.joined_offset'), array(4, 2, 2));
$this->assertEquals(Set::extract($result, '{n}.PaginatorAuthor.joined_offset'), array(4, 2, 2));
$Controller->request->params['named'] = array('sort' => 'PaginatorAuthor.joined_offset', 'direction' => 'asc');
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEqual(Set::extract($result, '{n}.PaginatorAuthor.joined_offset'), array(2, 2, 4));
$this->assertEquals(Set::extract($result, '{n}.PaginatorAuthor.joined_offset'), array(2, 2, 4));
}
/**

View file

@ -64,33 +64,33 @@ class I18nTest extends CakeTestCase {
Cache::config('_cake_core_', Cache::config('default'));
// make some calls to translate using different domains
$this->assertEqual('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
$this->assertEqual('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
$this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
$this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
$domains = I18n::domains();
$this->assertEqual('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
$this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
// reset internally stored entries
I18n::clear();
// now only dom1 should be in cache
$cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
$this->assertEqual('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
$this->assertEqual('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
$this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
$this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
// dom2 not in cache
$this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
// translate a item of dom2 (adds dom2 to cache)
$this->assertEqual('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
$this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
// verify dom2 was cached through manual read from cache
$cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
$this->assertEqual('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
$this->assertEqual('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
$this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
$this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
// modify cache entry manually to verify that dom1 entries now will be read from cache
$cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
$this->assertEqual('FOO', I18n::translate('dom1.foo', false, 'dom1'));
$this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
}
@ -101,7 +101,7 @@ class I18nTest extends CakeTestCase {
*/
public function testDefaultStrings() {
$singular = $this->__singular();
$this->assertEqual('Plural Rule 1', $singular);
$this->assertEquals('Plural Rule 1', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or > 1', $plurals));
@ -132,7 +132,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 = 0 or > 1', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 1 (from core)', $coreSingular);
$this->assertEquals('Plural Rule 1 (from core)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or > 1 (from core)', $corePlurals));
@ -172,7 +172,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_0_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 0 (translated)', $singular);
$this->assertEquals('Plural Rule 0 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 ends with any # (translated)', $plurals));
@ -203,7 +203,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 ends with any # (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 0 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 0 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 ends with any # (from core translated)', $corePlurals));
@ -243,7 +243,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_0_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 0 (translated)', $singular);
$this->assertEquals('Plural Rule 0 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 ends with any # (translated)', $plurals));
@ -274,7 +274,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 ends with any # (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 0 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 0 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 ends with any # (from core translated)', $corePlurals));
@ -314,7 +314,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_1_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 1 (translated)', $singular);
$this->assertEquals('Plural Rule 1 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or > 1 (translated)', $plurals));
@ -345,7 +345,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 = 0 or > 1 (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 1 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 1 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or > 1 (from core translated)', $corePlurals));
@ -385,7 +385,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_1_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 1 (translated)', $singular);
$this->assertEquals('Plural Rule 1 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or > 1 (translated)', $plurals));
@ -416,7 +416,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 = 0 or > 1 (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 1 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 1 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or > 1 (from core translated)', $corePlurals));
@ -456,7 +456,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_2_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 2 (translated)', $singular);
$this->assertEquals('Plural Rule 2 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or 1 (translated)', $plurals));
@ -487,7 +487,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 > 1 (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 2 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 2 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or 1 (from core translated)', $corePlurals));
@ -527,7 +527,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_2_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 2 (translated)', $singular);
$this->assertEquals('Plural Rule 2 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or 1 (translated)', $plurals));
@ -558,7 +558,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 > 1 (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 2 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 2 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or 1 (from core translated)', $corePlurals));
@ -598,7 +598,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_3_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 3 (translated)', $singular);
$this->assertEquals('Plural Rule 3 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 (translated)', $plurals));
@ -629,7 +629,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 3 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 3 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 (from core translated)', $corePlurals));
@ -669,7 +669,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_3_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 3 (translated)', $singular);
$this->assertEquals('Plural Rule 3 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 (translated)', $plurals));
@ -700,7 +700,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 3 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 3 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 (from core translated)', $corePlurals));
@ -740,7 +740,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_4_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 4 (translated)', $singular);
$this->assertEquals('Plural Rule 4 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -771,7 +771,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 4 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 4 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -811,7 +811,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_4_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 4 (translated)', $singular);
$this->assertEquals('Plural Rule 4 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -842,7 +842,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 4 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 4 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -882,7 +882,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_5_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 5 (translated)', $singular);
$this->assertEquals('Plural Rule 5 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or ends in 01-19 (translated)', $plurals));
@ -914,7 +914,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 5 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 5 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or ends in 01-19 (from core translated)', $corePlurals));
@ -955,7 +955,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_5_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 5 (translated)', $singular);
$this->assertEquals('Plural Rule 5 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 = 0 or ends in 01-19 (translated)', $plurals));
@ -987,7 +987,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 5 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 5 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 = 0 or ends in 01-19 (from core translated)', $corePlurals));
@ -1028,7 +1028,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_6_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 6 (translated)', $singular);
$this->assertEquals('Plural Rule 6 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 ends in 0 or ends in 10-20 (translated)', $plurals));
@ -1059,7 +1059,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 6 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 6 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 ends in 0 or ends in 10-20 (from core translated)', $corePlurals));
@ -1099,7 +1099,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_6_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 6 (translated)', $singular);
$this->assertEquals('Plural Rule 6 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 ends in 0 or ends in 10-20 (translated)', $plurals));
@ -1130,7 +1130,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 6 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 6 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 ends in 0 or ends in 10-20 (from core translated)', $corePlurals));
@ -1170,7 +1170,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_7_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 7 (translated)', $singular);
$this->assertEquals('Plural Rule 7 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1201,7 +1201,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 7 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 7 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1241,7 +1241,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_7_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 7 (translated)', $singular);
$this->assertEquals('Plural Rule 7 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1272,7 +1272,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 7 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 7 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1312,7 +1312,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_8_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 8 (translated)', $singular);
$this->assertEquals('Plural Rule 8 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1343,7 +1343,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 8 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 8 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1383,7 +1383,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_8_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 8 (translated)', $singular);
$this->assertEquals('Plural Rule 8 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1414,7 +1414,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 8 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 8 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1454,7 +1454,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_9_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 9 (translated)', $singular);
$this->assertEquals('Plural Rule 9 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1486,7 +1486,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 9 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 9 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1528,7 +1528,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_9_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 9 (translated)', $singular);
$this->assertEquals('Plural Rule 9 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1560,7 +1560,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 9 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 9 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1602,7 +1602,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_10_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 10 (translated)', $singular);
$this->assertEquals('Plural Rule 10 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1634,7 +1634,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 10 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 10 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1675,7 +1675,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_10_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 10 (translated)', $singular);
$this->assertEquals('Plural Rule 10 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1707,7 +1707,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 10 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 10 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1748,7 +1748,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_11_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 11 (translated)', $singular);
$this->assertEquals('Plural Rule 11 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1779,7 +1779,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 11 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 11 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1819,7 +1819,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_11_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 11 (translated)', $singular);
$this->assertEquals('Plural Rule 11 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -1850,7 +1850,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 11 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 11 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -1890,7 +1890,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_12_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 12 (translated)', $singular);
$this->assertEquals('Plural Rule 12 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 is 0 or 3-10 (translated)', $plurals));
@ -1921,7 +1921,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 12 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 12 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 is 0 or 3-10 (from core translated)', $corePlurals));
@ -1961,7 +1961,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_12_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 12 (translated)', $singular);
$this->assertEquals('Plural Rule 12 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 is 0 or 3-10 (translated)', $plurals));
@ -1992,7 +1992,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 12 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 12 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 is 0 or 3-10 (from core translated)', $corePlurals));
@ -2032,7 +2032,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_13_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 13 (translated)', $singular);
$this->assertEquals('Plural Rule 13 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 is 0 or ends in 01-10 (translated)', $plurals));
@ -2063,7 +2063,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 13 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 13 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 is 0 or ends in 01-10 (from core translated)', $corePlurals));
@ -2103,7 +2103,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_13_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 13 (translated)', $singular);
$this->assertEquals('Plural Rule 13 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 is 0 or ends in 01-10 (translated)', $plurals));
@ -2134,7 +2134,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 13 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 13 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 is 0 or ends in 01-10 (from core translated)', $corePlurals));
@ -2174,7 +2174,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_14_po');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 14 (translated)', $singular);
$this->assertEquals('Plural Rule 14 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -2205,7 +2205,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 14 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 14 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -2245,7 +2245,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'rule_14_mo');
$singular = $this->__singular();
$this->assertEqual('Plural Rule 14 (translated)', $singular);
$this->assertEquals('Plural Rule 14 (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (translated)', $plurals));
@ -2276,7 +2276,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('25 everything else (translated)', $plurals));
$coreSingular = $this->__singularFromCore();
$this->assertEqual('Plural Rule 14 (from core translated)', $coreSingular);
$this->assertEquals('Plural Rule 14 (from core translated)', $coreSingular);
$corePlurals = $this->__pluralFromCore();
$this->assertTrue(in_array('0 everything else (from core translated)', $corePlurals));
@ -2315,7 +2315,7 @@ class I18nTest extends CakeTestCase {
public function testSetLanguageWithSession () {
$_SESSION['Config']['language'] = 'po';
$singular = $this->__singular();
$this->assertEqual('Po (translated)', $singular);
$this->assertEquals('Po (translated)', $singular);
$plurals = $this->__plural();
$this->assertTrue(in_array('0 everything else (po translated)', $plurals));
@ -2355,7 +2355,7 @@ class I18nTest extends CakeTestCase {
public function testNoCoreTranslation () {
Configure::write('Config.language', 'po');
$singular = $this->__singular();
$this->assertEqual('Po (translated)', $singular);
$this->assertEquals('Po (translated)', $singular);
$coreSingular = $this->__singularFromCore();
$this->assertNotEquals('Po (from core translated)', $coreSingular);
@ -2401,7 +2401,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'po');
$singular = $this->__domainSingular();
$this->assertEqual('Plural Rule 1 (from plugin)', $singular);
$this->assertEquals('Plural Rule 1 (from plugin)', $singular);
$plurals = $this->__domainPlural();
$this->assertTrue(in_array('0 = 0 or > 1 (from plugin)', $plurals));
@ -2450,7 +2450,7 @@ class I18nTest extends CakeTestCase {
$expected .= "broken up over multiple lines.\n";
$expected .= "This is the third line.\n";
$expected .= "This is the forth line. (translated)";
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
// Windows Newline is \r\n
$string = "This is a multiline translation\r\n";
@ -2458,18 +2458,18 @@ class I18nTest extends CakeTestCase {
$string .= "This is the third line.\r\n";
$string .= "This is the forth line.";
$result = __($string);
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$singular = "valid\nsecond line";
$plural = "valids\nsecond line";
$result = __n($singular, $plural, 1);
$expected = "v\nsecond line";
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __n($singular, $plural, 2);
$expected = "vs\nsecond line";
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$string = "This is a multiline translation\n";
$string .= "broken up over multiple lines.\n";
@ -2481,11 +2481,11 @@ class I18nTest extends CakeTestCase {
$result = __n($singular, $plural, 1);
$expected = "%d is 1\n" . $string;
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __n($singular, $plural, 2);
$expected = "%d is 2-4\n" . $string;
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
// Windows Newline is \r\n
$string = "This is a multiline translation\r\n";
@ -2498,11 +2498,11 @@ class I18nTest extends CakeTestCase {
$result = __n($singular, $plural, 1);
$expected = "%d is 1\n" . str_replace("\r\n", "\n", $string);
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __n($singular, $plural, 2);
$expected = "%d is 2-4\n" . str_replace("\r\n", "\n", $string);
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
}
/**
@ -2513,7 +2513,7 @@ class I18nTest extends CakeTestCase {
public function testPoNoTranslationNeeded () {
Configure::write('Config.language', 'po');
$result = __('No Translation needed');
$this->assertEqual('No Translation needed', $result);
$this->assertEquals('No Translation needed', $result);
}
/**
@ -2523,7 +2523,7 @@ class I18nTest extends CakeTestCase {
*/
public function testPoQuotedString () {
$expected = 'this is a "quoted string" (translated)';
$this->assertEqual($expected, __('this is a "quoted string"'));
$this->assertEquals($expected, __('this is a "quoted string"'));
}
/**
@ -2536,15 +2536,15 @@ class I18nTest extends CakeTestCase {
$result = __n('%d = 1', '%d = 0 or > 1', (float)1);
$expected = '%d is 1 (translated)';
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __n('%d = 1', '%d = 0 or > 1', (float)2);
$expected = "%d ends in 2-4, not 12-14 (translated)";
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __n('%d = 1', '%d = 0 or > 1', (float)5);
$expected = "%d everything else (translated)";
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
}
/**
@ -2555,7 +2555,7 @@ class I18nTest extends CakeTestCase {
public function testCategory() {
Configure::write('Config.language', 'po');
$category = $this->__category();
$this->assertEqual('Monetary Po (translated)', $category);
$this->assertEquals('Monetary Po (translated)', $category);
}
/**
@ -2567,7 +2567,7 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'po');
$singular = $this->__domainCategorySingular();
$this->assertEqual('Monetary Plural Rule 1 (from plugin)', $singular);
$this->assertEquals('Monetary Plural Rule 1 (from plugin)', $singular);
$plurals = $this->__domainCategoryPlural();
$this->assertTrue(in_array('Monetary 0 = 0 or > 1 (from plugin)', $plurals));
@ -2582,25 +2582,25 @@ class I18nTest extends CakeTestCase {
public function testCategoryThenSingular() {
Configure::write('Config.language', 'po');
$category = $this->__category();
$this->assertEqual('Monetary Po (translated)', $category);
$this->assertEquals('Monetary Po (translated)', $category);
$singular = $this->__singular();
$this->assertEqual('Po (translated)', $singular);
$this->assertEquals('Po (translated)', $singular);
}
public function testTimeDefinition() {
Configure::write('Config.language', 'po');
$result = __c('d_fmt', 5);
$expected = '%m/%d/%Y';
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __c('am_pm', 5);
$expected = array('AM', 'PM');
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __c('abmon', 5);
$expected = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
}
public function testTimeDefinitionJapanese(){
@ -2609,15 +2609,15 @@ class I18nTest extends CakeTestCase {
$expected = "%Y年%m月%d日";
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __c('am_pm', 5);
$expected = array("午前", "午後");
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
$result = __c('abmon', 5);
$expected = array(" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月");
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
}
/**

File diff suppressed because it is too large Load diff

View file

@ -7560,7 +7560,7 @@ class ModelReadTest extends BaseModelTest {
'2' => 'Second Post',
'1' => 'First Post'
);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
$result = $Post->find('list', array('order' => array('Post.other_field' => 'DESC')));
$expected = array(
@ -7568,23 +7568,23 @@ class ModelReadTest extends BaseModelTest {
'2' => 'Second Post',
'3' => 'Third Post'
);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
$Post->Author->virtualFields = array('joined' => 'Post.id * Author.id');
$result = $Post->find('all');
$result = Set::extract('{n}.Author.joined', $result);
$expected = array(1, 6, 3);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
$result = $Post->find('all', array('order' => array('Author.joined' => 'ASC')));
$result = Set::extract('{n}.Author.joined', $result);
$expected = array(1, 3, 6);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
$result = $Post->find('all', array('order' => array('Author.joined' => 'DESC')));
$result = Set::extract('{n}.Author.joined', $result);
$expected = array(6, 3, 1);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
}
/**

View file

@ -3550,7 +3550,6 @@ class ModelWriteTest extends BaseModelTest {
'title' => '',
'body' => 'Trying to get away with an empty title'
));
$newTs = date('Y-m-d H:i:s');
$result = $TestModel->saveAll($data, array('validate' => true, 'atomic' => false));
$this->assertEquals($result, array(true, false));
$result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC'));
@ -3598,10 +3597,10 @@ class ModelWriteTest extends BaseModelTest {
)
);
$this->assertTrue($result[0]['Post']['updated'] >= $newTs);
$this->assertTrue($result[1]['Post']['updated'] >= $newTs);
$this->assertTrue($result[3]['Post']['updated'] >= $newTs);
$this->assertTrue($result[3]['Post']['created'] >= $newTs);
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
$this->assertTrue($result[3]['Post']['created'] >= $ts);
unset(
$result[0]['Post']['updated'], $result[1]['Post']['updated'],
$result[3]['Post']['updated'], $result[3]['Post']['created']

View file

@ -606,7 +606,7 @@ class CakeRouteTest extends CakeTestCase {
'fish' => 'trout'
)
);
$this->assertEquals($expected, $result, 'Fish should be parsed, as action == index');
$this->assertEquals($expected, $result, 'Fizz should be parsed, as controller == comments|other');
$result = $route->parse('/comments/index/wibble:spin/fish:trout/fizz:buzz');
$expected = array(
@ -665,6 +665,19 @@ class CakeRouteTest extends CakeTestCase {
$this->assertEquals($expected, $result, 'Greedy named grabs everything, rules are followed');
}
/**
* Having greedNamed enabled should not capture routing.prefixes.
*
* @return void
*/
public function testMatchGreedyNamedExcludesPrefixes() {
Configure::write('Routing.prefixes', array('admin'));
Router::reload();
$route = new CakeRoute('/sales/*', array('controller' => 'sales', 'action' => 'index'));
$this->assertFalse($route->match(array('controller' => 'sales', 'action' => 'index', 'admin' => 1)), 'Greedy named consume routing prefixes.');
}
/**
* test that parsing array format named parameters works
*

View file

@ -960,6 +960,21 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
}
/**
* Test that buttons created with foo[bar] name attributes are unlocked correctly.
*
* @return void
*/
public function testSecurityButtonNestedNamed() {
$key = 'testKey';
$this->Form->request['_Token'] = array('key' => $key);
$this->Form->create('Addresses');
$this->Form->button('Test', array('type' => 'submit', 'name' => 'Address[button]'));
$result = $this->Form->unlockField();
$this->assertEquals(array('Address.button'), $result);
}
/**
* Test that the correct fields are unlocked for image submits with no names.
*

View file

@ -751,6 +751,7 @@ class TimeHelperTest extends CakeTestCase {
'locales' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS)
), true);
Configure::write('Config.language', 'time_test');
$time = strtotime('Thu Jan 14 13:59:28 2010');
$result = $this->Time->i18nFormat($time);
@ -765,6 +766,20 @@ class TimeHelperTest extends CakeTestCase {
$expected = 'Time is 01:59:28 PM, and date is 14/01/10';
$this->assertEquals($expected, $result);
$time = strtotime('Wed Jan 13 13:59:28 2010');
$result = $this->Time->i18nFormat($time);
$expected = '13/01/10';
$this->assertEquals($expected, $result);
$result = $this->Time->i18nFormat($time, '%c');
$expected = 'mié 13 ene 2010 13:59:28 ' . strftime('%Z', $time);
$this->assertEquals($expected, $result);
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
$expected = 'Time is 01:59:28 PM, and date is 13/01/10';
$this->assertEquals($expected, $result);
$result = $this->Time->i18nFormat('invalid date', '%x', 'Date invalid');
$expected = 'Date invalid';
$this->assertEquals($expected, $result);

View file

@ -34,6 +34,7 @@ class File {
* Folder object of the File
*
* @var Folder
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$Folder
*/
public $Folder = null;
@ -41,13 +42,15 @@ class File {
* Filename
*
* @var string
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$name
*/
public $name = null;
/**
* File info
*
* @var string
* @var array
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$info
*/
public $info = array();
@ -55,6 +58,7 @@ class File {
* Holds the file handler resource if the file is opened
*
* @var resource
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$handle
*/
public $handle = null;
@ -62,6 +66,7 @@ class File {
* Enable locking for file reading and writing
*
* @var boolean
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$lock
*/
public $lock = null;
@ -71,6 +76,7 @@ class File {
* Current file's absolute path
*
* @var mixed null
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$path
*/
public $path = null;

View file

@ -29,6 +29,7 @@ class Folder {
* Path to Folder.
*
* @var string
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$path
*/
public $path = null;
@ -37,6 +38,7 @@ class Folder {
* should be sorted by name.
*
* @var boolean
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$sort
*/
public $sort = false;
@ -44,6 +46,7 @@ class Folder {
* Mode to be used on create. Does nothing on windows platforms.
*
* @var integer
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$mode
*/
public $mode = 0755;

View file

@ -37,6 +37,7 @@ class Set {
* @param array $arr1 Array to be merged
* @param array $arr2 Array to merge with
* @return array Merged array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::merge
*/
public static function merge($arr1, $arr2 = null) {
$args = func_get_args();
@ -61,6 +62,7 @@ class Set {
*
* @param array $var Either an array to filter, or value when in callback
* @return mixed Either filtered array, or true/false when in callback
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::filter
*/
public static function filter(array $var) {
foreach ($var as $k => $v) {
@ -90,6 +92,7 @@ class Set {
* @param mixed $array Original array
* @param mixed $array2 Differences to push
* @return array Combined array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::pushDiff
*/
public static function pushDiff($array, $array2) {
if (empty($array) && !empty($array2)) {
@ -116,6 +119,7 @@ class Set {
* @param string $class A class name of the type of object to map to
* @param string $tmp A temporary class name used as $class if $class is an array
* @return object Hierarchical object
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::map
*/
public static function map($class = 'stdClass', $tmp = 'stdClass') {
if (is_array($class)) {
@ -202,6 +206,7 @@ class Set {
*
* @param array $array The array to check. If null, the value of the current Set object
* @return boolean true if values are numeric, false otherwise
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::numeric
*/
public static function numeric($array = null) {
if (empty($array)) {
@ -238,6 +243,7 @@ class Set {
* @param mixed $select Key in $list to return
* @param mixed $list can be an array or a comma-separated list.
* @return string the value of the array key or null if no match
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::enum
*/
public static function enum($select, $list = null) {
if (empty($list)) {
@ -260,6 +266,7 @@ class Set {
* @param string $format Format string into which values will be inserted, see sprintf()
* @param array $keys An array containing one or more Set::extract()-style key paths
* @return array An array of strings extracted from $keys and formatted with $format
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::format
*/
public static function format($data, $format, $keys) {
$extracted = array();
@ -338,6 +345,7 @@ class Set {
* @param array $data An array of data to extract from
* @param array $options Currently only supports 'flatten' which can be disabled for higher XPath-ness
* @return array An array of matched items
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::extract
*/
public static function extract($path, $data = null, $options = array()) {
if (is_string($data)) {
@ -488,6 +496,7 @@ class Set {
* @param integer $i Optional: The 'nth'-number of the item being matched.
* @param integer $length
* @return boolean
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::matches
*/
public static function matches($conditions, $data = array(), $i = null, $length = null) {
if (empty($conditions)) {
@ -561,6 +570,7 @@ class Set {
* @param array $data Array from where to extract
* @param mixed $path As an array, or as a dot-separated string.
* @return array Extracted data
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::classicExtract
*/
public static function classicExtract($data, $path = null) {
if (empty($path)) {
@ -648,6 +658,7 @@ class Set {
* @param mixed $path A dot-separated string.
* @param array $data Data to insert
* @return array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::insert
*/
public static function insert($list, $path, $data = null) {
if (!is_array($path)) {
@ -678,6 +689,7 @@ class Set {
* @param mixed $list From where to remove
* @param mixed $path A dot-separated string.
* @return array Array with $path removed from its value
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::remove
*/
public static function remove($list, $path = null) {
if (empty($path)) {
@ -710,6 +722,7 @@ class Set {
* @param mixed $data Data to check on
* @param mixed $path A dot-separated string.
* @return boolean true if path is found, false otherwise
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::check
*/
public static function check($data, $path = null) {
if (empty($path)) {
@ -742,6 +755,7 @@ class Set {
* @param mixed $val2 Second value
* @return array Returns the key => value pairs that are not common in $val1 and $val2
* The expression for this function is ($val1 - $val2) + ($val2 - ($val1 - $val2))
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::diff
*/
public static function diff($val1, $val2 = null) {
if (empty($val1)) {
@ -768,6 +782,7 @@ class Set {
* @param array $val1 First value
* @param array $val2 Second value
* @return boolean true if $val1 contains $val2, false otherwise
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::contains
*/
public static function contains($val1, $val2 = null) {
if (empty($val1) || empty($val2)) {
@ -794,6 +809,7 @@ class Set {
* @param boolean $all Set to true to count the dimension considering all elements in array
* @param integer $count Start the dimension count at this number
* @return integer The number of dimensions in $array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::countDim
*/
public static function countDim($array = null, $all = false, $count = 0) {
if ($all) {
@ -822,6 +838,7 @@ class Set {
* @param string $sep If $list is a string, it will be split into an array with $sep
* @param boolean $trim If true, separated strings will be trimmed
* @return array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::normalize
*/
public static function normalize($list, $assoc = true, $sep = ',', $trim = true) {
if (is_string($list)) {
@ -873,6 +890,7 @@ class Set {
* @param mixed $path2 As an array, or as a dot-separated string.
* @param string $groupPath As an array, or as a dot-separated string.
* @return array Combined array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::combine
*/
public static function combine($data, $path1 = null, $path2 = null, $groupPath = null) {
if (empty($data)) {
@ -933,6 +951,7 @@ class Set {
* Converts an object into an array.
* @param object $object Object to reverse
* @return array Array representation of given object
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::reverse
*/
public static function reverse($object) {
$out = array();
@ -979,6 +998,7 @@ class Set {
* @param array $data Array to flatten
* @param string $separator String used to separate array key elements in a path, defaults to '.'
* @return array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::flatten
*/
public static function flatten($data, $separator = '.') {
$result = array();
@ -1035,6 +1055,7 @@ class Set {
* @param string $path A Set-compatible path to the array value
* @param string $dir Direction of sorting - either ascending (ASC), or descending (DESC)
* @return array Sorted array of data
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::sort
*/
public static function sort($data, $path, $dir) {
$originalKeys = array_keys($data);
@ -1074,6 +1095,7 @@ class Set {
* to array_map, reduce will handoff to array_reduce, and pass will
* use call_user_func_array().
* @return mixed Result of the callback when applied to extracted data
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::apply
*/
public static function apply($path, $data, $callback, $options = array()) {
$defaults = array('type' => 'pass');

View file

@ -591,7 +591,7 @@ class FormHelper extends AppHelper {
*
* @param boolean $lock Whether this field should be part of the validation
* or excluded as part of the unlockedFields.
* @param mixed $field Reference to field to be secured
* @param mixed $field Reference to field to be secured. Should be dot separted to indicate nesting.
* @param mixed $value Field value, if value should not be tampered with.
* @return void
*/
@ -1466,7 +1466,8 @@ class FormHelper extends AppHelper {
$title = h($title);
}
if (isset($options['name'])) {
$this->_secure($options['secure'], $options['name']);
$name = str_replace(array('[', ']'), array('.', ''), $options['name']);
$this->_secure($options['secure'], $name);
}
return $this->Html->useTag('button', $options['type'], array_diff_key($options, array('type' => '')), $title);
}

View file

@ -16,6 +16,9 @@
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!class_exists('Multibyte')) {
App::import('Core', 'Multibyte');
}
App::uses('AppHelper', 'View/Helper');
@ -241,7 +244,7 @@ class TimeHelper extends AppHelper {
$format = $this->niceFormat;
}
$format = $this->convertSpecifiers($format, $date);
return strftime($format, $date);
return $this->_strftime($format, $date);
}
/**
@ -263,12 +266,12 @@ class TimeHelper extends AppHelper {
$y = $this->isThisYear($date) ? '' : ' %Y';
if ($this->isToday($dateString, $userOffset)) {
$ret = __d('cake', 'Today, %s', strftime("%H:%M", $date));
$ret = __d('cake', 'Today, %s', $this->_strftime("%H:%M", $date));
} elseif ($this->wasYesterday($dateString, $userOffset)) {
$ret = __d('cake', 'Yesterday, %s', strftime("%H:%M", $date));
$ret = __d('cake', 'Yesterday, %s', $this->_strftime("%H:%M", $date));
} else {
$format = $this->convertSpecifiers("%b %eS{$y}, %H:%M", $date);
$ret = strftime($format, $date);
$ret = $this->_strftime($format, $date);
}
return $ret;
@ -748,6 +751,32 @@ class TimeHelper extends AppHelper {
$format = '%x';
}
$format = $this->convertSpecifiers($format, $date);
return strftime($format, $date);
return $this->_strftime($format, $date);
}
/**
* Multibyte wrapper for strftime.
*
* Handles utf8_encoding the result of strftime when necessary.
*
* @param string $format Format string.
* @param int $date Timestamp to format.
* @return string formatted string with correct encoding.
*/
protected function _strftime($format, $date) {
$format = strftime($format, $date);
$encoding = Configure::read('App.encoding');
if (!empty($encoding) && $encoding === 'UTF-8') {
if (function_exists('mb_check_encoding')) {
$valid = mb_check_encoding($format, $encoding);
} else {
$valid = !Multibyte::checkMultibyte($format);
}
if (!$valid) {
$format = utf8_encode($format);
}
}
return $format;
}
}

View file

@ -92,12 +92,10 @@ function debug($var = false, $showHtml = null, $showFrom = true) {
</div>
HTML;
$text = <<<TEXT
%s
########## DEBUG ##########
%s
###########################
TEXT;
$template = $html;
if (php_sapi_name() == 'cli' || $showHtml === false) {