Browse Source

Merge pull request #3875 from ADmad/3.0-merge

3.0 merge
José Lorenzo Rodríguez 11 years ago
parent
commit
63624e12e4
37 changed files with 87 additions and 81 deletions
  1. 0 1
      .travis.yml
  2. 1 1
      src/Cache/Engine/ApcEngine.php
  3. 0 2
      src/Console/Command/Task/ExtractTask.php
  4. 17 0
      src/Console/ConsoleErrorHandler.php
  5. 0 2
      src/Console/ConsoleInputArgument.php
  6. 0 2
      src/Console/ConsoleInputOption.php
  7. 0 2
      src/Console/HelpFormatter.php
  8. 0 2
      src/Controller/Component/SessionComponent.php
  9. 0 2
      src/Database/Exception.php
  10. 0 1
      src/Event/EventListener.php
  11. 0 2
      src/I18n/I18n.php
  12. 0 2
      src/Log/Engine/ConsoleLog.php
  13. 7 2
      src/Log/Engine/FileLog.php
  14. 0 2
      src/Log/Engine/SyslogLog.php
  15. 13 12
      src/Network/Email/Email.php
  16. 1 1
      src/Network/Request.php
  17. 2 2
      src/Network/Response.php
  18. 1 0
      src/Routing/Route/RedirectRoute.php
  19. 0 1
      src/Template/Error/fatal_error.ctp
  20. 0 1
      src/Template/Error/missing_connection.ctp
  21. 0 1
      src/Template/Error/missing_datasource.ctp
  22. 0 1
      src/Template/Error/missing_view.ctp
  23. 0 1
      src/Template/Error/pdo_error.ctp
  24. 4 4
      src/TestSuite/TestCase.php
  25. 10 1
      src/Utility/Inflector.php
  26. 1 1
      src/Validation/Validation.php
  27. 0 1
      src/View/View.php
  28. 0 4
      src/bootstrap.php
  29. 0 16
      tests/TestCase/Console/Command/Task/FixtureTaskTest.php
  30. 23 0
      tests/TestCase/Console/ConsoleErrorHandlerTest.php
  31. 0 1
      tests/TestCase/Log/Engine/SyslogLogTest.php
  32. 6 6
      tests/TestCase/Network/Email/EmailTest.php
  33. 1 0
      tests/TestCase/Utility/InflectorTest.php
  34. 0 1
      tests/test_app/Plugin/TestPlugin/src/Routing/Filter/TestDispatcherFilter.php
  35. 0 1
      tests/test_app/TestApp/Template/Error/error400.ctp
  36. 0 1
      tests/test_app/TestApp/Template/Error/error500.ctp
  37. 0 1
      tests/test_app/TestApp/View/Helper/BananaHelper.php

+ 0 - 1
.travis.yml

@@ -28,7 +28,6 @@ matrix:
     - php: hhvm-nightly
       env: HHVM=1 DB=mysql db_class='Cake\Database\Driver\Mysql' db_dsn='mysql:host=0.0.0.0;dbname=cakephp_test' db_database='cakephp_test' db_login='travis' db_password=''
 
-
 before_script:
   - composer self-update
   - composer install --prefer-source --no-interaction --dev

+ 1 - 1
src/Cache/Engine/ApcEngine.php

@@ -14,9 +14,9 @@
  */
 namespace Cake\Cache\Engine;
 
+use APCIterator;
 use Cake\Cache\CacheEngine;
 use Cake\Utility\Inflector;
-use APCIterator;
 
 /**
  * APC storage engine for cache

+ 0 - 2
src/Console/Command/Task/ExtractTask.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * Language string extractor
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 17 - 0
src/Console/ConsoleErrorHandler.php

@@ -51,6 +51,23 @@ class ConsoleErrorHandler extends BaseErrorHandler {
 	}
 
 /**
+ * Handle errors in the console environment. Writes errors to stderr,
+ * and logs messages if Configure::read('debug') is false.
+ *
+ * @param \Exception $exception Exception instance.
+ * @return void
+ * @throws Exception When renderer class not found
+ * @see http://php.net/manual/en/function.set-exception-handler.php
+ */
+	public function handleException(\Exception $exception) {
+		$this->_displayException($exception);
+		$this->_logException($exception);
+		$code = $exception->getCode();
+		$code = ($code && is_int($code)) ? $code : 1;
+		$this->_stop($code);
+	}
+
+/**
  * Prints an exception to stderr.
  *
  * @param \Exception $exception The exception to handle

+ 0 - 2
src/Console/ConsoleInputArgument.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * ConsoleArgumentOption file
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 2
src/Console/ConsoleInputOption.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * ConsoleInputOption file
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 2
src/Console/HelpFormatter.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * HelpFormatter
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 2
src/Controller/Component/SessionComponent.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * SessionComponent. Provides access to Sessions from the Controller layer
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 2
src/Database/Exception.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * Database Exception
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
src/Event/EventListener.php

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 2
src/I18n/I18n.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * Internationalization
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 2
src/Log/Engine/ConsoleLog.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * Console Logging
- *
  * CakePHP(tm) :  Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 7 - 2
src/Log/Engine/FileLog.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * File Storage stream for Logging
- *
  * CakePHP(tm) :  Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *
@@ -70,6 +68,13 @@ class FileLog extends BaseLog {
 	protected $_file = null;
 
 /**
+ * Max file size, used for log file rotation.
+ *
+ * @var int
+ */
+	protected $_size = null;
+
+/**
  * Sets protected properties based on config provided
  *
  * @param array $config Configuration array

+ 0 - 2
src/Log/Engine/SyslogLog.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * Syslog logger engine for CakePHP
- *
  * CakePHP(tm) :  Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 13 - 12
src/Network/Email/Email.php

@@ -329,11 +329,13 @@ class Email {
 
 /**
  * Regex for email validation
- * If null, filter_var() will be used.
+ *
+ * If null, filter_var() will be used. Use the emailPattern() method
+ * to set a custom pattern.'
  *
  * @var string
  */
-	protected $_emailPattern = null;
+	protected $_emailPattern = '/^((?:[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui';
 
 /**
  * The class name used for email configuration.
@@ -530,7 +532,7 @@ class Email {
  * Charset setter/getter
  *
  * @param string $charset Character set.
- * @return string $this->charset
+ * @return string this->charset
  */
 	public function charset($charset = null) {
 		if ($charset === null) {
@@ -547,7 +549,7 @@ class Email {
  * HeaderCharset setter/getter
  *
  * @param string $charset Character set.
- * @return string $this->charset
+ * @return string this->charset
  */
 	public function headerCharset($charset = null) {
 		if ($charset === null) {
@@ -562,8 +564,8 @@ class Email {
  * @param string $regex for email address validation
  * @return string|$this
  */
-	public function emailPattern($regex = null) {
-		if ($regex === null) {
+	public function emailPattern($regex = false) {
+		if ($regex === false) {
 			return $this->_emailPattern;
 		}
 		$this->_emailPattern = $regex;
@@ -609,13 +611,12 @@ class Email {
  * @throws \Cake\Network\Error\SocketException If email address does not validate
  */
 	protected function _validateEmail($email) {
-		$valid = (($this->_emailPattern !== null &&
-			preg_match($this->_emailPattern, $email)) ||
-			filter_var($email, FILTER_VALIDATE_EMAIL)
-		);
-		if (!$valid) {
-			throw new Error\SocketException(sprintf('Invalid email: "%s"', $email));
+		if ($this->_emailPattern === null && filter_var($email, FILTER_VALIDATE_EMAIL)) {
+			return;
+		} elseif (preg_match($this->_emailPattern, $email)) {
+			return;
 		}
+		throw new Error\SocketException(__d('cake_dev', 'Invalid email: "%s"', $email));
 	}
 
 /**

+ 1 - 1
src/Network/Request.php

@@ -611,7 +611,7 @@ class Request implements \ArrayAccess {
  *
  * @param array $types The types to check.
  * @return bool Success.
- * @see Request::is()
+ * @see \Cake\Network\Request::is()
  */
 	public function isAll(array $types) {
 		$result = array_filter(array_map(array($this, 'is'), $types));

+ 2 - 2
src/Network/Response.php

@@ -1142,7 +1142,7 @@ class Response {
  * the Last-Modified etag response header before calling this method. Otherwise
  * a comparison will not be possible.
  *
- * @param Request $request Request object
+ * @param \Cake\Network\Request $request Request object
  * @return bool whether the response was marked as not modified or not.
  */
 	public function checkNotModified(Request $request) {
@@ -1288,7 +1288,7 @@ class Response {
 /**
  * Normalize the origin to regular expressions and put in an array format
  *
- * @param array $domains Domain names.
+ * @param array $domains Domain names to normalize.
  * @param bool $requestIsSSL Whether it's a SSL request.
  * @return array
  */

+ 1 - 0
src/Routing/Route/RedirectRoute.php

@@ -107,4 +107,5 @@ class RedirectRoute extends Route {
 	public function match(array $url, array $context = array()) {
 		return false;
 	}
+
 }

+ 0 - 1
src/Template/Error/fatal_error.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
src/Template/Error/missing_connection.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
src/Template/Error/missing_datasource.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
src/Template/Error/missing_view.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
src/Template/Error/pdo_error.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 4 - 4
src/TestSuite/TestCase.php

@@ -68,8 +68,8 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
 /**
  * Overrides SimpleTestCase::skipIf to provide a boolean return value
  *
- * @param bool $shouldSkip
- * @param string $message
+ * @param bool $shouldSkip Whether or not the test should be skipped.
+ * @param string $message The message to display.
  * @return bool
  */
 	public function skipIf($shouldSkip, $message = '') {
@@ -527,9 +527,9 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
 /**
  * Mock a model, maintain fixtures and table association
  *
- * @param string $model The model to get a mock for.
+ * @param string $alias The model to get a mock for.
  * @param mixed $methods The list of methods to mock
- * @param array $config The config data for the mock's constructor.
+ * @param array $options The config data for the mock's constructor.
  * @throws \Cake\ORM\Error\MissingTableClassException
  * @return Model
  */

+ 10 - 1
src/Utility/Inflector.php

@@ -55,7 +55,16 @@ class Inflector {
 			'/$/' => 's',
 		),
 		'uninflected' => array(
-			'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'feedback'
+			'.*[nrlm]ese',
+			'.*deer',
+			'.*fish',
+			'.*measles',
+			'.*ois',
+			'.*pox',
+			'.*sheep',
+			'people',
+			'feedback',
+			'stadia'
 		),
 		'irregular' => array(
 			'atlas' => 'atlases',

+ 1 - 1
src/Validation/Validation.php

@@ -415,7 +415,7 @@ class Validation {
  * - true => Any number of decimal places greater than 0, or a float|double. The '.' is required.
  * - 1..N => Exactly that many number of decimal places. The '.' is required.
  *
- * @param float $check The value the test for decimal
+ * @param float $check The value the test for decimal.
  * @param int $places Decimal places.
  * @param string $regex If a custom regular expression is used, this is the only validation that will occur.
  * @return bool Success

+ 0 - 1
src/View/View.php

@@ -91,7 +91,6 @@ class View {
 /**
  * Name of the controller that created the View if any.
  *
- * @see Controller::$name
  * @var string
  */
 	public $name = null;

+ 0 - 4
src/bootstrap.php

@@ -1,9 +1,5 @@
 <?php
 /**
- * Basic Cake functionality.
- *
- * Handles loading of core files needed on every request
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 16
tests/TestCase/Console/Command/Task/FixtureTaskTest.php

@@ -207,22 +207,6 @@ class FixtureTaskTest extends TestCase {
  *
  * @return void
  */
-	public function testMainWithNamedModel() {
-		$this->Task->connection = 'test';
-		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
-
-		$this->Task->expects($this->at(0))
-			->method('createFile')
-			->with($filename, $this->stringContains('class ArticleFixture'));
-
-		$this->Task->main('article');
-	}
-
-/**
- * test that execute passes runs bake depending with named model.
- *
- * @return void
- */
 	public function testMainWithPluginModel() {
 		$this->Task->connection = 'test';
 		$filename = $this->_normalizePath(TEST_APP . 'Plugin/TestPlugin/tests/Fixture/ArticleFixture.php');

+ 23 - 0
tests/TestCase/Console/ConsoleErrorHandlerTest.php

@@ -135,4 +135,27 @@ class ConsoleErrorHandlerTest extends TestCase {
 		$this->Error->handleException($exception);
 	}
 
+/**
+ * test a exception with non-integer code
+ *
+ * @return void
+ */
+	public function testNonIntegerExceptionCode() {
+		$exception = new Error\Exception('Non-integer exception code');
+
+		$class = new \ReflectionClass('Exception');
+		$property = $class->getProperty('code');
+		$property->setAccessible(true);
+		$property->setValue($exception, '42S22');
+
+		$this->stderr->expects($this->once())->method('write')
+			->with($this->stringContains('Non-integer exception code'));
+
+		$this->Error->expects($this->once())
+			->method('_stop')
+			->with(1);
+
+		$this->Error->handleException($exception);
+	}
+
 }

+ 0 - 1
tests/TestCase/Log/Engine/SyslogLogTest.php

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 6 - 6
tests/TestCase/Network/Email/EmailTest.php

@@ -196,12 +196,16 @@ class EmailTest extends TestCase {
 		$this->assertSame($this->CakeEmail->to(), $expected);
 
 		$list = array(
+			'root@localhost' => 'root',
+			'bjørn@hammeröath.com' => 'Bjorn',
 			'cake@cakephp.org' => 'Cake PHP',
 			'cake-php@googlegroups.com' => 'Cake Groups',
 			'root@cakephp.org'
 		);
 		$this->CakeEmail->to($list);
 		$expected = array(
+			'root@localhost' => 'root',
+			'bjørn@hammeröath.com' => 'Bjorn',
 			'cake@cakephp.org' => 'Cake PHP',
 			'cake-php@googlegroups.com' => 'Cake Groups',
 			'root@cakephp.org' => 'root@cakephp.org'
@@ -212,6 +216,8 @@ class EmailTest extends TestCase {
 		$this->CakeEmail->addTo('mark_story@cakephp.org', 'Mark Story');
 		$result = $this->CakeEmail->addTo(array('phpnut@cakephp.org' => 'PhpNut', 'jose_zap@cakephp.org'));
 		$expected = array(
+			'root@localhost' => 'root',
+			'bjørn@hammeröath.com' => 'Bjorn',
 			'cake@cakephp.org' => 'Cake PHP',
 			'cake-php@googlegroups.com' => 'Cake Groups',
 			'root@cakephp.org' => 'root@cakephp.org',
@@ -222,9 +228,6 @@ class EmailTest extends TestCase {
 		);
 		$this->assertSame($this->CakeEmail->to(), $expected);
 		$this->assertSame($this->CakeEmail, $result);
-
-		$this->setExpectedException('Cake\Network\Error\SocketException');
-		$this->CakeEmail->to(array('cake@localhost', 'CakePHP'));
 	}
 
 /**
@@ -238,8 +241,6 @@ class EmailTest extends TestCase {
 			array(''),
 			array('string'),
 			array('<tag>'),
-			array('some@one-whereis'),
-			array('wrong@key' => 'Name'),
 			array(array('ok@cakephp.org', 1.0, '', 'string'))
 		);
 	}
@@ -273,7 +274,6 @@ class EmailTest extends TestCase {
  */
 	public function testEmailPattern() {
 		$regex = '/.+@.+\..+/i';
-		$this->assertNull($this->CakeEmail->emailPattern());
 		$this->assertSame($regex, $this->CakeEmail->emailPattern($regex)->emailPattern());
 	}
 

+ 1 - 0
tests/TestCase/Utility/InflectorTest.php

@@ -238,6 +238,7 @@ class InflectorTest extends TestCase {
 		$this->assertEquals(Inflector::pluralize('curve'), 'curves');
 		$this->assertEquals(Inflector::pluralize('body_curve'), 'body_curves');
 		$this->assertEquals(Inflector::pluralize('metadata'), 'metadata');
+		$this->assertEquals(Inflector::pluralize('stadia'), 'stadia');
 		$this->assertEquals(Inflector::pluralize(''), '');
 	}
 

+ 0 - 1
tests/test_app/Plugin/TestPlugin/src/Routing/Filter/TestDispatcherFilter.php

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
tests/test_app/TestApp/Template/Error/error400.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
tests/test_app/TestApp/Template/Error/error500.ctp

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *

+ 0 - 1
tests/test_app/TestApp/View/Helper/BananaHelper.php

@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *