mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge branch 'master' into 2.7
This commit is contained in:
commit
eb85a875c0
13 changed files with 125 additions and 18 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -33,3 +33,6 @@
|
|||
*.ico binary
|
||||
*.mo binary
|
||||
*.pdf binary
|
||||
*.woff binary
|
||||
*.ttf binary
|
||||
*.eot binary
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.2
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
@ -27,8 +26,8 @@ matrix:
|
|||
|
||||
|
||||
before_script:
|
||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi"
|
||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi"
|
||||
- sh -c "composer global require 'phpunit/phpunit=3.7.33'"
|
||||
- sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit"
|
||||
- sudo locale-gen de_DE
|
||||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
|
||||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi"
|
||||
|
|
|
@ -60,7 +60,7 @@ To run the sniffs for CakePHP coding standards:
|
|||
phpcs -p --extensions=php --standard=CakePHP ./lib/Cake
|
||||
|
||||
Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
|
||||
repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.mdown) contains installation info
|
||||
repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info
|
||||
for the sniff and phpcs.
|
||||
|
||||
# Additional Resources
|
||||
|
|
|
@ -123,7 +123,7 @@ class PluginTask extends AppShell {
|
|||
'Test' . DS . 'Fixture',
|
||||
'View' . DS . 'Elements',
|
||||
'View' . DS . 'Helper',
|
||||
'View' . DS . 'Layout',
|
||||
'View' . DS . 'Layouts',
|
||||
'webroot' . DS . 'css',
|
||||
'webroot' . DS . 'js',
|
||||
'webroot' . DS . 'img',
|
||||
|
|
|
@ -22,7 +22,6 @@ App::uses('ConsoleInputSubcommand', 'Console');
|
|||
App::uses('ConsoleOptionParser', 'Console');
|
||||
App::uses('ClassRegistry', 'Utility');
|
||||
App::uses('File', 'Utility');
|
||||
App::uses('ClassRegistry', 'Utility');
|
||||
|
||||
/**
|
||||
* Base class for command-line utilities for automating programmer chores.
|
||||
|
|
|
@ -95,6 +95,14 @@ App::uses('Router', 'Routing');
|
|||
*/
|
||||
class ErrorHandler {
|
||||
|
||||
/**
|
||||
* Whether to give up rendering an exception, if the renderer itself is
|
||||
* throwing exceptions.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $_bailExceptionRendering = false;
|
||||
|
||||
/**
|
||||
* Set as the default exception handler by the CakePHP bootstrap process.
|
||||
*
|
||||
|
@ -125,6 +133,8 @@ class ErrorHandler {
|
|||
$e->getMessage(),
|
||||
$e->getTraceAsString()
|
||||
);
|
||||
|
||||
self::$_bailExceptionRendering = true;
|
||||
trigger_error($message, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -234,6 +244,8 @@ class ErrorHandler {
|
|||
* @param string $file File on which error occurred
|
||||
* @param int $line Line that triggered the error
|
||||
* @return bool
|
||||
* @throws FatalErrorException If the Exception renderer threw an exception during rendering, and debug > 0.
|
||||
* @throws InternalErrorException If the Exception renderer threw an exception during rendering, and debug is 0.
|
||||
*/
|
||||
public static function handleFatalError($code, $description, $file, $line) {
|
||||
$logMessage = 'Fatal Error (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
|
||||
|
@ -249,10 +261,18 @@ class ErrorHandler {
|
|||
}
|
||||
|
||||
if (Configure::read('debug')) {
|
||||
call_user_func($exceptionHandler, new FatalErrorException($description, 500, $file, $line));
|
||||
$exception = new FatalErrorException($description, 500, $file, $line);
|
||||
} else {
|
||||
call_user_func($exceptionHandler, new InternalErrorException());
|
||||
$exception = new InternalErrorException();
|
||||
}
|
||||
|
||||
if (self::$_bailExceptionRendering) {
|
||||
self::$_bailExceptionRendering = false;
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
call_user_func($exceptionHandler, $exception);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1138,7 +1138,7 @@ class CakeResponse {
|
|||
/**
|
||||
* Checks whether a response has not been modified according to the 'If-None-Match'
|
||||
* (Etags) and 'If-Modified-Since' (last modification date) request
|
||||
* headers headers. If the response is detected to be not modified, it
|
||||
* headers. If the response is detected to be not modified, it
|
||||
* is marked as so accordingly so the client can be informed of that.
|
||||
*
|
||||
* In order to mark a response as not modified, you need to set at least
|
||||
|
|
|
@ -115,7 +115,7 @@ class PluginTaskTest extends CakeTestCase {
|
|||
'Test' . DS . 'Fixture',
|
||||
'View' . DS . 'Elements',
|
||||
'View' . DS . 'Helper',
|
||||
'View' . DS . 'Layout',
|
||||
'View' . DS . 'Layouts',
|
||||
'webroot' . DS . 'css',
|
||||
'webroot' . DS . 'js',
|
||||
'webroot' . DS . 'img',
|
||||
|
|
|
@ -254,7 +254,11 @@ class BasicAuthenticateTest extends CakeTestCase {
|
|||
*/
|
||||
public function testAuthenticateUserFieldsRelatedModelsSuccess() {
|
||||
$User = ClassRegistry::init('User');
|
||||
$User->bindModel(array('hasOne' => array('Article')));
|
||||
$User->bindModel(array('hasOne' => array(
|
||||
'Article' => array(
|
||||
'order' => 'Article.id ASC'
|
||||
)
|
||||
)));
|
||||
$this->auth->settings['recursive'] = 0;
|
||||
$this->auth->settings['userFields'] = array('Article.id', 'Article.title');
|
||||
$request = new CakeRequest('posts/index', false);
|
||||
|
|
|
@ -20,6 +20,23 @@ App::uses('ErrorHandler', 'Error');
|
|||
App::uses('Controller', 'Controller');
|
||||
App::uses('Router', 'Routing');
|
||||
|
||||
/**
|
||||
* A faulty ExceptionRenderer to test nesting.
|
||||
*/
|
||||
class FaultyExceptionRenderer extends ExceptionRenderer {
|
||||
|
||||
/**
|
||||
* Dummy rendering implementation.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function render() {
|
||||
throw new Exception('Error from renderer.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ErrorHandlerTest class
|
||||
*
|
||||
|
@ -320,4 +337,48 @@ class ErrorHandlerTest extends CakeTestCase {
|
|||
$this->assertContains('[FatalErrorException] Something wrong', $log[1], 'message missing.');
|
||||
}
|
||||
|
||||
/**
|
||||
* testExceptionRendererNestingDebug method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionRendererNestingDebug() {
|
||||
Configure::write('debug', 2);
|
||||
Configure::write('Exception.renderer', 'FaultyExceptionRenderer');
|
||||
|
||||
$result = false;
|
||||
try {
|
||||
ob_start();
|
||||
ob_start();
|
||||
ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__);
|
||||
} catch (Exception $e) {
|
||||
$result = $e instanceof FatalErrorException;
|
||||
}
|
||||
|
||||
restore_error_handler();
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testExceptionRendererNestingProduction method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionRendererNestingProduction() {
|
||||
Configure::write('debug', 0);
|
||||
Configure::write('Exception.renderer', 'FaultyExceptionRenderer');
|
||||
|
||||
$result = false;
|
||||
try {
|
||||
ob_start();
|
||||
ob_start();
|
||||
ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__);
|
||||
} catch (Exception $e) {
|
||||
$result = $e instanceof InternalErrorException;
|
||||
}
|
||||
|
||||
restore_error_handler();
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -763,6 +763,32 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests correct generation of decimal fields as text inputs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTextFieldGenerationForDecimalAsText() {
|
||||
$this->Form->create('ValidateUser');
|
||||
$result = $this->Form->input('cost_decimal', array(
|
||||
'type' => 'text'
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'label' => array('for' => 'ValidateUserCostDecimal'),
|
||||
'Cost Decimal',
|
||||
'/label',
|
||||
array('input' => array(
|
||||
'type' => 'text',
|
||||
'name' => 'data[ValidateUser][cost_decimal]',
|
||||
'id' => 'ValidateUserCostDecimal',
|
||||
'maxlength' => 6,
|
||||
)),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests correct generation of number fields for integer fields
|
||||
*
|
||||
|
|
|
@ -20,12 +20,7 @@
|
|||
<div id="content">
|
||||
<h2>PHPUnit is not installed!</h2>
|
||||
<p>You must install PHPUnit to use the CakePHP(tm) Test Suite.</p>
|
||||
<p>PHPUnit can be installed with pear, using the pear installer.</p>
|
||||
<p>To install with the PEAR installer run the following commands:</p>
|
||||
<ul>
|
||||
<li><code>pear config-set auto_discover 1</code></li>
|
||||
<li><code>pear install pear.phpunit.de/PHPUnit</code></li>
|
||||
</ul>
|
||||
<p>PHPUnit can be installed with Composer, or downloaded as a phar archive.</p>
|
||||
<p>Once PHPUnit is installed make sure its located on PHP's <code>include_path</code> by checking your php.ini</p>
|
||||
<p>For full instructions on how to <a href="http://www.phpunit.de/manual/current/en/installation.html" target="_blank">install PHPUnit, see the PHPUnit installation guide</a>.</p>
|
||||
<p><a href="https://github.com/sebastianbergmann/phpunit" target="_blank">Download PHPUnit</a></p>
|
||||
|
|
|
@ -1292,7 +1292,7 @@ class FormHelper extends AppHelper {
|
|||
if ($autoLength &&
|
||||
in_array($options['type'], array('text', 'textarea', 'email', 'tel', 'url', 'search'))
|
||||
) {
|
||||
$options['maxlength'] = $fieldDef['length'];
|
||||
$options['maxlength'] = (int)$fieldDef['length'];
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue