mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
Fix unit tests for php8, force composer to think we are still php7 to pick a supported phpunit and being less specific about an error msg because PHP8 is in active development and the exact wording is changing.
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user