Skip to content

Commit

Permalink
Fix errors in php7.1
Browse files Browse the repository at this point in the history
* The constructor of errors has changed in PHP 7.1
* mcrypt is no longer available in PHP 7.1 by default.
  • Loading branch information
markstory committed Dec 5, 2016
1 parent caaf748 commit e3221b1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
Expand Up @@ -47,15 +47,14 @@ public function setUp() {
/**
* 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');
}
}

Expand Down
Expand Up @@ -207,6 +207,7 @@ public function testWriteSimple() {
* @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~#^';

Expand Down
5 changes: 2 additions & 3 deletions lib/Cake/Test/Case/Core/ConfigureTest.php
Expand Up @@ -449,17 +449,16 @@ public function testReaderSetup() {
/**
* test reader() throwing exceptions on missing interface.
*
* @expectedException PHPUnit_Framework_Error
* @throws PHPUnit_Framework_Error
* @return void
*/
public function testReaderExceptionOnIncorrectClass() {
$reader = new StdClass();

try {
Configure::config('test', $reader);
$this->fail('No error raised');
} catch (Throwable $t) {
throw new PHPUnit_Framework_Error($t);
$this->assertTrue(true, 'TypeError raised');
}
}

Expand Down
5 changes: 2 additions & 3 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -2908,15 +2908,14 @@ public function testSchema() {
/**
* 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');
}
}

Expand Down
5 changes: 2 additions & 3 deletions lib/Cake/Test/Case/Model/ModelValidationTest.php
Expand Up @@ -2223,15 +2223,14 @@ public function testValidatorOverride() {
/**
* 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');
}
}

Expand Down
5 changes: 5 additions & 0 deletions lib/Cake/Test/Case/Utility/SecurityTest.php
Expand Up @@ -328,6 +328,7 @@ public function testRijndaelInvalidKey() {
* @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);
Expand All @@ -342,6 +343,7 @@ public function testEncryptDecrypt() {
* @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);
Expand All @@ -356,6 +358,7 @@ public function testDecryptKeyFailure() {
* @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!';
Expand All @@ -372,6 +375,7 @@ public function testDecryptHmacFailure() {
* @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!';
Expand Down Expand Up @@ -400,6 +404,7 @@ public function testEncryptInvalidKey() {
* @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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/View.php
Expand Up @@ -564,7 +564,7 @@ public function renderCache($filename, $timeStart) {

$type = $response->mapType($response->type());
if (Configure::read('debug') > 0 && $type === 'html') {
echo "<!-- Cached Render Time: " . round(microtime(true) - $timeStart, 4) . "s -->";
echo "<!-- Cached Render Time: " . round(microtime(true) - (int)$timeStart, 4) . "s -->";
}
$out = ob_get_clean();

Expand Down

0 comments on commit e3221b1

Please sign in to comment.