mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-08 21:05:37 +00:00
feature #4265 Migrate NodeTestCase to static data providers (derrabus)
This PR was merged into the 3.x branch.
Discussion
----------
Migrate NodeTestCase to static data providers
PHPUnit 11 requires data providers to be static. This PR prepares our abstract `NodeTestCase` by deprecating the non-static `getTests()` and adding a static `provideTests()` as a replacement. I've also added PHPUnit attributes which newer PHPUnit releases prefer over PHPDoc annotations.
Commits
-------
f555a33c Migrate NodeTestCase to static data providers
This commit is contained in:
+8
-10
@@ -35,7 +35,7 @@ class SetTest extends NodeTestCase
|
||||
$this->assertFalse($node->getAttribute('capture'));
|
||||
}
|
||||
|
||||
public function getTests()
|
||||
public static function provideTests(): iterable
|
||||
{
|
||||
$tests = [];
|
||||
|
||||
@@ -52,27 +52,25 @@ EOF
|
||||
$values = new Node([new PrintNode(new ConstantExpression('foo', 1), 1)], [], 1);
|
||||
$node = new SetNode(true, $names, $values, 1);
|
||||
|
||||
if ($this->getEnvironment()->useYield()) {
|
||||
$tests[] = [$node, <<<EOF
|
||||
$tests[] = [$node, <<<EOF
|
||||
// line 1
|
||||
\$context["foo"] = ('' === \$tmp = implode('', iterator_to_array((function () use (&\$context, \$macros, \$blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
})(), false))) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
||||
EOF
|
||||
, new Environment(new ArrayLoader()),
|
||||
];
|
||||
} else {
|
||||
$tests[] = [$node, <<<'EOF'
|
||||
, new Environment(new ArrayLoader(), ['use_yield' => true]),
|
||||
];
|
||||
|
||||
$tests[] = [$node, <<<'EOF'
|
||||
// line 1
|
||||
$context["foo"] = ('' === $tmp = \Twig\Extension\CoreExtension::captureOutput((function () use (&$context, $macros, $blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
})())) ? '' : new Markup($tmp, $this->env->getCharset());
|
||||
EOF
|
||||
, new Environment(new ArrayLoader()),
|
||||
];
|
||||
}
|
||||
, new Environment(new ArrayLoader(), ['use_yield' => false]),
|
||||
];
|
||||
|
||||
$names = new Node([new AssignNameExpression('foo', 1)], [], 1);
|
||||
$values = new TextNode('foo', 1);
|
||||
|
||||
Reference in New Issue
Block a user