mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
commit
f0abce55f2
22 changed files with 143 additions and 25 deletions
|
@ -41,15 +41,13 @@ matrix:
|
|||
|
||||
- php: 7.2
|
||||
env: DB=mysql PHPUNIT=5.7.19
|
||||
allow_failures:
|
||||
exclude:
|
||||
- php: 7.2
|
||||
env: DB=mysql
|
||||
|
||||
- php: 7.2
|
||||
env: DB=mysql PHPUNIT=5.7.19
|
||||
|
||||
|
||||
before_script:
|
||||
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]] ; then pear config-set preferred_state snapshot && yes "" | pecl install mcrypt ; fi
|
||||
- composer require "phpunit/phpunit=$PHPUNIT"
|
||||
- echo "require_once 'vendors/autoload.php';" >> app/Config/bootstrap.php
|
||||
- sudo locale-gen de_DE
|
||||
|
@ -62,7 +60,6 @@ before_script:
|
|||
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -U postgres -d cakephp_test; fi"
|
||||
- chmod -R 777 ./app/tmp
|
||||
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]] ; then pecl install timezonedb ; fi
|
||||
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]] ; then pecl install mcrypt ; fi
|
||||
- sh -c "if [ '$PHPCS' = '1' ]; then composer require 'cakephp/cakephp-codesniffer:1.*'; fi"
|
||||
- sh -c "if [ '$PHPCS' = '1' ]; then vendors/bin/phpcs --config-set installed_paths vendors/cakephp/cakephp-codesniffer; fi"
|
||||
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"ext-mcrypt": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "<6.0.0",
|
||||
"phpunit/phpunit": "^3.7",
|
||||
"cakephp/cakephp-codesniffer": "^1.0.0"
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -181,7 +181,7 @@ abstract class CacheEngine {
|
|||
|
||||
$prefix = '';
|
||||
if (!empty($this->_groupPrefix)) {
|
||||
$prefix = vsprintf($this->_groupPrefix, $this->groups());
|
||||
$prefix = md5(implode('_', $this->groups()));
|
||||
}
|
||||
|
||||
$key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace(array(DS, '/', '.'), '_', strval($key)))));
|
||||
|
|
|
@ -331,6 +331,12 @@ class ControllerTask extends BakeTask {
|
|||
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||
$this->out("\n" . __d('cake_console', 'Baking controller class for %s...', $controllerName), 1, Shell::QUIET);
|
||||
|
||||
if ($helpers === null) {
|
||||
$helpers = array();
|
||||
}
|
||||
if ($components === null) {
|
||||
$components = array();
|
||||
}
|
||||
$isScaffold = ($actions === 'scaffold') ? true : false;
|
||||
|
||||
$this->Template->set(array(
|
||||
|
|
|
@ -554,7 +554,7 @@ class Multibyte {
|
|||
|
||||
if (!empty($keys)) {
|
||||
foreach ($keys as $key => $value) {
|
||||
if ($keys[$key]['upper'] == $char && count($keys[$key]['lower'][0]) === 1) {
|
||||
if ($keys[$key]['upper'] == $char && count($keys[$key]['lower']) > 0) {
|
||||
$lowerCase[] = $keys[$key]['lower'][0];
|
||||
$matched = true;
|
||||
break 1;
|
||||
|
|
|
@ -552,6 +552,12 @@ class CakeSession {
|
|||
|
||||
if (!empty($sessionConfig['handler'])) {
|
||||
$sessionConfig['ini']['session.save_handler'] = 'user';
|
||||
|
||||
// In PHP7.2.0+ session.save_handler can't be set to 'user' by the user.
|
||||
// https://github.com/php/php-src/commit/a93a51c3bf4ea1638ce0adc4a899cb93531b9f0d
|
||||
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
|
||||
unset($sessionConfig['ini']['session.save_handler']);
|
||||
}
|
||||
} elseif (!empty($sessionConfig['session.save_path']) && Configure::read('debug')) {
|
||||
if (!is_dir($sessionConfig['session.save_path'])) {
|
||||
mkdir($sessionConfig['session.save_path'], 0775, true);
|
||||
|
|
|
@ -302,6 +302,10 @@ class Sqlserver extends DboSource {
|
|||
$prepend = 'DISTINCT ';
|
||||
$fields[$i] = trim(str_replace('DISTINCT', '', $fields[$i]));
|
||||
}
|
||||
if (strpos($fields[$i], 'COUNT(DISTINCT') !== false) {
|
||||
$prepend = 'COUNT(DISTINCT ';
|
||||
$fields[$i] = trim(str_replace('COUNT(DISTINCT', '', $this->_quoteFields($fields[$i])));
|
||||
}
|
||||
|
||||
if (!preg_match('/\s+AS\s+/i', $fields[$i])) {
|
||||
if (substr($fields[$i], -1) === '*') {
|
||||
|
|
|
@ -470,7 +470,7 @@ class DboSource extends DataSource {
|
|||
$query = $this->_connection->prepare($sql, $prepareOptions);
|
||||
$query->setFetchMode(PDO::FETCH_LAZY);
|
||||
if (!$query->execute($params)) {
|
||||
$this->_results = $query;
|
||||
$this->_result = $query;
|
||||
$query->closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -415,6 +415,7 @@ class AuthComponentTest extends CakeTestCase {
|
|||
TestAuthComponent::clearUser();
|
||||
$this->Auth->Session->delete('Auth');
|
||||
$this->Auth->Session->delete('Message.auth');
|
||||
$this->Auth->Session->destroy();
|
||||
unset($this->Controller, $this->Auth);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,11 +120,11 @@ class ControllerPaginateModel extends CakeTestModel {
|
|||
/**
|
||||
* paginate method
|
||||
*
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) {
|
||||
$this->extra = $extra;
|
||||
return true;
|
||||
return array(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -186,6 +186,7 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
$this->Controller->Session->delete('_Token');
|
||||
$this->Controller->Session->destroy();
|
||||
unset($this->Controller->Security);
|
||||
unset($this->Controller->Component);
|
||||
unset($this->Controller);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
App::uses('Router', 'Routing');
|
||||
App::uses('CakeSession', 'Model/Datasource');
|
||||
App::uses('Controller', 'Controller');
|
||||
App::uses('Scaffold', 'Controller');
|
||||
App::uses('ScaffoldView', 'View');
|
||||
|
@ -175,6 +176,7 @@ class ScaffoldTest extends CakeTestCase {
|
|||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
CakeSession::destroy();
|
||||
unset($this->Controller);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ class I18nTest extends CakeTestCase {
|
|||
parent::tearDown();
|
||||
|
||||
Cache::delete('object_map', '_cake_core_');
|
||||
CakeSession::destroy();
|
||||
App::build();
|
||||
CakePlugin::unload();
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class ConnectionManagerTest extends CakeTestCase {
|
|||
|
||||
ConnectionManager::create($name, $config);
|
||||
$connections = ConnectionManager::enumConnectionObjects();
|
||||
$this->assertTrue((bool)(count(array_keys($connections) >= 1)));
|
||||
$this->assertTrue(count(array_keys($connections)) >= 1);
|
||||
|
||||
$source = ConnectionManager::getDataSource('test_get_datasource');
|
||||
$this->assertTrue(is_object($source));
|
||||
|
@ -239,7 +239,7 @@ class ConnectionManagerTest extends CakeTestCase {
|
|||
$name = 'test_created_connection';
|
||||
|
||||
$connections = ConnectionManager::enumConnectionObjects();
|
||||
$this->assertTrue((bool)(count(array_keys($connections) >= 1)));
|
||||
$this->assertTrue(count(array_keys($connections)) >= 1);
|
||||
|
||||
$source = ConnectionManager::getDataSource('test');
|
||||
$this->assertTrue(is_object($source));
|
||||
|
|
|
@ -383,6 +383,10 @@ class SqlserverTest extends CakeTestCase {
|
|||
$result = $this->db->fields($this->model, null, 'DISTINCT Car.country_code');
|
||||
$expected = array('DISTINCT [Car].[country_code] AS [Car__country_code]');
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $this->db->fields($this->model, null, 'COUNT(DISTINCT Car.country_code)');
|
||||
$expected = array('COUNT(DISTINCT [Car].[country_code]) AS [Car__country_code]');
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3367,7 +3367,9 @@ class ModelWriteTest extends BaseModelTest {
|
|||
array(
|
||||
'comment' => 'Article comment',
|
||||
'user_id' => 1
|
||||
)));
|
||||
)
|
||||
)
|
||||
);
|
||||
$Article = new Article();
|
||||
$result = $Article->saveAll($data);
|
||||
$this->assertFalse(empty($result));
|
||||
|
@ -3376,7 +3378,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->assertEquals(2, count($result['Tag']));
|
||||
$this->assertEquals('tag1', $result['Tag'][0]['tag']);
|
||||
$this->assertEquals(1, count($result['Comment']));
|
||||
$this->assertEquals(1, count($result['Comment'][0]['comment']));
|
||||
$this->assertEquals('Article comment', $result['Comment'][0]['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5647,7 +5649,9 @@ class ModelWriteTest extends BaseModelTest {
|
|||
array(
|
||||
'comment' => 'Article comment',
|
||||
'user_id' => 1
|
||||
)));
|
||||
)
|
||||
)
|
||||
);
|
||||
$Article = new Article();
|
||||
$result = $Article->saveAssociated($data);
|
||||
$this->assertFalse(empty($result));
|
||||
|
@ -5656,7 +5660,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->assertEquals(2, count($result['Tag']));
|
||||
$this->assertEquals('tag1', $result['Tag'][0]['tag']);
|
||||
$this->assertEquals(1, count($result['Comment']));
|
||||
$this->assertEquals(1, count($result['Comment'][0]['comment']));
|
||||
$this->assertEquals('Article comment', $result['Comment'][0]['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,6 +79,12 @@ if (!class_exists('PostsController')) {
|
|||
public $components = array(
|
||||
'RequestHandler',
|
||||
'Email',
|
||||
'AliasedEmail' => array(
|
||||
'className' => 'Email',
|
||||
),
|
||||
'AliasedPluginEmail' => array(
|
||||
'className' => 'TestPlugin.TestPluginEmail',
|
||||
),
|
||||
'Auth'
|
||||
);
|
||||
}
|
||||
|
@ -270,6 +276,44 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$this->assertFalse($Tests->TestPluginComment->save(array()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ControllerTestCase::generate() using aliased component
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGenerateWithMockedAliasedComponent() {
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'components' => array(
|
||||
'AliasedEmail' => array('send')
|
||||
)
|
||||
));
|
||||
$Posts->AliasedEmail->expects($this->once())
|
||||
->method('send')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->assertInstanceOf('EmailComponent', $Posts->AliasedEmail);
|
||||
$this->assertTrue($Posts->AliasedEmail->send());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ControllerTestCase::generate() using aliased plugin component
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGenerateWithMockedAliasedPluginComponent() {
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'components' => array(
|
||||
'AliasedPluginEmail' => array('send')
|
||||
)
|
||||
));
|
||||
$Posts->AliasedPluginEmail->expects($this->once())
|
||||
->method('send')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->assertInstanceOf('TestPluginEmailComponent', $Posts->AliasedPluginEmail);
|
||||
$this->assertTrue($Posts->AliasedPluginEmail->send());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests testAction
|
||||
*
|
||||
|
|
|
@ -87,6 +87,7 @@ class SessionHelperTest extends CakeTestCase {
|
|||
public function tearDown() {
|
||||
$_SESSION = array();
|
||||
unset($this->View, $this->Session);
|
||||
CakeSession::destroy();
|
||||
CakePlugin::unload();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
@ -149,6 +150,18 @@ class SessionHelperTest extends CakeTestCase {
|
|||
$this->assertFalse($this->Session->check('Message.bare'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the flash method works without any params being passed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFlashWithNoParams() {
|
||||
$result = $this->Session->flash();
|
||||
$expected = '<div id="flashMessage" class="message">This is a calling</div>';
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertFalse($this->Session->check('Message.flash'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test flash() with the attributes.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
App::uses('EmailComponent', 'Controller/Component');
|
||||
|
||||
/**
|
||||
* TestPluginEmailComponent
|
||||
*
|
||||
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
|
||||
*/
|
||||
class TestPluginEmailComponent extends EmailComponent {
|
||||
}
|
|
@ -388,7 +388,15 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
if ($methods === true) {
|
||||
$methods = array();
|
||||
}
|
||||
$config = isset($controllerObj->components[$component]) ? $controllerObj->components[$component] : array();
|
||||
if (isset($config['className'])) {
|
||||
$alias = $component;
|
||||
$component = $config['className'];
|
||||
}
|
||||
list($plugin, $name) = pluginSplit($component, true);
|
||||
if (!isset($alias)) {
|
||||
$alias = $name;
|
||||
}
|
||||
$componentClass = $name . 'Component';
|
||||
App::uses($componentClass, $plugin . 'Controller/Component');
|
||||
if (!class_exists($componentClass)) {
|
||||
|
@ -396,11 +404,11 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
'class' => $componentClass
|
||||
));
|
||||
}
|
||||
$config = isset($controllerObj->components[$component]) ? $controllerObj->components[$component] : array();
|
||||
/** @var Component|PHPUnit_Framework_MockObject_MockObject $componentObj */
|
||||
$componentObj = $this->getMock($componentClass, $methods, array($controllerObj->Components, $config));
|
||||
$controllerObj->Components->set($name, $componentObj);
|
||||
$controllerObj->Components->enable($name);
|
||||
$controllerObj->Components->set($alias, $componentObj);
|
||||
$controllerObj->Components->enable($alias);
|
||||
unset($alias);
|
||||
}
|
||||
|
||||
$controllerObj->constructClasses();
|
||||
|
|
|
@ -25,6 +25,13 @@ App::uses('CakeBaseReporter', 'TestSuite/Reporter');
|
|||
*/
|
||||
class CakeHtmlReporter extends CakeBaseReporter {
|
||||
|
||||
/**
|
||||
* The content buffer
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_buffer = '';
|
||||
|
||||
/**
|
||||
* Paints the top of the web page setting the
|
||||
* title to the name of the starting test.
|
||||
|
@ -33,12 +40,13 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
*/
|
||||
public function paintHeader() {
|
||||
$this->_headerSent = true;
|
||||
ob_start();
|
||||
$this->sendContentType();
|
||||
$this->sendNoCacheHeaders();
|
||||
$this->paintDocumentStart();
|
||||
$this->paintTestMenu();
|
||||
echo "<ul class='tests'>\n";
|
||||
ob_end_flush();
|
||||
$this->_buffer = ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +66,6 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintDocumentStart() {
|
||||
ob_start();
|
||||
$baseDir = $this->params['baseDir'];
|
||||
include CAKE . 'TestSuite' . DS . 'templates' . DS . 'header.php';
|
||||
}
|
||||
|
@ -135,7 +142,9 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintFooter($result) {
|
||||
echo $this->_buffer;
|
||||
ob_end_flush();
|
||||
|
||||
$colour = ($result->failureCount() + $result->errorCount() > 0 ? "red" : "green");
|
||||
echo "</ul>\n";
|
||||
echo "<div style=\"";
|
||||
|
@ -248,6 +257,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintFail($message, $test) {
|
||||
ob_start();
|
||||
$trace = $this->_getStackTrace($message);
|
||||
$className = get_class($test);
|
||||
$testName = $className . '::' . $test->getName() . '()';
|
||||
|
@ -286,6 +296,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
}
|
||||
echo "<div class='msg'>" . __d('cake_dev', 'Stack trace:') . '<br />' . $trace . "</div>\n";
|
||||
echo "</li>\n";
|
||||
$this->_buffer .= ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,6 +309,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintPass(PHPUnit_Framework_Test $test, $time = null) {
|
||||
ob_start();
|
||||
if (isset($this->params['showPasses']) && $this->params['showPasses']) {
|
||||
echo "<li class='pass'>\n";
|
||||
echo "<span>Passed</span> ";
|
||||
|
@ -305,6 +317,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
echo "<br />" . $this->_htmlEntities($test->getName()) . " ($time seconds)\n";
|
||||
echo "</li>\n";
|
||||
}
|
||||
$this->_buffer .= ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,6 +328,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintException($message, $test) {
|
||||
ob_start();
|
||||
$trace = $this->_getStackTrace($message);
|
||||
$testName = get_class($test) . '(' . $test->getName() . ')';
|
||||
|
||||
|
@ -325,6 +339,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
echo "<div class='msg'>" . __d('cake_dev', 'Test case: %s', $testName) . "</div>\n";
|
||||
echo "<div class='msg'>" . __d('cake_dev', 'Stack trace:') . '<br />' . $trace . "</div>\n";
|
||||
echo "</li>\n";
|
||||
$this->_buffer .= ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,10 +350,12 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintSkip($message, $test) {
|
||||
ob_start();
|
||||
echo "<li class='skipped'>\n";
|
||||
echo "<span>Skipped</span> ";
|
||||
echo $test->getName() . ': ' . $this->_htmlEntities($message->getMessage());
|
||||
echo "</li>\n";
|
||||
$this->_buffer .= ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,9 +407,9 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
*/
|
||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
||||
if (!$this->_headerSent) {
|
||||
echo $this->paintHeader();
|
||||
$this->paintHeader();
|
||||
}
|
||||
echo '<h2>' . __d('cake_dev', 'Running %s', $suite->getName()) . '</h2>';
|
||||
$this->_buffer .= '<h2>' . __d('cake_dev', 'Running %s', $suite->getName()) . '</h2>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
// @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
// +--------------------------------------------------------------------------------------------+ //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
2.10.6
|
||||
2.10.7
|
||||
|
|
Loading…
Reference in a new issue