mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-24 23:16:26 +00:00
Prepare IntegrationTestCase for static data providers
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
* Mark `Twig\Test\NodeTestCase::getEnvironment()` as final, override `createEnvironment()` instead.
|
||||
* Deprecate `Twig\Test\NodeTestCase::getVariableGetter()`, call `createVariableGetter()` instead.
|
||||
* Deprecate `Twig\Test\NodeTestCase::getAttributeGetter()`, call `createAttributeGetter()` instead.
|
||||
* Deprecate not overriding `Twig\Test\IntegrationTestCase::getFixturesDirectory()`, this method will be abstract in 4.0
|
||||
* Marked `Twig\Test\IntegrationTestCase::getTests()` and `getLegacyTests()` as final
|
||||
|
||||
# 3.12.0 (2024-08-29)
|
||||
|
||||
|
||||
@@ -216,3 +216,10 @@ Testing Utilities
|
||||
* The method ``Twig\Test\NodeTestCase::getEnvironment()`` is considered final
|
||||
as of Twig 3.13. If you want to override how the Twig environment is
|
||||
constructed, override ``createEnvironment()`` instead.
|
||||
|
||||
* The method ``getFixturesDir()`` on ``Twig\Test\IntegrationTestCase`` is
|
||||
deprecated, implement the new static method ``getFixturesDirectory()``
|
||||
instead, which will be abstract in 4.0.
|
||||
|
||||
* The data providers ``getTests()`` and ``getLegacyTests()`` on
|
||||
``Twig\Test\IntegrationTestCase`` are considered final als of Twig 3.13.
|
||||
|
||||
@@ -38,7 +38,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"require": {
|
||||
"php": ">=8.0.2",
|
||||
"symfony/cache": "^5.4|^6.4|^7.0",
|
||||
"twig/twig": "^3.12|^4.0"
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"php": ">=8.0.2",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"tijsverkoyen/css-to-inline-styles": "^2.0",
|
||||
"twig/twig": "^3.0|^4.0"
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"php": ">=8.0.2",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"symfony/mime": "^5.4|^6.4|^7.0",
|
||||
"twig/twig": "^3.0|^4.0"
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"php": ">=8.0.2",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"lorenzo/pinky": "^1.0.5",
|
||||
"twig/twig": "^3.0|^4.0"
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.0.2",
|
||||
"twig/twig": "^3.10|^4.0",
|
||||
"twig/twig": "^3.13|^4.0",
|
||||
"symfony/intl": "^5.4|^6.4|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"require": {
|
||||
"php": ">=8.0.2",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"twig/twig": "^3.0|^4.0"
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0",
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"php": ">=8.0.2",
|
||||
"symfony/string": "^5.4|^6.4|^7.0",
|
||||
"symfony/translation-contracts": "^1.1|^2|^3",
|
||||
"twig/twig": "^3.0|^4.0"
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
|
||||
@@ -30,9 +30,18 @@ use Twig\TwigTest;
|
||||
abstract class IntegrationTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @deprecated since Twig 3.13, use getFixturesDirectory() instead.
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getFixturesDir();
|
||||
protected function getFixturesDir()
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RuntimeLoaderInterface[]
|
||||
@@ -92,9 +101,19 @@ abstract class IntegrationTestCase extends TestCase
|
||||
$this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @final since Twig 3.13
|
||||
*/
|
||||
public function getTests($name, $legacyTests = false)
|
||||
{
|
||||
$fixturesDir = realpath($this->getFixturesDir());
|
||||
try {
|
||||
$fixturesDir = static::getFixturesDirectory();
|
||||
} catch (\BadMethodCallException) {
|
||||
trigger_deprecation('twig/twig', '3.13', 'Not overriding "%s::getFixturesDirectory()" in "%s" is deprecated. This method will be abstract in 4.0.', self::class, static::class);
|
||||
$fixturesDir = $this->getFixturesDir();
|
||||
}
|
||||
|
||||
$fixturesDir = realpath($fixturesDir);
|
||||
$tests = [];
|
||||
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($fixturesDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
@@ -137,6 +156,9 @@ abstract class IntegrationTestCase extends TestCase
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @final since Twig 3.13
|
||||
*/
|
||||
public function getLegacyTests()
|
||||
{
|
||||
return $this->getTests('testLegacyIntegration', true);
|
||||
|
||||
@@ -48,7 +48,7 @@ class IntegrationTest extends IntegrationTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
protected static function getFixturesDirectory(): string
|
||||
{
|
||||
return __DIR__.'/Fixtures/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user