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.3
|
||||||
- php: 7.4
|
- php: 7.4
|
||||||
- php: nightly
|
- php: nightly
|
||||||
|
install: travis_retry composer config platform.php 7.4.0 && composer require phpunit/phpunit:^7.5
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: nightly
|
- php: nightly
|
||||||
@@ -34,10 +35,10 @@ services:
|
|||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- mysql -e "create database IF NOT EXISTS test;" -uroot
|
- mysql -e "create database IF NOT EXISTS test;" -uroot
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- phpenv config-rm xdebug.ini || return 0
|
- phpenv config-rm xdebug.ini || return 0
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./phpunit.sh
|
- ./phpunit.sh
|
||||||
|
@@ -66,18 +66,33 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testError()
|
public function testError()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
$exceptionThrown = false;
|
||||||
$this->expectExceptionMessage("Undefined array key \"foo\"");
|
|
||||||
$this->expectException(PHPUnit_Framework_Error_Warning::class);
|
try {
|
||||||
} elseif (PHP_VERSION_ID >= 56000) {
|
$e1 = error_reporting();
|
||||||
$this->expectExceptionMessage("Undefined index: foo");
|
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
|
||||||
$this->expectException(PHPUnit_Framework_Error_Notice::class);
|
$e2 = error_reporting();
|
||||||
} else {
|
$this->assertEquals($e1, $e2);
|
||||||
return; // skip this test
|
} 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->assertTrue($exceptionThrown);
|
||||||
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
|
|
||||||
$e2 = error_reporting();
|
|
||||||
$this->assertEquals($e1, $e2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -404,9 +404,9 @@ class ConfigVarTest extends PHPUnit_Smarty
|
|||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
if (PHP_VERSION_ID >= 80000) {
|
||||||
$this->assertEquals('Undefined variable $foo', $e->getMessage());
|
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals('Undefined variable: foo', $e->getMessage());
|
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user