mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-14 10:58:24 +00:00
Fix failures on PHP 7.4. Run phpcs on PHP 7.0
This commit is contained in:
parent
b56ea15eba
commit
49bbc21e1d
9 changed files with 40 additions and 62 deletions
10
.travis.yml
10
.travis.yml
|
@ -1,5 +1,6 @@
|
|||
language: php
|
||||
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
php:
|
||||
|
@ -8,7 +9,7 @@ php:
|
|||
- 7.4
|
||||
|
||||
env:
|
||||
matrix:
|
||||
jobs:
|
||||
- DB=mysql
|
||||
global:
|
||||
- PHPUNIT=5.7.19
|
||||
|
@ -19,7 +20,7 @@ services:
|
|||
- postgresql
|
||||
- mysql
|
||||
|
||||
matrix:
|
||||
jobs:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 5.3
|
||||
|
@ -41,12 +42,9 @@ matrix:
|
|||
- php: 7.3
|
||||
env: DB=sqlite
|
||||
|
||||
- php: 7.2
|
||||
- php: 7.0
|
||||
env: PHPCS=1
|
||||
|
||||
allow_failures:
|
||||
- php: 7.4
|
||||
|
||||
before_script:
|
||||
- if [[ ${TRAVIS_PHP_VERSION:0:3} =~ ^7\.[234]$ ]] ; then pear config-set preferred_state snapshot && yes "" | pecl install mcrypt ; fi
|
||||
- composer require "phpunit/phpunit=$PHPUNIT"
|
||||
|
|
|
@ -223,7 +223,7 @@ class ShellDispatcher {
|
|||
}
|
||||
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
|
||||
$added = in_array($command, $methods);
|
||||
$private = $command[0] === '_' && method_exists($Shell, $command);
|
||||
$private = substr($command, 0, 1) === '_' && method_exists($Shell, $command);
|
||||
|
||||
if (!$private) {
|
||||
if ($added) {
|
||||
|
|
|
@ -179,7 +179,6 @@ class Sqlite extends DboSource {
|
|||
);
|
||||
|
||||
foreach ($result as $column) {
|
||||
$column = (array)$column;
|
||||
$default = ($column['dflt_value'] === 'NULL') ? null : trim($column['dflt_value'], "'");
|
||||
|
||||
$fields[$column['name']] = array(
|
||||
|
|
|
@ -1358,7 +1358,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || $data[$val][0] === '-')) {
|
||||
if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || substr($data[$val], 0, 1) === '-')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1991,7 +1991,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*/
|
||||
protected function _isUUIDField($field) {
|
||||
$field = $this->schema($field);
|
||||
return $field['length'] == 36 && in_array($field['type'], array('string', 'binary', 'uuid'));
|
||||
return $field !== null && $field['length'] == 36 && in_array($field['type'], array('string', 'binary', 'uuid'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -189,8 +189,12 @@ class CacheTest extends CakeTestCase {
|
|||
$result = Cache::config('tests', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||
$this->assertEquals(Cache::settings('tests'), $result['settings']);
|
||||
|
||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||
Cache::config('tests', $_cacheConfigTests['settings']);
|
||||
if ($_cacheConfigSessions !== false) {
|
||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||
}
|
||||
if ($_cacheConfigTests !== false) {
|
||||
Cache::config('tests', $_cacheConfigTests['settings']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -356,41 +356,6 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildColumn method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildColumn() {
|
||||
$restore = $this->Dbo->columns;
|
||||
$this->Dbo->columns = array('varchar(255)' => 1);
|
||||
$data = array(
|
||||
'name' => 'testName',
|
||||
'type' => 'varchar(255)',
|
||||
'default',
|
||||
'null' => true,
|
||||
'key',
|
||||
'comment' => 'test'
|
||||
);
|
||||
$result = $this->Dbo->buildColumn($data);
|
||||
$expected = '`testName` DEFAULT NULL COMMENT \'test\'';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$data = array(
|
||||
'name' => 'testName',
|
||||
'type' => 'varchar(255)',
|
||||
'default',
|
||||
'null' => true,
|
||||
'key',
|
||||
'charset' => 'utf8',
|
||||
'collate' => 'utf8_unicode_ci'
|
||||
);
|
||||
$result = $this->Dbo->buildColumn($data);
|
||||
$expected = '`testName` CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL';
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->Dbo->columns = $restore;
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL 4.x returns index data in a different format,
|
||||
* Using a mock ensure that MySQL 4.x output is properly parsed.
|
||||
|
@ -3166,7 +3131,7 @@ SQL;
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildColumn2() {
|
||||
public function testBuildColumn() {
|
||||
$data = array(
|
||||
'name' => 'testName',
|
||||
'type' => 'string',
|
||||
|
|
|
@ -7975,7 +7975,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->request->data['Contact']['published'] = '';
|
||||
$this->Form->request->data['Contact']['published'] = '';
|
||||
$result = $this->Form->year('Contact.published', 2006, 2007, array('class' => 'year'));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Contact][published][year]', 'id' => 'ContactPublishedYear', 'class' => 'year')),
|
||||
|
|
|
@ -245,7 +245,11 @@ class RssHelperTest extends CakeTestCase {
|
|||
array('title' => 'title3', 'guid' => 'http://www.example.com/guid3', 'link' => 'http://www.example.com/link3', 'description' => 'description3')
|
||||
);
|
||||
|
||||
$result = $this->Rss->items($items, create_function('$v', '$v[\'title\'] = $v[\'title\'] . \'-transformed\'; return $v;'));
|
||||
$result = $this->Rss->items($items, function ($v) {
|
||||
$v['title'] = $v['title'] . '-transformed';
|
||||
|
||||
return $v;
|
||||
});
|
||||
$expected = array(
|
||||
'<item',
|
||||
'<title', 'title1-transformed', '/title',
|
||||
|
|
|
@ -1495,13 +1495,13 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test setting a block's content to an object without __toString magic method
|
||||
*
|
||||
* This should produce a "Object of class TestObjectWithoutToString could not be converted to string" error
|
||||
* which gets thrown as a PHPUnit_Framework_Error Exception by PHPUnit.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testBlockSetObjectWithoutToString() {
|
||||
$this->_checkException(
|
||||
'Object of class TestObjectWithoutToString could not be converted to string'
|
||||
);
|
||||
|
||||
$objectWithToString = new TestObjectWithoutToString();
|
||||
$this->View->assign('testWithObjectWithoutToString', $objectWithToString);
|
||||
}
|
||||
|
@ -1547,13 +1547,13 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test appending an object without __toString magic method to a block with append.
|
||||
*
|
||||
* This should produce a "Object of class TestObjectWithoutToString could not be converted to string" error
|
||||
* which gets thrown as a PHPUnit_Framework_Error Exception by PHPUnit.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testBlockAppendObjectWithoutToString() {
|
||||
$this->_checkException(
|
||||
'Object of class TestObjectWithoutToString could not be converted to string'
|
||||
);
|
||||
|
||||
$object = new TestObjectWithoutToString();
|
||||
$this->View->assign('testBlock', 'Block ');
|
||||
$this->View->append('testBlock', $object);
|
||||
|
@ -1576,13 +1576,13 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test prepending an object without __toString magic method to a block with prepend.
|
||||
*
|
||||
* This should produce a "Object of class TestObjectWithoutToString could not be converted to string" error
|
||||
* which gets thrown as a PHPUnit_Framework_Error Exception by PHPUnit.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testBlockPrependObjectWithoutToString() {
|
||||
$this->_checkException(
|
||||
'Object of class TestObjectWithoutToString could not be converted to string'
|
||||
);
|
||||
|
||||
$object = new TestObjectWithoutToString();
|
||||
$this->View->assign('test', 'Block ');
|
||||
$this->View->prepend('test', $object);
|
||||
|
@ -1839,4 +1839,12 @@ TEXT;
|
|||
$result = $this->View->get('title', $default);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
protected function _checkException($message) {
|
||||
if (version_compare(PHP_VERSION, '7.4', '>=')) {
|
||||
$this->setExpectedException('Error', $message);
|
||||
} else {
|
||||
$this->setExpectedException('PHPUnit_Framework_Error', $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue