From caaf7488839307d3e5e0a22d65e5350db355951d Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 5 Dec 2016 09:22:48 -0500 Subject: [PATCH 1/4] Add PHP7.1 to test matrix. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b43db1d25..2070d62da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 env: - DB=mysql @@ -22,7 +23,7 @@ matrix: - php: 5.4 env: DB=sqlite - - php: 5.4 + - php: 7.0 env: PHPCS=1 From e3221b1c383fb7f99f8aad0945aa303f2321d3b0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 5 Dec 2016 16:14:33 -0500 Subject: [PATCH 2/4] Fix errors in php7.1 * The constructor of errors has changed in PHP 7.1 * mcrypt is no longer available in PHP 7.1 by default. --- .../Controller/Component/Auth/ControllerAuthorizeTest.php | 5 ++--- .../Test/Case/Controller/Component/CookieComponentTest.php | 1 + lib/Cake/Test/Case/Core/ConfigureTest.php | 5 ++--- lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php | 5 ++--- lib/Cake/Test/Case/Model/ModelValidationTest.php | 5 ++--- lib/Cake/Test/Case/Utility/SecurityTest.php | 5 +++++ lib/Cake/View/View.php | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index b0f554bf4..ce92d6b14 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -47,15 +47,14 @@ class ControllerAuthorizeTest extends CakeTestCase { /** * testControllerTypeError * - * @expectedException PHPUnit_Framework_Error - * @throws PHPUnit_Framework_Error * @return void */ public function testControllerTypeError() { try { $this->auth->controller(new StdClass()); + $this->fail('No exception thrown'); } catch (Throwable $t) { - throw new PHPUnit_Framework_Error($t); + $this->assertTrue(true, 'Exception was raised'); } } diff --git a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php index 7d9365c84..18b70bafc 100644 --- a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php @@ -207,6 +207,7 @@ class CookieComponentTest extends CakeTestCase { * @return void */ public function testWriteWithFalseyValue() { + $this->skipIf(!extension_loaded('mcrypt'), 'No Mcrypt, skipping.'); $this->Cookie->type('aes'); $this->Cookie->key = 'qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#HKis~#^'; diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 6a1b4bbbd..d8d3e33b2 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -449,8 +449,6 @@ class ConfigureTest extends CakeTestCase { /** * test reader() throwing exceptions on missing interface. * - * @expectedException PHPUnit_Framework_Error - * @throws PHPUnit_Framework_Error * @return void */ public function testReaderExceptionOnIncorrectClass() { @@ -458,8 +456,9 @@ class ConfigureTest extends CakeTestCase { try { Configure::config('test', $reader); + $this->fail('No error raised'); } catch (Throwable $t) { - throw new PHPUnit_Framework_Error($t); + $this->assertTrue(true, 'TypeError raised'); } } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index ee9c0f57e..6dc888223 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -2908,15 +2908,14 @@ SQL; /** * testDropSchemaNoSchema method * - * @expectedException PHPUnit_Framework_Error - * @throws PHPUnit_Framework_Error * @return void */ public function testDropSchemaNoSchema() { try { $this->Dbo->dropSchema(null); + $this->fail('No exception'); } catch (Throwable $t) { - throw new PHPUnit_Framework_Error($t); + $this->assertTrue(true, 'Exception raised'); } } diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 1636f7a21..7f2a73e43 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -2223,15 +2223,14 @@ class ModelValidationTest extends BaseModelTest { /** * Test that type hint exception is thrown * - * @expectedException PHPUnit_Framework_Error - * @throws PHPUnit_Framework_Error * @return void */ public function testValidatorTypehintException() { try { new ModelValidator('asdasds'); + $this->fail('No exeption raised'); } catch (Throwable $t) { - throw new PHPUnit_Framework_Error($t); + $this->assertTrue(true, 'An error/exception was raised'); } } diff --git a/lib/Cake/Test/Case/Utility/SecurityTest.php b/lib/Cake/Test/Case/Utility/SecurityTest.php index 10aa1d4c3..fed0dce1f 100644 --- a/lib/Cake/Test/Case/Utility/SecurityTest.php +++ b/lib/Cake/Test/Case/Utility/SecurityTest.php @@ -328,6 +328,7 @@ class SecurityTest extends CakeTestCase { * @return void */ public function testEncryptDecrypt() { + $this->skipIf(!extension_loaded('mcrypt'), 'This test requires mcrypt to be installed'); $txt = 'The quick brown fox'; $key = 'This key is longer than 32 bytes long.'; $result = Security::encrypt($txt, $key); @@ -342,6 +343,7 @@ class SecurityTest extends CakeTestCase { * @return void */ public function testDecryptKeyFailure() { + $this->skipIf(!extension_loaded('mcrypt'), 'This test requires mcrypt to be installed'); $txt = 'The quick brown fox'; $key = 'This key is longer than 32 bytes long.'; Security::encrypt($txt, $key); @@ -356,6 +358,7 @@ class SecurityTest extends CakeTestCase { * @return void */ public function testDecryptHmacFailure() { + $this->skipIf(!extension_loaded('mcrypt'), 'This test requires mcrypt to be installed'); $txt = 'The quick brown fox'; $key = 'This key is quite long and works well.'; $salt = 'this is a delicious salt!'; @@ -372,6 +375,7 @@ class SecurityTest extends CakeTestCase { * @return void */ public function testDecryptHmacSaltFailure() { + $this->skipIf(!extension_loaded('mcrypt'), 'This test requires mcrypt to be installed'); $txt = 'The quick brown fox'; $key = 'This key is quite long and works well.'; $salt = 'this is a delicious salt!'; @@ -400,6 +404,7 @@ class SecurityTest extends CakeTestCase { * @return void */ public function testEncryptDecryptFalseyData() { + $this->skipIf(!extension_loaded('mcrypt'), 'This test requires mcrypt to be installed'); $key = 'This is a key that is long enough to be ok.'; $result = Security::encrypt('', $key); diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 4d28993e0..9c643fdc1 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -564,7 +564,7 @@ class View extends CakeObject { $type = $response->mapType($response->type()); if (Configure::read('debug') > 0 && $type === 'html') { - echo ""; + echo ""; } $out = ob_get_clean(); From 0a2a400ea42d73d4f9d111e5485646dfc91630b4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 6 Dec 2016 21:20:32 -0500 Subject: [PATCH 3/4] Fix type error tests to work in PHP5 & PHP7.1 Catch the TypeErrors that are raised and make the match the PHP5 behavior of a converted error. --- .../Controller/Component/Auth/ControllerAuthorizeTest.php | 5 +++-- lib/Cake/Test/Case/Core/ConfigureTest.php | 6 +++--- lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php | 5 +++-- lib/Cake/Test/Case/Model/ModelValidationTest.php | 5 +++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index ce92d6b14..3ed011262 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -47,14 +47,15 @@ class ControllerAuthorizeTest extends CakeTestCase { /** * testControllerTypeError * + * @expectedException PHPUnit_Framework_Error * @return void */ public function testControllerTypeError() { try { $this->auth->controller(new StdClass()); $this->fail('No exception thrown'); - } catch (Throwable $t) { - $this->assertTrue(true, 'Exception was raised'); + } catch (TypeError $e) { + throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); } } diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index d8d3e33b2..8a738fd30 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -449,6 +449,7 @@ class ConfigureTest extends CakeTestCase { /** * test reader() throwing exceptions on missing interface. * + * @expectedException PHPUnit_Framework_Error * @return void */ public function testReaderExceptionOnIncorrectClass() { @@ -456,9 +457,8 @@ class ConfigureTest extends CakeTestCase { try { Configure::config('test', $reader); - $this->fail('No error raised'); - } catch (Throwable $t) { - $this->assertTrue(true, 'TypeError raised'); + } catch (TypeError $e) { + throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); } } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 6dc888223..e4c28cae0 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -2908,14 +2908,15 @@ SQL; /** * testDropSchemaNoSchema method * + * @expectedException PHPUnit_Framework_Error * @return void */ public function testDropSchemaNoSchema() { try { $this->Dbo->dropSchema(null); $this->fail('No exception'); - } catch (Throwable $t) { - $this->assertTrue(true, 'Exception raised'); + } catch (TypeError $e) { + throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); } } diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 7f2a73e43..f00c1a250 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -2223,14 +2223,15 @@ class ModelValidationTest extends BaseModelTest { /** * Test that type hint exception is thrown * + * @expectedException PHPUnit_Framework_Error * @return void */ public function testValidatorTypehintException() { try { new ModelValidator('asdasds'); $this->fail('No exeption raised'); - } catch (Throwable $t) { - $this->assertTrue(true, 'An error/exception was raised'); + } catch (TypeError $e) { + throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); } } From 12cdc247ace5e2921d297d6ffd026b1bc306d0c3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 7 Dec 2016 00:38:55 -0500 Subject: [PATCH 4/4] Fix PHPCS errors. --- .../Case/Controller/Component/Auth/ControllerAuthorizeTest.php | 1 + lib/Cake/Test/Case/Core/ConfigureTest.php | 1 + lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php | 1 + lib/Cake/Test/Case/Model/ModelValidationTest.php | 1 + 4 files changed, 4 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index 3ed011262..6bf7b1026 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -49,6 +49,7 @@ class ControllerAuthorizeTest extends CakeTestCase { * * @expectedException PHPUnit_Framework_Error * @return void + * @throws PHPUnit_Framework_Error */ public function testControllerTypeError() { try { diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 8a738fd30..d4457e21b 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -451,6 +451,7 @@ class ConfigureTest extends CakeTestCase { * * @expectedException PHPUnit_Framework_Error * @return void + * @throws PHPUnit_Framework_Error */ public function testReaderExceptionOnIncorrectClass() { $reader = new StdClass(); diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index e4c28cae0..9577bad34 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -2910,6 +2910,7 @@ SQL; * * @expectedException PHPUnit_Framework_Error * @return void + * @throws PHPUnit_Framework_Error */ public function testDropSchemaNoSchema() { try { diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index f00c1a250..3eee85c28 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -2225,6 +2225,7 @@ class ModelValidationTest extends BaseModelTest { * * @expectedException PHPUnit_Framework_Error * @return void + * @throws PHPUnit_Framework_Error */ public function testValidatorTypehintException() { try {