Browse Source

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/Console/Command/Task/TestTask.php
mark_story 13 years ago
parent
commit
571c8bc08c

+ 3 - 3
lib/Cake/Console/Command/Task/TestTask.php

@@ -331,9 +331,9 @@ class TestTask extends BakeTask {
 /**
  * Get the base class and package name for a given type.
  *
- * @param string $type The type of class having a test
- *   generated is in.
- * @return array Array of class, type)
+ * @param string $type The type the class having a test
+ *   generated for is in.
+ * @return array Array of (class, type)
  * @throws CakeException on invalid types.
  */
 	public function getBaseType($type) {

+ 9 - 9
lib/Cake/Log/CakeLog.php

@@ -404,7 +404,7 @@ class CakeLog {
  *    or a string matching the recognized levels, then it will
  *    be treated log levels. Otherwise it's treated as scope.
  * @param string $message Message content to log
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -455,7 +455,7 @@ class CakeLog {
  * Convenience method to log emergency messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -467,7 +467,7 @@ class CakeLog {
  * Convenience method to log alert messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -479,7 +479,7 @@ class CakeLog {
  * Convenience method to log critical messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -491,7 +491,7 @@ class CakeLog {
  * Convenience method to log error messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -503,7 +503,7 @@ class CakeLog {
  * Convenience method to log warning messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -515,7 +515,7 @@ class CakeLog {
  * Convenience method to log notice messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -527,7 +527,7 @@ class CakeLog {
  * Convenience method to log debug messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */
@@ -539,7 +539,7 @@ class CakeLog {
  * Convenience method to log info messages
  *
  * @param string $message log message
- * @param string|array $scope The scope(s) a log messge is being created in.
+ * @param string|array $scope The scope(s) a log message is being created in.
  *    See CakeLog::config() for more information on logging scopes.
  * @return boolean Success
  */

+ 5 - 3
lib/Cake/Model/Datasource/DboSource.php

@@ -2315,7 +2315,6 @@ class DboSource extends DataSource {
 			}
 			$fields = array_values($fields);
 		}
-
 		if (!$quote) {
 			if (!empty($virtual)) {
 				$fields = array_merge($fields, $this->_constructVirtualFields($model, $alias, $virtual));
@@ -2633,8 +2632,11 @@ class DboSource extends DataSource {
 			$end = preg_quote($this->endQuote);
 		}
 		$conditions = str_replace(array($start, $end), '', $conditions);
-		$conditions = preg_replace_callback('/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', array(&$this, '_quoteMatchedField'), $conditions);
-
+		$conditions = preg_replace_callback(
+			'/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9\\-_' . $start . $end . ']*\\.[a-z0-9_\\-' . $start . $end . ']*)/i',
+			array(&$this, '_quoteMatchedField'),
+			$conditions
+		);
 		if ($conditions !== null) {
 			return $conditions;
 		}

+ 4 - 1
lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php

@@ -152,7 +152,7 @@ class ExtractTaskTest extends CakeTestCase {
 		$pattern .= 'msgid "Editing this Page"\nmsgstr ""/';
 		$this->assertRegExp($pattern, $result);
 
-		$pattern = '/\#: (\\\\|\/)extract\.ctp:18\nmsgid "';
+		$pattern = '/\#: (\\\\|\/)extract\.ctp:22\nmsgid "';
 		$pattern .= 'Hot features!';
 		$pattern .= '\\\n - No Configuration: Set-up the database and let the magic begin';
 		$pattern .= '\\\n - Extremely Simple: Just look at the name...It\'s Cake';
@@ -160,6 +160,9 @@ class ExtractTaskTest extends CakeTestCase {
 		$pattern .= '"\nmsgstr ""/';
 		$this->assertRegExp($pattern, $result);
 
+		$this->assertContains('msgid "double \\"quoted\\""', $result, 'Strings with quotes not handled correctly');
+		$this->assertContains("msgid \"single 'quoted'\"", $result, 'Strings with quotes not handled correctly');
+
 		// extract.ctp - reading the domain.pot
 		$result = file_get_contents($this->path . DS . 'domain.pot');
 

+ 5 - 1
lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php

@@ -403,8 +403,12 @@ class TranslateBehaviorTest extends CakeTestCase {
 				)
 			)
 		);
-
 		$this->assertEquals($expected, $result);
+
+		$TestModel = new TranslatedItem();
+		$TestModel->locale = array('pt-br');
+		$result = $TestModel->find('all');
+		$this->assertCount(3, $result, '3 records should have been found, no SQL error.');
 	}
 
 /**

+ 3 - 0
lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php

@@ -2028,6 +2028,9 @@ class MysqlTest extends CakeTestCase {
 		$result = $this->Dbo->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"');
 		$expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"';
 		$this->assertEquals($expected, $result);
+
+		$result = $this->Dbo->conditions('I18n__title_pt-br.content = "test"');
+		$this->assertEquals(' WHERE `I18n__title_pt-br`.`content` = "test"', $result);
 	}
 
 /**

+ 4 - 0
lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php

@@ -585,6 +585,10 @@ class DboSourceTest extends CakeTestCase {
 		$expected = 'Function(`Something`.`foo`) AS `x`';
 		$this->assertEquals($expected, $result);
 
+		$result = $this->testDb->name('I18n__title__pt-br.locale');
+		$expected = '`I18n__title__pt-br`.`locale`';
+		$this->assertEquals($expected, $result);
+
 		$result = $this->testDb->name('name-with-minus');
 		$expected = '`name-with-minus`';
 		$this->assertEquals($expected, $result);

+ 2 - 2
lib/Cake/Test/Case/Network/Email/CakeEmailTest.php

@@ -1163,11 +1163,11 @@ class CakeEmailTest extends CakeTestCase {
 		$this->CakeEmail->template('image');
 		$this->CakeEmail->emailFormat('html');
 		$server = env('SERVER_NAME') ? env('SERVER_NAME') : 'localhost';
-				
+
 		if (env('SERVER_PORT') != null && env('SERVER_PORT') != 80) {
 			$server .= ':' . env('SERVER_PORT');
 		}
-				
+
 		$expected = '<img src="http://' . $server . '/img/image.gif" alt="cool image" width="100" height="100" />';
 		$result = $this->CakeEmail->send();
 		$this->assertContains($expected, $result['message']);

+ 16 - 15
lib/Cake/Test/Case/Utility/FileTest.php

@@ -64,38 +64,39 @@ class FileTest extends CakeTestCase {
  * @return void
  */
 	public function testBasic() {
-		$file = __FILE__;
+		$file = CAKE . DS . 'LICENSE.txt';
 
-		$result = $this->File->pwd();
-		$expecting = $file;
-		$this->assertEquals($expecting, $result);
+		$this->File = new File($file, false);
 
 		$result = $this->File->name;
-		$expecting = basename(__FILE__);
+		$expecting = basename($file);
 		$this->assertEquals($expecting, $result);
 
 		$result = $this->File->info();
 		$expecting = array(
-			'dirname' => dirname(__FILE__),
-			'basename' => basename(__FILE__),
-			'extension' => 'php',
-			'filename' => 'FileTest',
+			'dirname' => dirname($file),
+			'basename' => basename($file),
+			'extension' => 'txt',
+			'filename' => 'LICENSE',
 			'filesize' => filesize($file),
-			'mime' => 'text/x-php'
+			'mime' => 'text/plain'
 		);
-		if (!function_exists('finfo_open') && (!function_exists('mime_content_type') ||
-				function_exists('mime_content_type') && false === mime_content_type($this->File->pwd()))) {
+		if (
+			!function_exists('finfo_open') &&
+			(!function_exists('mime_content_type') ||
+			function_exists('mime_content_type') &&
+			mime_content_type($this->File->pwd()) === false)
+		) {
 			$expecting['mime'] = false;
 		}
-
 		$this->assertEquals($expecting, $result);
 
 		$result = $this->File->ext();
-		$expecting = 'php';
+		$expecting = 'txt';
 		$this->assertEquals($expecting, $result);
 
 		$result = $this->File->name();
-		$expecting = 'FileTest';
+		$expecting = 'LICENSE';
 		$this->assertEquals($expecting, $result);
 
 		$result = $this->File->md5();

+ 11 - 11
lib/Cake/Test/Case/Utility/ValidationTest.php

@@ -1510,9 +1510,9 @@ class ValidationTest extends CakeTestCase {
 		$this->assertTrue(Validation::decimal('1234', null));
 		$this->assertTrue(Validation::decimal('-1234', null));
 		$this->assertTrue(Validation::decimal('+1234', null));
-		$this->assertTrue(Validation::decimal((float) 1234, null));
-		$this->assertTrue(Validation::decimal((double) 1234, null));
-		$this->assertTrue(Validation::decimal((int) 1234, null));
+		$this->assertTrue(Validation::decimal((float)1234, null));
+		$this->assertTrue(Validation::decimal((double)1234, null));
+		$this->assertTrue(Validation::decimal((int)1234, null));
 
 		$this->assertFalse(Validation::decimal('', null));
 		$this->assertFalse(Validation::decimal('string', null));
@@ -1540,13 +1540,13 @@ class ValidationTest extends CakeTestCase {
 		$this->assertTrue(Validation::decimal('.00', true));
 		$this->assertTrue(Validation::decimal(.01, true));
 		$this->assertTrue(Validation::decimal('.01', true));
-		$this->assertTrue(Validation::decimal((float) 1234, true));
-		$this->assertTrue(Validation::decimal((double) 1234, true));
+		$this->assertTrue(Validation::decimal((float)1234, true));
+		$this->assertTrue(Validation::decimal((double)1234, true));
 
 		$this->assertFalse(Validation::decimal('', true));
 		$this->assertFalse(Validation::decimal('string', true));
 		$this->assertFalse(Validation::decimal('1234.', true));
-		$this->assertFalse(Validation::decimal((int) 1234, true));
+		$this->assertFalse(Validation::decimal((int)1234, true));
 		$this->assertFalse(Validation::decimal('1234', true));
 		$this->assertFalse(Validation::decimal('-1234', true));
 		$this->assertFalse(Validation::decimal('+1234', true));
@@ -1580,9 +1580,9 @@ class ValidationTest extends CakeTestCase {
 		$this->assertFalse(Validation::decimal('1234.', 1));
 		$this->assertFalse(Validation::decimal(.0, 1));
 		$this->assertFalse(Validation::decimal(.00, 2));
-		$this->assertFalse(Validation::decimal((float) 1234, 1));
-		$this->assertFalse(Validation::decimal((double) 1234, 1));
-		$this->assertFalse(Validation::decimal((int) 1234, 1));
+		$this->assertFalse(Validation::decimal((float)1234, 1));
+		$this->assertFalse(Validation::decimal((double)1234, 1));
+		$this->assertFalse(Validation::decimal((int)1234, 1));
 		$this->assertFalse(Validation::decimal('1234.5678', '3'));
 		$this->assertFalse(Validation::decimal(1234.5678, 3));
 		$this->assertFalse(Validation::decimal(-1234.5678, 3));
@@ -1596,8 +1596,8 @@ class ValidationTest extends CakeTestCase {
  */
 	public function testDecimalWithInvalidPlaces() {
 		$this->assertFalse(Validation::decimal('.27', 'string'));
-		$this->assertFalse(Validation::decimal(1234.5678, (array) true));
-		$this->assertFalse(Validation::decimal(-1234.5678, (object) true));
+		$this->assertFalse(Validation::decimal(1234.5678, (array)true));
+		$this->assertFalse(Validation::decimal(-1234.5678, (object)true));
 	}
 
 /**

+ 4 - 0
lib/Cake/Test/test_app/View/Pages/extract.ctp

@@ -14,6 +14,10 @@ echo __dn('domain', 'You deleted %d message (domain).', 'You deleted %d messages
 echo __('Editing this Page');
 echo __('You have %d new message.');
 
+// Contains quotes
+echo __('double "quoted"');
+echo __("single 'quoted'");
+
 // Multiline
 __('Hot features!'
 	. "\n - No Configuration:"

+ 3 - 3
lib/Cake/View/View.php

@@ -625,7 +625,7 @@ class View extends Object {
  * @param string $value The content for the block.
  * @return void
  * @throws CakeException when you use non-string values.
- * @see ViewBlock::assign()
+ * @see ViewBlock::set()
  */
 	public function assign($name, $value) {
 		return $this->Blocks->set($name, $value);
@@ -637,7 +637,7 @@ class View extends Object {
  *
  * @param string $name Name of the block
  * @return The block content or '' if the block does not exist.
- * @see ViewBlock::fetch()
+ * @see ViewBlock::get()
  */
 	public function fetch($name) {
 		return $this->Blocks->get($name);
@@ -647,7 +647,7 @@ class View extends Object {
  * End a capturing block. The compliment to View::start()
  *
  * @return void
- * @see ViewBlock::start()
+ * @see ViewBlock::end()
  */
 	public function end() {
 		return $this->Blocks->end();