diff --git a/.travis.yml b/.travis.yml index 69b76018..dd03b40e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ jobs: - php: 7.3 - php: 7.4 - php: nightly + install: travis_retry composer config platform.php 7.4.0 && composer require phpunit/phpunit:^7.5 fast_finish: true allow_failures: - php: nightly @@ -34,10 +35,10 @@ services: - mysql before_script: - - mysql -e "create database IF NOT EXISTS test;" -uroot + - mysql -e "create database IF NOT EXISTS test;" -uroot before_install: - - phpenv config-rm xdebug.ini || return 0 + - phpenv config-rm xdebug.ini || return 0 script: - - ./phpunit.sh + - ./phpunit.sh diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php index a23d6aa0..64fb9c00 100644 --- a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php @@ -66,18 +66,33 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty */ public function testError() { - if (PHP_VERSION_ID >= 80000) { - $this->expectExceptionMessage("Undefined array key \"foo\""); - $this->expectException(PHPUnit_Framework_Error_Warning::class); - } elseif (PHP_VERSION_ID >= 56000) { - $this->expectExceptionMessage("Undefined index: foo"); - $this->expectException(PHPUnit_Framework_Error_Notice::class); - } else { - return; // skip this test + $exceptionThrown = false; + + try { + $e1 = error_reporting(); + $this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl')); + $e2 = error_reporting(); + $this->assertEquals($e1, $e2); + } catch (Exception $e) { + + $exceptionThrown = true; + + if (PHP_VERSION_ID >= 80000) { + $this->assertStringStartsWith('Undefined array key', $e->getMessage()); + } else { + $this->assertStringStartsWith('Undefined index', $e->getMessage()); + } + + $this->assertTrue(in_array( + get_class($e), + array( + 'PHPUnit_Framework_Error_Warning', + 'PHPUnit_Framework_Error_Notice', + 'PHPUnit\Framework\Error\Warning', + 'PHPUnit\Framework\Error\Notice', + ) + )); } - $e1 = error_reporting(); - $this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl')); - $e2 = error_reporting(); - $this->assertEquals($e1, $e2); + $this->assertTrue($exceptionThrown); } } diff --git a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php index 24a2a0e8..41faf101 100644 --- a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php +++ b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php @@ -404,9 +404,9 @@ class ConfigVarTest extends PHPUnit_Smarty } catch (Exception $e) { if (PHP_VERSION_ID >= 80000) { - $this->assertEquals('Undefined variable $foo', $e->getMessage()); + $this->assertStringStartsWith('Undefined variable', $e->getMessage()); } else { - $this->assertEquals('Undefined variable: foo', $e->getMessage()); + $this->assertStringStartsWith('Undefined variable', $e->getMessage()); } } }