From c3afe0bc9d9058fb1b49718a7ac0ea2cf3f1b3f3 Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 14 Apr 2017 12:16:33 +0200 Subject: [PATCH] Update for PHPunit >= 5 --- tests/Bootstrap.php | 13 +++++++---- tests/PHPUnit_Smarty.php | 3 ++- .../UndefinedTemplateVarTest.php | 10 ++++---- tests/phpunit.xml | 23 +++++++++++++------ 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index b5732256..7b2a5fe4 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -16,6 +16,7 @@ if (!class_exists('Smarty_Autoloader')) { throw new Exception('can not locate Smarty distribution'); } } + if (!defined('SMARTY_COMPOSER_INSTALL')) { foreach (array(dirname(__FILE__) . '/../../autoload.php', dirname(__FILE__) . '/../vendor/autoload.php', dirname(__FILE__) . '/vendor/autoload.php') as $file) { @@ -26,15 +27,19 @@ if (!defined('SMARTY_COMPOSER_INSTALL')) { } unset($file); } -if (!class_exists('PHPUnit_Framework_TestCase') && !class_exists('\PHPUnit\Framework\TestCase')) { +if (!class_exists('PHPUnit_Framework_TestCase') && !class_exists('\PHPUnit\Framework\TestCase')){ require_once SMARTY_COMPOSER_INSTALL; } + if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); + class_alias('\PHPUnit\Framework\Error\Notice', '\PHPUnit_Framework_Error_Notice'); + class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error_Error'); + class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning'); + class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Deprecated'); + class_alias('\PHPUnit\Util\Configuration', '\PHPUnit_Util_Configuration'); } -if (!class_exists('\PHPUnit_Framework_Error') && class_exists('\PHPUnit\Framework\Error')) { - class_alias('\PHPUnit\Framework\Error', '\PHPUnit_Framework_Error'); -} + require_once 'PHPUnit_Smarty.php'; if (!ini_get('date.timezone')) { ini_set('date.timezone', 'Europe/Berlin'); diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index 12e8d935..fdcd6897 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -249,7 +249,8 @@ KEY `expire` (`expire`) if (is_dir(self::$cwd . '/templates_tmp')) { $this->cleanDir(self::$cwd . '/templates_tmp'); } - } + $this->assertTrue(true); + } /** * Make temporary template file diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php index 1753b687..8a564cbc 100644 --- a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php @@ -61,14 +61,14 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty /** * Throw E_NOTICE message * - * @expectedException PHPUnit_Framework_Error + * @expectedException PHPUnit_Framework_Error_Notice * @expectedExceptionMessage Undefined index: foo */ public function testE_Notice() { - $e1 = error_reporting(); - $this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl')); - $e2 = error_reporting(); - $this->assertEquals($e1, $e2); + $e1 = error_reporting(); + $this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl')); + $e2 = error_reporting(); + $this->assertEquals($e1, $e2); } } diff --git a/tests/phpunit.xml b/tests/phpunit.xml index cdf9ee76..0e7d7f40 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,16 +1,24 @@ + stopOnError="false" + stopOnFailure="false" + stopOnIncomplete="false" + stopOnSkipped="false" + stopOnRisky="false" + timeoutForSmallTests="1" + timeoutForMediumTests="10" + timeoutForLargeTests="60" + verbose="false"> - + UnitTests @@ -29,7 +37,8 @@ - highlight="false" lowUpperBound="35" highLowerBound="70"/> +