mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Switch to static data provides for integration tests
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Twig\Test;
|
namespace Twig\Test;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
|
||||||
use PHPUnit\Framework\Constraint\Exception;
|
use PHPUnit\Framework\Constraint\Exception;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
@@ -75,6 +77,7 @@ abstract class IntegrationTestCase extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getTests
|
* @dataProvider getTests
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('getTests')]
|
||||||
public function testIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '')
|
public function testIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '')
|
||||||
{
|
{
|
||||||
$this->doIntegrationTest($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
|
* @group legacy
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('getLegacyTests'), IgnoreDeprecations]
|
||||||
public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '')
|
public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '')
|
||||||
{
|
{
|
||||||
$this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation);
|
$this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static function assembleTests(bool $legacyTests): array
|
||||||
* @final since Twig 3.13
|
|
||||||
*/
|
|
||||||
public function getTests($name, $legacyTests = false)
|
|
||||||
{
|
{
|
||||||
$fixturesDir = static::getFixturesDirectory();
|
$fixturesDir = static::getFixturesDirectory();
|
||||||
$fixturesDir = realpath($fixturesDir);
|
$fixturesDir = realpath($fixturesDir);
|
||||||
@@ -139,12 +140,14 @@ abstract class IntegrationTestCase extends TestCase
|
|||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
final public static function getTests(): array
|
||||||
* @final since Twig 3.13
|
|
||||||
*/
|
|
||||||
public function getLegacyTests()
|
|
||||||
{
|
{
|
||||||
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 = '')
|
protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '')
|
||||||
|
|||||||
Reference in New Issue
Block a user