mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-11 18:06:46 +00:00
Add PHPUnit attributes alongside annotations to silence doc-comment metadata deprecations on PHPUnit 11
This commit is contained in:
@@ -20,6 +20,7 @@ namespace Twig\Tests\Cache;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Cache\ChainCache;
|
||||
use Twig\Cache\FilesystemCache;
|
||||
@@ -215,6 +216,7 @@ class ChainTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideInput
|
||||
*/
|
||||
#[DataProvider('provideInput')]
|
||||
public function testGenerateKey($expected, $input)
|
||||
{
|
||||
$cache = new ChainCache([]);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Cache;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Cache\FilesystemCache;
|
||||
use Twig\Tests\FilesystemHelper;
|
||||
@@ -174,6 +175,7 @@ class FilesystemTest extends TestCase
|
||||
*
|
||||
* @dataProvider provideDirectories
|
||||
*/
|
||||
#[DataProvider('provideDirectories')]
|
||||
public function testGenerateKey($expected, $input)
|
||||
{
|
||||
$cache = new FilesystemCache($input);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Cache;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Cache\ReadOnlyFilesystemCache;
|
||||
use Twig\Tests\FilesystemHelper;
|
||||
@@ -112,6 +113,7 @@ class ReadOnlyFilesystemTest extends TestCase
|
||||
*
|
||||
* @dataProvider provideDirectories
|
||||
*/
|
||||
#[DataProvider('provideDirectories')]
|
||||
public function testGenerateKey($expected, $input)
|
||||
{
|
||||
$cache = new ReadOnlyFilesystemCache($input);
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\ExtensionInterface;
|
||||
@@ -32,6 +34,7 @@ class CustomExtensionTest extends TestCase
|
||||
*
|
||||
* @dataProvider provideInvalidExtensions
|
||||
*/
|
||||
#[DataProvider('provideInvalidExtensions'), Group('legacy')]
|
||||
public function testGetInvalidOperators(ExtensionInterface $extension, $expectedExceptionMessage)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader());
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\DeprecatedCallableInfo;
|
||||
|
||||
@@ -28,6 +29,7 @@ class DeprecatedCallableInfoTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideTestsForTriggerDeprecation
|
||||
*/
|
||||
#[DataProvider('provideTestsForTriggerDeprecation')]
|
||||
public function testTriggerDeprecation($expected, DeprecatedCallableInfo $info)
|
||||
{
|
||||
$info->setType('function');
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Cache\CacheInterface;
|
||||
@@ -462,9 +463,8 @@ class EnvironmentTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*
|
||||
* @requires PHP 8
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testLegacyEchoingNode()
|
||||
{
|
||||
$loader = new ArrayLoader(['echo_bar' => 'A{% set v %}B{% test %}C{% endset %}D{% test %}E{{ v }}F{% set w %}{% test %}{% endset %}G{{ w }}H']);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Attribute\YieldReady;
|
||||
use Twig\Compiler;
|
||||
@@ -144,6 +145,7 @@ EOHTML,
|
||||
/**
|
||||
* @dataProvider getErroredTemplates
|
||||
*/
|
||||
#[DataProvider('getErroredTemplates')]
|
||||
public function testTwigExceptionAddsFileAndLine($templates, $name, $line)
|
||||
{
|
||||
$loader = new ArrayLoader($templates);
|
||||
@@ -272,6 +274,7 @@ EOHTML,
|
||||
/**
|
||||
* @dataProvider getErrorWithoutLineAndContextData
|
||||
*/
|
||||
#[DataProvider('getErrorWithoutLineAndContextData')]
|
||||
public function testErrorWithoutLineAndContext(LoaderInterface $loader, bool $debug, bool $addDebugInfo, bool $exceptionWithLineAndContext, int $errorLine)
|
||||
{
|
||||
$twig = new Environment($loader, ['debug' => $debug, 'cache' => false]);
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Attribute\FirstClassTwigCallableReady;
|
||||
@@ -56,6 +58,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getFailingTestsForAssignment
|
||||
*/
|
||||
#[DataProvider('getFailingTestsForAssignment')]
|
||||
public function testCanOnlyAssignToNames($template)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
|
||||
@@ -86,6 +89,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestsForSequence
|
||||
*/
|
||||
#[DataProvider('getTestsForSequence')]
|
||||
public function testSequenceExpression($template, $expected)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
|
||||
@@ -99,6 +103,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getFailingTestsForSequence
|
||||
*/
|
||||
#[DataProvider('getFailingTestsForSequence')]
|
||||
public function testSequenceSyntaxError($template)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
|
||||
@@ -247,6 +252,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestsForString
|
||||
*/
|
||||
#[DataProvider('getTestsForString')]
|
||||
public function testStringExpression($template, $expected)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
@@ -304,6 +310,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestsForNullSafeOperator
|
||||
*/
|
||||
#[DataProvider('getTestsForNullSafeOperator')]
|
||||
public function testNullSafeOperator($template, $data, $expected)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(['template' => $template]), ['strict_variables' => true]);
|
||||
@@ -376,6 +383,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestForInvalidNullSafeOperatorShortCircuiting
|
||||
*/
|
||||
#[DataProvider('getTestForInvalidNullSafeOperatorShortCircuiting')]
|
||||
public function testInvalidNullSafeOperatorShortCircuiting(string $template, array $data, string $expectedMessage)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(['template' => $template]), ['strict_variables' => true]);
|
||||
@@ -414,6 +422,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getMacroDefinitionDoesNotSupportNonConstantDefaultValues
|
||||
*/
|
||||
#[DataProvider('getMacroDefinitionDoesNotSupportNonConstantDefaultValues')]
|
||||
public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
|
||||
@@ -436,6 +445,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getMacroDefinitionSupportsConstantDefaultValues
|
||||
*/
|
||||
#[DataProvider('getMacroDefinitionSupportsConstantDefaultValues')]
|
||||
public function testMacroDefinitionSupportsConstantDefaultValues($template)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
|
||||
@@ -606,6 +616,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNotReadyFunction()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.12: Twig node "Twig\Tests\NotReadyFunctionExpression" is not marked as ready for passing a "TwigFunction" in the constructor instead of its name; please update your code and then add #[FirstClassTwigCallableReady] attribute to the constructor.');
|
||||
@@ -621,6 +632,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNotReadyFilter()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.12: Twig node "Twig\Tests\NotReadyFilterExpression" is not marked as ready for passing a "TwigFilter" in the constructor instead of its name; please update your code and then add #[FirstClassTwigCallableReady] attribute to the constructor.');
|
||||
@@ -636,6 +648,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNotReadyTest()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.12: Twig node "Twig\Tests\NotReadyTestExpression" is not marked as ready for passing a "TwigTest" in the constructor instead of its name; please update your code and then add #[FirstClassTwigCallableReady] attribute to the constructor.');
|
||||
@@ -716,6 +729,7 @@ class ExpressionParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getBindingPowerTests
|
||||
*/
|
||||
#[DataProvider('getBindingPowerTests')]
|
||||
public function testBindingPower(string $expression, string $expectedExpression, mixed $expectedResult, array $context = [])
|
||||
{
|
||||
$env = new Environment(new ArrayLoader([
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\DeprecatedCallableInfo;
|
||||
use Twig\Error\RuntimeError;
|
||||
@@ -28,6 +29,7 @@ class AttributeExtensionTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideFilters
|
||||
*/
|
||||
#[DataProvider('provideFilters')]
|
||||
public function testFilter(string $name, string $method, array $options)
|
||||
{
|
||||
$extension = new AttributeExtension(ExtensionWithAttributes::class);
|
||||
@@ -57,6 +59,7 @@ class AttributeExtensionTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideFunctions
|
||||
*/
|
||||
#[DataProvider('provideFunctions')]
|
||||
public function testFunction(string $name, string $method, array $options)
|
||||
{
|
||||
$extension = new AttributeExtension(ExtensionWithAttributes::class);
|
||||
@@ -86,6 +89,7 @@ class AttributeExtensionTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideTests
|
||||
*/
|
||||
#[DataProvider('provideTests')]
|
||||
public function testTest(string $name, string $method, array $options)
|
||||
{
|
||||
$extension = new AttributeExtension(ExtensionWithAttributes::class);
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests\Extension;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Environment;
|
||||
@@ -37,6 +39,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideCycleCases
|
||||
*/
|
||||
#[DataProvider('provideCycleCases')]
|
||||
public function testCycleFunction($values, $position, $expected)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::cycle($values, $position));
|
||||
@@ -60,6 +63,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideCycleInvalidCases
|
||||
*/
|
||||
#[DataProvider('provideCycleInvalidCases')]
|
||||
public function testCycleFunctionThrowRuntimeError($values, mixed $position = null)
|
||||
{
|
||||
$this->expectException(RuntimeError::class);
|
||||
@@ -78,6 +82,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getRandomFunctionTestData
|
||||
*/
|
||||
#[DataProvider('getRandomFunctionTestData')]
|
||||
public function testRandomFunction(array $expectedInArray, $value1, $value2 = null)
|
||||
{
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
@@ -178,6 +183,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideTwigFirstCases
|
||||
*/
|
||||
#[DataProvider('provideTwigFirstCases')]
|
||||
public function testTwigFirst($expected, $input)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::first('UTF-8', $input));
|
||||
@@ -199,6 +205,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideTwigLastCases
|
||||
*/
|
||||
#[DataProvider('provideTwigLastCases')]
|
||||
public function testTwigLast($expected, $input)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::last('UTF-8', $input));
|
||||
@@ -220,6 +227,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideArrayKeyCases
|
||||
*/
|
||||
#[DataProvider('provideArrayKeyCases')]
|
||||
public function testArrayKeysFilter(array $expected, $input)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::keys($input));
|
||||
@@ -243,6 +251,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideInFilterCases
|
||||
*/
|
||||
#[DataProvider('provideInFilterCases')]
|
||||
public function testInFilter($expected, $value, $compare)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::inFilter($value, $compare));
|
||||
@@ -271,6 +280,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideSliceFilterCases
|
||||
*/
|
||||
#[DataProvider('provideSliceFilterCases')]
|
||||
public function testSliceFilter($expected, $input, $start, $length = null, $preserveKeys = false)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::slice('UTF-8', $input, $start, $length, $preserveKeys));
|
||||
@@ -300,6 +310,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideCompareCases
|
||||
*/
|
||||
#[DataProvider('provideCompareCases')]
|
||||
public function testCompare($expected, $a, $b)
|
||||
{
|
||||
$this->assertSame($expected, CoreExtension::compare($a, $b));
|
||||
@@ -414,6 +425,7 @@ class CoreTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testCycleWithArrayAccessAndTraversableButNotCountable()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.12: Passing a non-countable sequence of values to "Twig\Extension\CoreExtension::cycle()" is deprecated.');
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\EscaperExtension;
|
||||
@@ -34,6 +36,7 @@ class EscaperTest extends TestCase
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
#[DataProvider('provideCustomEscaperCases'), Group('legacy')]
|
||||
public function testCustomEscaper($expected, $string, $strategy)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader());
|
||||
@@ -56,6 +59,7 @@ class EscaperTest extends TestCase
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
#[DataProvider('provideCustomEscaperCases'), Group('legacy')]
|
||||
public function testCustomEscaperWithoutCallingSetEscaperRuntime($expected, $string, $strategy)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader());
|
||||
@@ -67,6 +71,7 @@ class EscaperTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testCustomEscapersOnMultipleEnvs()
|
||||
{
|
||||
$env1 = new Environment(new ArrayLoader());
|
||||
@@ -84,6 +89,7 @@ class EscaperTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSafeClassesUseCustomRuntimeLoader()
|
||||
{
|
||||
$runtime = new EscaperRuntime();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\DebugExtension;
|
||||
@@ -19,6 +20,7 @@ use Twig\Loader\ArrayLoader;
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
class LegacyDebugFunctionsTest extends TestCase
|
||||
{
|
||||
public function testDump()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\StringLoaderExtension;
|
||||
@@ -19,6 +20,7 @@ use Twig\Loader\ArrayLoader;
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
class LegacyStringLoaderFunctionsTest extends TestCase
|
||||
{
|
||||
public function testTemplateFromString()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Environment;
|
||||
@@ -102,6 +103,7 @@ class SandboxStateChangeTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicyDecisionFlip()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -197,6 +199,7 @@ class SandboxStateChangeTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSandboxTagAroundIncludeOfPreWarmedTemplate()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.15: The "sandbox" tag is deprecated in "wrapper" at line 1.');
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests\Extension;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Environment;
|
||||
@@ -99,6 +101,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getSandboxedForCoreTagsTests
|
||||
*/
|
||||
#[DataProvider('getSandboxedForCoreTagsTests')]
|
||||
public function testSandboxForCoreTags(string $tag, string $template)
|
||||
{
|
||||
$twig = $this->getEnvironment(true, [], self::$templates, []);
|
||||
@@ -137,6 +140,7 @@ class SandboxTest extends TestCase
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
#[DataProvider('getSandboxedForExtendsAndUseTagsTests'), Group('legacy')]
|
||||
public function testSandboxForExtendsAndUseTags(string $tag, string $template)
|
||||
{
|
||||
$this->expectDeprecation(\sprintf('Since twig/twig 3.12: The "%s" tag is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitly in your sandbox policy if needed (or enable strict mode on the security policy to opt-in to the 4.0 behavior now).', $tag));
|
||||
@@ -156,6 +160,7 @@ class SandboxTest extends TestCase
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
#[DataProvider('getSandboxedForParserCallableFunctionsTests'), Group('legacy')]
|
||||
public function testSandboxForParserCallableFunctions(string $function, string $templateName, array $extraTemplates, array $allowedTags, array $allowedMethods, array $allowedProperties, array $context, string $expected)
|
||||
{
|
||||
$this->expectDeprecation(\sprintf('Since twig/twig 3.27: The "%s" function is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitly in your sandbox policy if needed (or enable strict mode on the security policy to opt-in to the 4.0 behavior now).', $function));
|
||||
@@ -216,6 +221,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getAllowedParserCallableFunctionsTests
|
||||
*/
|
||||
#[DataProvider('getAllowedParserCallableFunctionsTests')]
|
||||
public function testSandboxWithAllowedParserCallableFunctions(string $templateName, array $extraTemplates, array $allowedTags, array $allowedMethods, array $allowedProperties, array $allowedFunctions, array $context, string $expected)
|
||||
{
|
||||
$twig = $this->getEnvironment(true, [], $extraTemplates, $allowedTags, [], $allowedMethods, $allowedProperties, $allowedFunctions);
|
||||
@@ -255,6 +261,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getStrictSandboxRejectsGrandfatheredTagsTests
|
||||
*/
|
||||
#[DataProvider('getStrictSandboxRejectsGrandfatheredTagsTests')]
|
||||
public function testStrictSandboxRejectsGrandfatheredTags(string $tag, string $template)
|
||||
{
|
||||
$twig = $this->getEnvironment(true, [], self::$templates, [], [], [], [], [], null, true);
|
||||
@@ -274,6 +281,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getStrictSandboxRejectsGrandfatheredFunctionsTests
|
||||
*/
|
||||
#[DataProvider('getStrictSandboxRejectsGrandfatheredFunctionsTests')]
|
||||
public function testStrictSandboxRejectsGrandfatheredFunctions(string $function, string $templateName, array $extraTemplates, array $allowedTags, array $context)
|
||||
{
|
||||
$twig = $this->getEnvironment(true, [], $extraTemplates, $allowedTags, [], [], [], [], null, true);
|
||||
@@ -391,6 +399,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideNonStringArrayAccessKeys
|
||||
*/
|
||||
#[DataProvider('provideNonStringArrayAccessKeys')]
|
||||
public function testSandboxNonStringKeyAccessDoesNotTriggerImplicitConversionDeprecation(string $template, string $expectedKey)
|
||||
{
|
||||
$loader = new ArrayLoader(['t' => $template]);
|
||||
@@ -449,6 +458,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testIfSandBoxIsDisabledAfterSyntaxErrorLegacy()
|
||||
{
|
||||
$twig = $this->getEnvironment(false, [], self::$templates);
|
||||
@@ -553,6 +563,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getSandboxUnallowedToStringTests
|
||||
*/
|
||||
#[DataProvider('getSandboxUnallowedToStringTests')]
|
||||
public function testSandboxUnallowedToString($template)
|
||||
{
|
||||
$twig = $this->getEnvironment(true, [], ['index' => $template], ['if', 'do', 'for', 'set'], ['upper', 'join', 'replace', 'format', 'split'], ['Twig\Tests\Extension\FooObject' => 'getAnotherFooObject'], [], ['random', 'range', 'my_func']);
|
||||
@@ -766,6 +777,7 @@ class SandboxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getSandboxAllowedToStringTests
|
||||
*/
|
||||
#[DataProvider('getSandboxAllowedToStringTests')]
|
||||
public function testSandboxAllowedToString($template, $output)
|
||||
{
|
||||
$twig = $this->getEnvironment(true, [], ['index' => $template], ['set', 'do'], [], ['Twig\Tests\Extension\FooObject' => ['foo', 'getAnotherFooObject']]);
|
||||
@@ -1048,6 +1060,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSandboxTagIncludeWithPreloadedTemplate()
|
||||
{
|
||||
$twig = $this->getEnvironment(false, [], [
|
||||
@@ -1065,6 +1078,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSandboxTagIncludeIgnoreMissingWithPreloadedTemplate()
|
||||
{
|
||||
$twig = $this->getEnvironment(false, [], [
|
||||
@@ -1193,6 +1207,7 @@ EOF
|
||||
/**
|
||||
* @dataProvider getStringableTraversableBypassTemplates
|
||||
*/
|
||||
#[DataProvider('getStringableTraversableBypassTemplates')]
|
||||
public function testSandboxBlocksToStringInStringableTraversable(string $template)
|
||||
{
|
||||
$twig = $this->getEnvironment(
|
||||
@@ -1224,6 +1239,7 @@ EOF
|
||||
*
|
||||
* @dataProvider getStringableTraversableBypassTemplates
|
||||
*/
|
||||
#[DataProvider('getStringableTraversableBypassTemplates'), Group('legacy')]
|
||||
public function testSourcePolicySandboxBlocksToStringInStringableTraversable(string $template)
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1279,6 +1295,7 @@ EOF
|
||||
/**
|
||||
* @dataProvider getCyclicTraversableTemplates
|
||||
*/
|
||||
#[DataProvider('getCyclicTraversableTemplates')]
|
||||
public function testSandboxHandlesCyclicTraversableWithoutStackOverflow(string $template)
|
||||
{
|
||||
// A self-referencing IteratorAggregate must not cause the sandbox policy
|
||||
@@ -1308,6 +1325,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicySandboxBlocksToStringInTraversableJoin()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1333,6 +1351,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicySandboxBlocksToStringInTraversableReplace()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1412,6 +1431,7 @@ EOF
|
||||
/**
|
||||
* @dataProvider getSafePhpTypesSkipToStringWrap
|
||||
*/
|
||||
#[DataProvider('getSafePhpTypesSkipToStringWrap')]
|
||||
public function testSafePhpParamTypesSkipToStringWrap(string $template, callable $func, array $params): void
|
||||
{
|
||||
// The sandbox visitor must not wrap arguments whose target PHP
|
||||
@@ -1465,6 +1485,7 @@ EOF
|
||||
/**
|
||||
* @dataProvider getUnsafePhpTypesStillWrap
|
||||
*/
|
||||
#[DataProvider('getUnsafePhpTypesStillWrap')]
|
||||
public function testUnsafePhpParamTypesStillWrap(string $template, callable $func, array $params): void
|
||||
{
|
||||
// Conversely, an unsafe parameter type (`mixed`, untyped, `string`,
|
||||
@@ -1497,6 +1518,7 @@ EOF
|
||||
/**
|
||||
* @dataProvider getOpenPhpTypesStillWrap
|
||||
*/
|
||||
#[DataProvider('getOpenPhpTypesStillWrap')]
|
||||
public function testOpenPhpParamTypesStillWrap(callable $func, object $obj, string $class): void
|
||||
{
|
||||
// Interfaces and non-final classes are "open": a Stringable subtype
|
||||
@@ -1642,6 +1664,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicySandboxBlocksColumnFilterOnDisallowedProperty()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1668,6 +1691,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicySandboxBlocksColumnFilterOnDisallowedIndex()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1694,6 +1718,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicySandboxAllowsColumnFilterOnAllowedProperty()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1714,6 +1739,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicySandboxBlocksColumnFilterOnMagicGetter()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1751,6 +1777,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSandboxSourcePolicyEnableReturningFalse()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1767,6 +1794,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSandboxSourcePolicyEnableReturningTrue()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1784,6 +1812,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSandboxSourcePolicyFalseDoesntOverrideOtherEnables()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1803,6 +1832,7 @@ EOF
|
||||
*
|
||||
* @dataProvider provideSourcePolicyArrowBlockedTemplates
|
||||
*/
|
||||
#[DataProvider('provideSourcePolicyArrowBlockedTemplates'), Group('legacy')]
|
||||
public function testSourcePolicyBlocksNonClosureCallableInArrow(string $template)
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1835,6 +1865,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testSourcePolicyAllowsClosureInArrow()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1853,6 +1884,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNonSandboxedSourcePolicyAllowsNonClosureCallable()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1892,6 +1924,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNeedsIsSandboxedFilterFollowsSourcePolicy()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.27.0: The "Twig\Sandbox\SourcePolicyInterface" interface is deprecated with no replacement, do not pass an instance to "Twig\Extension\SandboxExtension".');
|
||||
@@ -1947,6 +1980,7 @@ EOF
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNeedsIsSandboxedHelperTriggersDeprecationForCustomImplementation()
|
||||
{
|
||||
$callable = new LegacyTwigCallableWithoutNeedsIsSandboxed();
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\FileExtensionEscapingStrategy;
|
||||
|
||||
@@ -28,6 +29,7 @@ class FileExtensionEscapingStrategyTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGuessData
|
||||
*/
|
||||
#[DataProvider('getGuessData')]
|
||||
public function testGuess($strategy, $filename)
|
||||
{
|
||||
$this->assertSame($strategy, FileExtensionEscapingStrategy::guess($filename));
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Environment;
|
||||
@@ -183,6 +185,7 @@ class LexerTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getStringWithEscapedDelimiter
|
||||
*/
|
||||
#[DataProvider('getStringWithEscapedDelimiter')]
|
||||
public function testStringWithEscapedDelimiter(string $template, string $expected)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
@@ -259,6 +262,7 @@ class LexerTest extends TestCase
|
||||
*
|
||||
* @dataProvider getStringWithEscapedDelimiterProducingDeprecation
|
||||
*/
|
||||
#[DataProvider('getStringWithEscapedDelimiterProducingDeprecation'), Group('legacy')]
|
||||
public function testStringWithEscapedDelimiterProducingDeprecation(string $template, string $expected, string $expectedDeprecation)
|
||||
{
|
||||
$this->expectDeprecation($expectedDeprecation);
|
||||
@@ -536,6 +540,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForErrorsAtTheEndOfTheStream
|
||||
*/
|
||||
#[DataProvider('getTemplateForErrorsAtTheEndOfTheStream')]
|
||||
public function testErrorsAtTheEndOfTheStream(string $template)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
@@ -559,6 +564,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForStrings
|
||||
*/
|
||||
#[DataProvider('getTemplateForStrings')]
|
||||
public function testStrings(string $expected)
|
||||
{
|
||||
$template = '{{ "'.$expected.'" }}';
|
||||
@@ -597,6 +603,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForInlineCommentsForVariable
|
||||
*/
|
||||
#[DataProvider('getTemplateForInlineCommentsForVariable')]
|
||||
public function testInlineCommentForVariable(string $template)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
@@ -630,6 +637,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForInlineCommentsForBlock
|
||||
*/
|
||||
#[DataProvider('getTemplateForInlineCommentsForBlock')]
|
||||
public function testInlineCommentForBlock(string $template)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
@@ -668,6 +676,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForInlineCommentsForComment
|
||||
*/
|
||||
#[DataProvider('getTemplateForInlineCommentsForComment')]
|
||||
public function testInlineCommentForComment(string $template)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
@@ -685,6 +694,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForUnclosedBracketInExpression
|
||||
*/
|
||||
#[DataProvider('getTemplateForUnclosedBracketInExpression')]
|
||||
public function testUnclosedBracketInExpression(string $template, string $bracket)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
@@ -706,6 +716,7 @@ bar
|
||||
/**
|
||||
* @dataProvider getTemplateForUnexpectedBracketInExpression
|
||||
*/
|
||||
#[DataProvider('getTemplateForUnexpectedBracketInExpression')]
|
||||
public function testUnexpectedBracketInExpression(string $template, string $bracket)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Loader;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
@@ -38,6 +39,7 @@ class FilesystemTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getSecurityTests
|
||||
*/
|
||||
#[DataProvider('getSecurityTests')]
|
||||
public function testSecurity($template)
|
||||
{
|
||||
$loader = new FilesystemLoader([__DIR__.'/../Fixtures']);
|
||||
@@ -83,6 +85,7 @@ class FilesystemTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getBasePaths
|
||||
*/
|
||||
#[DataProvider('getBasePaths')]
|
||||
public function testPaths($basePath, $cacheKey, $rootPath)
|
||||
{
|
||||
$loader = new FilesystemLoader([$basePath.'/normal', $basePath.'/normal_bis'], $rootPath);
|
||||
@@ -218,6 +221,7 @@ class FilesystemTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getArrayInheritanceTests
|
||||
*/
|
||||
#[DataProvider('getArrayInheritanceTests')]
|
||||
public function testArrayInheritance(string $templateName)
|
||||
{
|
||||
$loader = new FilesystemLoader([]);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Node\Expression;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Node\EmptyNode;
|
||||
@@ -29,6 +30,7 @@ use Twig\TwigFunction;
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
class CallTest extends TestCase
|
||||
{
|
||||
public function testGetArguments()
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Node\Expression;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Twig\Node\Expression\ConditionalExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Test\NodeTestCase;
|
||||
@@ -27,6 +28,7 @@ use Twig\Test\NodeTestCase;
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
class ConditionalTest extends NodeTestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Node\Expression;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\MacroReferenceExpression;
|
||||
@@ -21,6 +22,7 @@ class MacroReferenceTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideInvalidMacroNames
|
||||
*/
|
||||
#[DataProvider('provideInvalidMacroNames')]
|
||||
public function testConstructorRejectsNonIdentifierName(string $name)
|
||||
{
|
||||
$this->expectException(\LogicException::class);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Node\Expression;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\NullCoalesceExpression;
|
||||
use Twig\Node\Expression\Variable\ContextVariable;
|
||||
@@ -28,6 +29,7 @@ use Twig\Test\NodeTestCase;
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
class NullCoalesceTest extends NodeTestCase
|
||||
{
|
||||
public static function provideTests(): iterable
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Node;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Node\NameDeprecation;
|
||||
@@ -84,6 +85,7 @@ EOF, (string) $node);
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testAttributeDeprecationWithoutAlternative()
|
||||
{
|
||||
$node = new NodeForTest([], ['foo' => false]);
|
||||
@@ -96,6 +98,7 @@ EOF, (string) $node);
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testAttributeDeprecationWithAlternative()
|
||||
{
|
||||
$node = new NodeForTest([], ['foo' => false]);
|
||||
@@ -116,6 +119,7 @@ EOF, (string) $node);
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNodeDeprecationWithoutAlternative()
|
||||
{
|
||||
$node = new NodeForTest(['foo' => $foo = new NodeForTest()]);
|
||||
@@ -128,6 +132,7 @@ EOF, (string) $node);
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testNodeAttributeDeprecationWithAlternative()
|
||||
{
|
||||
$node = new NodeForTest(['foo' => $foo = new NodeForTest()]);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\NodeVisitor;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
@@ -90,6 +91,7 @@ class OptimizerTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestsForForLoopOptimizer
|
||||
*/
|
||||
#[DataProvider('getTestsForForLoopOptimizer')]
|
||||
public function testForLoopOptimizer($template, $expected)
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false]);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\SyntaxError;
|
||||
@@ -74,6 +75,7 @@ class ParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getFilterBodyNodesData
|
||||
*/
|
||||
#[DataProvider('getFilterBodyNodesData')]
|
||||
public function testFilterBodyNodes($input, $expected)
|
||||
{
|
||||
$parser = $this->getParser();
|
||||
@@ -103,6 +105,7 @@ class ParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getFilterBodyNodesDataThrowsException
|
||||
*/
|
||||
#[DataProvider('getFilterBodyNodesDataThrowsException')]
|
||||
public function testFilterBodyNodesThrowsException($input)
|
||||
{
|
||||
$parser = $this->getParser();
|
||||
@@ -124,6 +127,7 @@ class ParserTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getFilterBodyNodesWithBOMData
|
||||
*/
|
||||
#[DataProvider('getFilterBodyNodesWithBOMData')]
|
||||
public function testFilterBodyNodesWithBOM($emptyNode)
|
||||
{
|
||||
$parser = $this->getParser();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Resources;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\RuntimeError;
|
||||
@@ -31,6 +32,7 @@ require_once __DIR__.'/../../src/Resources/core.php';
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
class LegacyCoreTest extends TestCase
|
||||
{
|
||||
public function testTwigSortFilterEnforcesGlobalSandbox()
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests\Runtime;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Runtime\EscaperRuntime;
|
||||
@@ -386,6 +387,7 @@ class EscaperRuntimeTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideCustomEscaperCases
|
||||
*/
|
||||
#[DataProvider('provideCustomEscaperCases')]
|
||||
public function testCustomEscaper($expected, $string, $strategy, $charset)
|
||||
{
|
||||
$escaper = new EscaperRuntime();
|
||||
@@ -405,6 +407,7 @@ class EscaperRuntimeTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideObjectsForEscaping
|
||||
*/
|
||||
#[DataProvider('provideObjectsForEscaping')]
|
||||
public function testObjectEscaping(string $escapedHtml, string $escapedJs, array $safeClasses)
|
||||
{
|
||||
$obj = new Extension_TestClass();
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Twig\Tests;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\RuntimeError;
|
||||
@@ -46,6 +47,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getAttributeExceptions
|
||||
*/
|
||||
#[DataProvider('getAttributeExceptions')]
|
||||
public function testGetAttributeExceptions($template, $message)
|
||||
{
|
||||
$templates = ['index' => $template];
|
||||
@@ -96,6 +98,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGetAttributeWithSandbox
|
||||
*/
|
||||
#[DataProvider('getGetAttributeWithSandbox')]
|
||||
public function testGetAttributeWithSandbox($object, $item, $allowed)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader());
|
||||
@@ -135,6 +138,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getRenderTemplateWithoutOutputData
|
||||
*/
|
||||
#[DataProvider('getRenderTemplateWithoutOutputData')]
|
||||
public function testRenderTemplateWithoutOutput(string $template)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader(['index' => $template]));
|
||||
@@ -153,6 +157,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getNullCoalesceWithImportedMacroData
|
||||
*/
|
||||
#[DataProvider('getNullCoalesceWithImportedMacroData')]
|
||||
public function testNullCoalesceWithImportedMacro(array $templates, string $expected)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader($templates));
|
||||
@@ -255,6 +260,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getStrictVariablesModes
|
||||
*/
|
||||
#[DataProvider('getStrictVariablesModes')]
|
||||
public function testArrayAccessWithStringableKeyIsConsistentAcrossStrictModes(bool $strict)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader(['index' => '{{ array[object] }}']), [
|
||||
@@ -307,6 +313,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGetAttributeTests
|
||||
*/
|
||||
#[DataProvider('getGetAttributeTests')]
|
||||
public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader());
|
||||
@@ -318,6 +325,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGetAttributeTests
|
||||
*/
|
||||
#[DataProvider('getGetAttributeTests')]
|
||||
public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader(), ['strict_variables' => true]);
|
||||
@@ -337,6 +345,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGetAttributeTests
|
||||
*/
|
||||
#[DataProvider('getGetAttributeTests')]
|
||||
public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader());
|
||||
@@ -348,6 +357,7 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGetAttributeTests
|
||||
*/
|
||||
#[DataProvider('getGetAttributeTests')]
|
||||
public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader(), ['strict_variables' => true]);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\TokenParser;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
@@ -20,6 +21,7 @@ use Twig\Source;
|
||||
class TypesTokenParserTest extends TestCase
|
||||
{
|
||||
/** @dataProvider getMappingTests */
|
||||
#[DataProvider('getMappingTests')]
|
||||
public function testMappingParsing(string $template, array $expected): void
|
||||
{
|
||||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Twig\Tests\Util;
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Twig\Error\SyntaxError;
|
||||
@@ -98,6 +100,7 @@ class CallableArgumentsExtractorTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getGetArgumentsConversionData
|
||||
*/
|
||||
#[DataProvider('getGetArgumentsConversionData')]
|
||||
public function testGetArgumentsConversion($arg1, $arg2)
|
||||
{
|
||||
$this->assertEquals([null], $this->getArguments('custom', eval("return fn (\$$arg1) => '';"), [$arg1 => null]));
|
||||
@@ -121,6 +124,7 @@ class CallableArgumentsExtractorTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testGetArgumentsConversionForVariadics()
|
||||
{
|
||||
$this->expectDeprecation('Since twig/twig 3.15: Using "snake_case" for variadic arguments is required for a smooth upgrade with Twig 4.0; rename "someNumberVariadic" to "some_number_variadic" in "test.twig" at line 2.');
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Tests\Util;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Util\CallableParameters;
|
||||
|
||||
@@ -19,6 +20,7 @@ class CallableParametersTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideTypes
|
||||
*/
|
||||
#[DataProvider('provideTypes')]
|
||||
public function testIsStringCoercionSafe(?\ReflectionType $type, bool $expected, ?\ReflectionClass $scope = null): void
|
||||
{
|
||||
$this->assertSame($expected, CallableParameters::isStringCoercionSafe($type, $scope));
|
||||
|
||||
@@ -29,9 +29,6 @@ use Twig\Util\DeprecationCollector;
|
||||
|
||||
class DeprecationCollectorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @requires PHP 5.3
|
||||
*/
|
||||
public function testCollect()
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader());
|
||||
|
||||
Reference in New Issue
Block a user