Merge branch '2.1' into 2.2

Conflicts:
	lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
This commit is contained in:
mark_story 2012-04-09 21:55:02 -04:00
commit f8966a64f2
12 changed files with 319 additions and 275 deletions

View file

@ -58,7 +58,7 @@ class EmailConfig {
'username' => 'user', 'username' => 'user',
'password' => 'secret', 'password' => 'secret',
'client' => null, 'client' => null,
'log' => false 'log' => false,
//'charset' => 'utf-8', //'charset' => 'utf-8',
//'headerCharset' => 'utf-8', //'headerCharset' => 'utf-8',
); );

View file

@ -88,7 +88,8 @@ class L10n {
* *
* @var array * @var array
*/ */
protected $_l10nMap = array(/* Afrikaans */ 'afr' => 'af', protected $_l10nMap = array(
/* Afrikaans */ 'afr' => 'af',
/* Albanian */ 'alb' => 'sq', /* Albanian */ 'alb' => 'sq',
/* Arabic */ 'ara' => 'ar', /* Arabic */ 'ara' => 'ar',
/* Armenian - Armenia */ 'hye' => 'hy', /* Armenian - Armenia */ 'hye' => 'hy',
@ -166,7 +167,8 @@ class L10n {
/* Welsh */ 'cym' => 'cy', /* Welsh */ 'cym' => 'cy',
/* Xhosa */ 'xho' => 'xh', /* Xhosa */ 'xho' => 'xh',
/* Yiddish */ 'yid' => 'yi', /* Yiddish */ 'yid' => 'yi',
/* Zulu */ 'zul' => 'zu'); /* Zulu */ 'zul' => 'zu'
);
/** /**
* HTTP_ACCEPT_LANGUAGE catalog * HTTP_ACCEPT_LANGUAGE catalog
@ -175,7 +177,8 @@ class L10n {
* *
* @var array * @var array
*/ */
protected $_l10nCatalog = array('af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'), protected $_l10nCatalog = array(
'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'),
'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
@ -317,7 +320,8 @@ class L10n {
'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),
'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),
'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),
'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr')); 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr')
);
/** /**
* Class constructor * Class constructor
@ -339,9 +343,12 @@ class L10n {
public function get($language = null) { public function get($language = null) {
if ($language !== null) { if ($language !== null) {
return $this->_setLanguage($language); return $this->_setLanguage($language);
} elseif ($this->_autoLanguage() === false) {
return $this->_setLanguage();
} }
if (!$this->_autoLanguage()) {
$this->_setLanguage();
}
return $this->lang;
} }
/** /**

View file

@ -137,7 +137,7 @@ class DboSource extends DataSource {
/** /**
* Caches serialized results of executed queries * Caches serialized results of executed queries
* *
* @var array Maximum number of queries in the queries log. * @var array Cache of results from executed sql queries.
*/ */
protected $_queryCache = array(); protected $_queryCache = array();

View file

@ -54,14 +54,16 @@ class ShellTestShell extends Shell {
$this->stopped = $status; $this->stopped = $status;
} }
public function do_something() { protected function _secret() {
} }
protected function _secret() { //@codingStandardsIgnoreStart
public function do_something() {
} }
protected function no_access() { protected function no_access() {
} }
//@codingStandardsIgnoreEnd
public function mergeVars($properties, $class, $normalize = true) { public function mergeVars($properties, $class, $normalize = true) {
return $this->_mergeVars($properties, $class, $normalize); return $this->_mergeVars($properties, $class, $normalize);

View file

@ -289,6 +289,7 @@ class TestController extends ControllerTestAppController {
return 'I am from the controller.'; return 'I am from the controller.';
} }
//@codingStandardsIgnoreStart
protected function protected_m() { protected function protected_m() {
} }
@ -297,6 +298,7 @@ class TestController extends ControllerTestAppController {
public function _hidden() { public function _hidden() {
} }
//@codingStandardsIgnoreEnd
public function admin_add() { public function admin_add() {
} }

View file

@ -34,8 +34,9 @@ class L10nTest extends CakeTestCase {
$localize = new L10n(); $localize = new L10n();
// Catalog Entry // Catalog Entry
$localize->get('en'); $lang = $localize->get('en');
$this->assertEquals('en', $lang);
$this->assertEquals('English', $localize->language); $this->assertEquals('English', $localize->language);
$this->assertEquals(array('eng', 'eng'), $localize->languagePath); $this->assertEquals(array('eng', 'eng'), $localize->languagePath);
$this->assertEquals('eng', $localize->locale); $this->assertEquals('eng', $localize->locale);
@ -57,8 +58,9 @@ class L10nTest extends CakeTestCase {
// Default Entry // Default Entry
define('DEFAULT_LANGUAGE', 'en-us'); define('DEFAULT_LANGUAGE', 'en-us');
$localize->get('use_default'); $lang = $localize->get('use_default');
$this->assertEquals('en-us', $lang);
$this->assertEquals('English (United States)', $localize->language); $this->assertEquals('English (United States)', $localize->language);
$this->assertEquals(array('en_us', 'eng'), $localize->languagePath); $this->assertEquals(array('en_us', 'eng'), $localize->languagePath);
$this->assertEquals('en_us', $localize->locale); $this->assertEquals('en_us', $localize->locale);
@ -86,15 +88,17 @@ class L10nTest extends CakeTestCase {
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'inexistent,en-ca'; $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'inexistent,en-ca';
$localize = new L10n(); $localize = new L10n();
$localize->get(); $lang = $localize->get();
$this->assertEquals('en-ca', $lang);
$this->assertEquals('English (Canadian)', $localize->language); $this->assertEquals('English (Canadian)', $localize->language);
$this->assertEquals(array('en_ca', 'eng', 'eng'), $localize->languagePath); $this->assertEquals(array('en_ca', 'eng', 'eng'), $localize->languagePath);
$this->assertEquals('en_ca', $localize->locale); $this->assertEquals('en_ca', $localize->locale);
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx'; $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx';
$localize->get(); $lang = $localize->get();
$this->assertEquals('es-mx', $lang);
$this->assertEquals('Spanish (Mexican)', $localize->language); $this->assertEquals('Spanish (Mexican)', $localize->language);
$this->assertEquals(array('es_mx', 'spa', 'eng'), $localize->languagePath); $this->assertEquals(array('es_mx', 'spa', 'eng'), $localize->languagePath);
$this->assertEquals('es_mx', $localize->locale); $this->assertEquals('es_mx', $localize->locale);

View file

@ -1241,7 +1241,7 @@ class CakeEmailTest extends CakeTestCase {
$this->assertContains('Content-Type: text/html; charset=utf-8', $message); $this->assertContains('Content-Type: text/html; charset=utf-8', $message);
// UTF-8 is 8bit // UTF-8 is 8bit
$this->assertTrue($this->checkContentTransferEncoding($message, '8bit')); $this->assertTrue($this->_checkContentTransferEncoding($message, '8bit'));
$this->CakeEmail->charset = 'ISO-2022-JP'; $this->CakeEmail->charset = 'ISO-2022-JP';
$this->CakeEmail->send(); $this->CakeEmail->send();
@ -1250,7 +1250,7 @@ class CakeEmailTest extends CakeTestCase {
$this->assertContains('Content-Type: text/html; charset=ISO-2022-JP', $message); $this->assertContains('Content-Type: text/html; charset=ISO-2022-JP', $message);
// ISO-2022-JP is 7bit // ISO-2022-JP is 7bit
$this->assertTrue($this->checkContentTransferEncoding($message, '7bit')); $this->assertTrue($this->_checkContentTransferEncoding($message, '7bit'));
} }
/** /**
@ -1511,7 +1511,7 @@ class CakeEmailTest extends CakeTestCase {
$this->assertContains(mb_convert_encoding('ってテーブルを作ってやってたらう','ISO-2022-JP'), $result['message']); $this->assertContains(mb_convert_encoding('ってテーブルを作ってやってたらう','ISO-2022-JP'), $result['message']);
} }
public function checkContentTransferEncoding($message, $charset) { protected function _checkContentTransferEncoding($message, $charset) {
$boundary = '--alt-' . $this->CakeEmail->getBoundary(); $boundary = '--alt-' . $this->CakeEmail->getBoundary();
$result['text'] = false; $result['text'] = false;
$result['html'] = false; $result['html'] = false;
@ -1541,6 +1541,7 @@ class CakeEmailTest extends CakeTestCase {
/** /**
* Test CakeEmail::_encode function * Test CakeEmail::_encode function
* *
* @return void
*/ */
public function testEncode() { public function testEncode() {
$this->skipIf(!function_exists('mb_convert_encoding')); $this->skipIf(!function_exists('mb_convert_encoding'));

View file

@ -355,6 +355,9 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->image('/test/view/1.gif'); $result = $this->Html->image('/test/view/1.gif');
$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => ''))); $this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => '')));
$result = $this->Html->image('test.gif?one=two&three=four');
$this->assertTags($result, array('img' => array('src' => 'img/test.gif?one=two&three=four', 'alt' => '')));
$result = $this->Html->image('test.gif', array('fullBase' => true)); $result = $this->Html->image('test.gif', array('fullBase' => true));
$here = $this->Html->url('/', true); $here = $this->Html->url('/', true);
$this->assertTags($result, array('img' => array('src' => $here . 'img/test.gif', 'alt' => ''))); $this->assertTags($result, array('img' => array('src' => $here . 'img/test.gif', 'alt' => '')));
@ -515,6 +518,10 @@ class HtmlHelperTest extends CakeTestCase {
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/'; $expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Html->css('screen.css?with=param&other=param');
$expected['link']['href'] = 'css/screen.css?with=param&other=param';
$this->assertTags($result, $expected);
$result = $this->Html->css('http://whatever.com/screen.css?1234'); $result = $this->Html->css('http://whatever.com/screen.css?1234');
$expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/'; $expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/';
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
@ -787,6 +794,12 @@ class HtmlHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Html->script('test.json.js?foo=bar&other=test');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js?foo=bar&other=test')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('foo'); $result = $this->Html->script('foo');
$this->assertNull($result, 'Script returned upon duplicate inclusion %s'); $this->assertNull($result, 'Script returned upon duplicate inclusion %s');

View file

@ -193,6 +193,8 @@ class HelperTest extends CakeTestCase {
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp();
ClassRegistry::flush(); ClassRegistry::flush();
Router::reload(); Router::reload();
$null = null; $null = null;
@ -215,9 +217,11 @@ class HelperTest extends CakeTestCase {
* @return void * @return void
*/ */
public function tearDown() { public function tearDown() {
parent::tearDown();
Configure::delete('Asset');
CakePlugin::unload(); CakePlugin::unload();
unset($this->Helper, $this->View); unset($this->Helper, $this->View);
ClassRegistry::flush();
} }
/** /**
@ -565,9 +569,7 @@ class HelperTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testAssetTimestamp() { public function testAssetTimestamp() {
$_timestamp = Configure::read('Asset.timestamp'); Configure::write('Foo.bar', 'test');
$_debug = Configure::read('debug');
Configure::write('Asset.timestamp', false); Configure::write('Asset.timestamp', false);
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css'); $result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
$this->assertEquals(CSS_URL . 'cake.generic.css', $result); $this->assertEquals(CSS_URL . 'cake.generic.css', $result);
@ -593,9 +595,6 @@ class HelperTest extends CakeTestCase {
$this->Helper->request->webroot = '/some/dir/'; $this->Helper->request->webroot = '/some/dir/';
$result = $this->Helper->assetTimestamp('/some/dir/' . CSS_URL . 'cake.generic.css'); $result = $this->Helper->assetTimestamp('/some/dir/' . CSS_URL . 'cake.generic.css');
$this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result); $this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
Configure::write('debug', $_debug);
Configure::write('Asset.timestamp', $_timestamp);
} }
/** /**
@ -605,8 +604,6 @@ class HelperTest extends CakeTestCase {
*/ */
public function testAssetUrl() { public function testAssetUrl() {
$this->Helper->webroot = ''; $this->Helper->webroot = '';
$_timestamp = Configure::read('Asset.timestamp');
$result = $this->Helper->assetUrl(array( $result = $this->Helper->assetUrl(array(
'controller' => 'js', 'controller' => 'js',
'action' => 'post', 'action' => 'post',
@ -625,6 +622,17 @@ class HelperTest extends CakeTestCase {
$result = $this->Helper->assetUrl('style', array('ext' => '.css')); $result = $this->Helper->assetUrl('style', array('ext' => '.css'));
$this->assertEqual('style.css', $result); $this->assertEqual('style.css', $result);
$result = $this->Helper->assetUrl('foo.jpg?one=two&three=four');
$this->assertEquals('foo.jpg?one=two&three=four', $result);
}
/**
* Test assetUrl with plugins.
*
* @return void
*/
public function testAssetUrlPlugin() {
$this->Helper->webroot = '';
CakePlugin::load('TestPlugin'); CakePlugin::load('TestPlugin');
$result = $this->Helper->assetUrl('TestPlugin.style', array('ext' => '.css')); $result = $this->Helper->assetUrl('TestPlugin.style', array('ext' => '.css'));
@ -634,13 +642,19 @@ class HelperTest extends CakeTestCase {
$this->assertEqual('TestPlugin.style.css', $result); $this->assertEqual('TestPlugin.style.css', $result);
CakePlugin::unload('TestPlugin'); CakePlugin::unload('TestPlugin');
}
/**
* test assetUrl and Asset.timestamp = force
*
* @return void
*/
public function testAssetUrlTimestampForce() {
$this->Helper->webroot = '';
Configure::write('Asset.timestamp', 'force'); Configure::write('Asset.timestamp', 'force');
$result = $this->Helper->assetUrl('cake.generic.css', array('pathPrefix' => CSS_URL)); $result = $this->Helper->assetUrl('cake.generic.css', array('pathPrefix' => CSS_URL));
$this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result); $this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
Configure::write('Asset.timestamp', $_timestamp);
} }
/** /**
@ -649,7 +663,6 @@ class HelperTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testAssetTimestampPluginsAndThemes() { public function testAssetTimestampPluginsAndThemes() {
$timestamp = Configure::read('Asset.timestamp');
Configure::write('Asset.timestamp', 'force'); Configure::write('Asset.timestamp', 'force');
App::build(array( App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS),
@ -667,9 +680,6 @@ class HelperTest extends CakeTestCase {
$result = $this->Helper->assetTimestamp('/theme/test_theme/js/non_existant.js'); $result = $this->Helper->assetTimestamp('/theme/test_theme/js/non_existant.js');
$this->assertRegExp('#/theme/test_theme/js/non_existant.js\?$#', $result, 'No error on missing file'); $this->assertRegExp('#/theme/test_theme/js/non_existant.js\?$#', $result, 'No error on missing file');
App::build();
Configure::write('Asset.timestamp', $timestamp);
} }
/** /**

View file

@ -192,19 +192,30 @@ class CakeNumber {
* *
* ### Options * ### Options
* *
* - `before` - The currency symbol to place before whole numbers ie. '$' * - `wholeSymbol` - The currency symbol to use for whole numbers,
* - `after` - The currency symbol to place after decimal numbers ie. 'c'. Set to boolean false to * greater than 1, or less than -1.
* use no decimal symbol. eg. 0.35 => $0.35. * - `wholePosition` - The position the whole symbol should be placed
* - `zero` - The text to use for zero values, can be a string or a number. ie. 0, 'Free!' * valid options are 'before' & 'after'.
* - `fractionSymbol` - The currency symbol to use for fractional numbers.
* - `fractionPosition` - The position the fraction symbol should be placed
* valid options are 'before' & 'after'.
* - `before` - The currency symbol to place before whole numbers
* ie. '$'. `before` is an alias for `wholeSymbol`.
* - `after` - The currency symbol to place after decimal numbers
* ie. 'c'. Set to boolean false to use no decimal symbol.
* eg. 0.35 => $0.35. `after` is an alias for `fractionSymbol`
* - `zero` - The text to use for zero values, can be a
* string or a number. ie. 0, 'Free!'
* - `places` - Number of decimal places to use. ie. 2 * - `places` - Number of decimal places to use. ie. 2
* - `thousands` - Thousands separator ie. ',' * - `thousands` - Thousands separator ie. ','
* - `decimals` - Decimal separator symbol ie. '.' * - `decimals` - Decimal separator symbol ie. '.'
* - `negative` - Symbol for negative numbers. If equal to '()', the number will be wrapped with ( and ) * - `negative` - Symbol for negative numbers. If equal to '()',
* the number will be wrapped with ( and )
* - `escape` - Should the output be htmlentity escaped? Defaults to true * - `escape` - Should the output be htmlentity escaped? Defaults to true
* *
* @param float $number * @param float $number
* @param string $currency Shortcut to default options. Valid values are 'USD', 'EUR', 'GBP', otherwise * @param string $currency Shortcut to default options. Valid values are
* set at least 'before' and 'after' options. * 'USD', 'EUR', 'GBP', otherwise set at least 'before' and 'after' options.
* @param array $options * @param array $options
* @return string Number formatted as a currency. * @return string Number formatted as a currency.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency
@ -269,14 +280,8 @@ class CakeNumber {
* *
* {{{ $number->currency($value, 'NOK'); }}} * {{{ $number->currency($value, 'NOK'); }}}
* *
* Added formats are merged with the following defaults. * Added formats are merged with the defaults defined in CakeNumber::$_currencyDefaults
* * See CakeNumber::currency() for more information on the various options and their function.
* {{{
* array(
* 'before' => '$', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => ',',
* 'decimals' => '.', 'negative' => '()', 'escape' => true
* )
* }}}
* *
* @param string $formatName The format name to be used in the future. * @param string $formatName The format name to be used in the future.
* @param array $options The array of options for this format. * @param array $options The array of options for this format.

View file

@ -296,7 +296,7 @@ class Helper extends Object {
if (isset($plugin)) { if (isset($plugin)) {
$path = Inflector::underscore($plugin) . '/' . $path; $path = Inflector::underscore($plugin) . '/' . $path;
} }
$path = $this->assetTimestamp($this->webroot($path)); $path = h($this->assetTimestamp($this->webroot($path)));
if (!empty($options['fullBase'])) { if (!empty($options['fullBase'])) {
$path = $this->url('/', true) . $path; $path = $this->url('/', true) . $path;