From 9282dbcc42b897b4f3c4dacbd767d1e7b1ff1b75 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 3 Sep 2024 22:48:59 +0200 Subject: [PATCH] Switch to static data provides for integration tests --- src/Test/IntegrationTestCase.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Test/IntegrationTestCase.php b/src/Test/IntegrationTestCase.php index 4a7030e46..9ae7241a9 100644 --- a/src/Test/IntegrationTestCase.php +++ b/src/Test/IntegrationTestCase.php @@ -11,6 +11,8 @@ namespace Twig\Test; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Constraint\Exception; use PHPUnit\Framework\TestCase; use Twig\Environment; @@ -75,6 +77,7 @@ abstract class IntegrationTestCase extends TestCase /** * @dataProvider getTests */ + #[DataProvider('getTests')] public function testIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '') { $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation); @@ -85,15 +88,13 @@ abstract class IntegrationTestCase extends TestCase * * @group legacy */ + #[DataProvider('getLegacyTests'), IgnoreDeprecations] public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '') { $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation); } - /** - * @final since Twig 3.13 - */ - public function getTests($name, $legacyTests = false) + private static function assembleTests(bool $legacyTests): array { $fixturesDir = static::getFixturesDirectory(); $fixturesDir = realpath($fixturesDir); @@ -139,12 +140,14 @@ abstract class IntegrationTestCase extends TestCase return $tests; } - /** - * @final since Twig 3.13 - */ - public function getLegacyTests() + final public static function getTests(): array { - return $this->getTests('testLegacyIntegration', true); + return self::assembleTests(false); + } + + final public static function getLegacyTests(): array + { + return self::assembleTests(true); } protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '')