File: 0008-Compatibility-with-recent-PHPUnit-12.patch

package info (click to toggle)
php-twig 3.21.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,384 kB
  • sloc: php: 24,699; makefile: 110; sh: 43
file content (374 lines) | stat: -rw-r--r-- 16,016 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Sat, 15 Feb 2025 15:51:59 +0100
Subject: Compatibility with recent PHPUnit (12)

---
 extra/cssinliner-extra/Tests/LegacyFunctionsTest.php |  2 ++
 extra/html-extra/Tests/LegacyFunctionsTest.php       |  2 ++
 extra/inky-extra/Tests/LegacyFunctionsTest.php       |  2 ++
 extra/markdown-extra/Tests/FunctionalTest.php        |  4 +++-
 extra/markdown-extra/Tests/LegacyFunctionsTest.php   |  2 ++
 tests/EnvironmentTest.php                            |  8 +++-----
 tests/ErrorTest.php                                  |  4 +---
 tests/ExpressionParserTest.php                       | 19 +++++++------------
 tests/Extension/AttributeExtensionTest.php           | 12 +++---------
 tests/Extension/EscaperTest.php                      |  3 +++
 tests/Extension/SandboxTest.php                      | 12 ++++--------
 tests/LexerTest.php                                  |  3 +++
 tests/NodeVisitor/OptimizerTest.php                  |  1 +
 tests/TemplateTest.php                               |  6 +++---
 14 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/extra/cssinliner-extra/Tests/LegacyFunctionsTest.php b/extra/cssinliner-extra/Tests/LegacyFunctionsTest.php
index d62e267..0b8bd7b 100644
--- a/extra/cssinliner-extra/Tests/LegacyFunctionsTest.php
+++ b/extra/cssinliner-extra/Tests/LegacyFunctionsTest.php
@@ -11,6 +11,7 @@
 
 namespace Twig\Extra\CssInliner\Tests;
 
+use PHPUnit\Framework\Attributes\IgnoreDeprecations;
 use PHPUnit\Framework\TestCase;
 use Twig\Extra\CssInliner\CssInlinerExtension;
 
@@ -21,6 +22,7 @@ use function Twig\Extra\CssInliner\twig_inline_css;
  */
 class LegacyFunctionsTest extends TestCase
 {
+    #[IgnoreDeprecations]
     public function testInlineCss()
     {
         $this->assertSame(CssInlinerExtension::inlineCss('<p>body</p>', 'p { color: red }'), twig_inline_css('<p>body</p>', 'p { color: red }'));
diff --git a/extra/html-extra/Tests/LegacyFunctionsTest.php b/extra/html-extra/Tests/LegacyFunctionsTest.php
index accf8af..757553c 100644
--- a/extra/html-extra/Tests/LegacyFunctionsTest.php
+++ b/extra/html-extra/Tests/LegacyFunctionsTest.php
@@ -11,6 +11,7 @@
 
 namespace Twig\Extra\Html\Tests;
 
+use PHPUnit\Framework\Attributes\IgnoreDeprecations;
 use PHPUnit\Framework\TestCase;
 use Twig\Extra\Html\HtmlExtension;
 
@@ -19,6 +20,7 @@ use Twig\Extra\Html\HtmlExtension;
  */
 class LegacyFunctionsTest extends TestCase
 {
+    #[IgnoreDeprecations]
     public function testHtmlToMarkdown()
     {
         $this->assertSame(HtmlExtension::htmlClasses(['charset' => 'utf-8']), twig_html_classes(['charset' => 'utf-8']));
diff --git a/extra/inky-extra/Tests/LegacyFunctionsTest.php b/extra/inky-extra/Tests/LegacyFunctionsTest.php
index 4810235..e83848c 100644
--- a/extra/inky-extra/Tests/LegacyFunctionsTest.php
+++ b/extra/inky-extra/Tests/LegacyFunctionsTest.php
@@ -11,6 +11,7 @@
 
 namespace Twig\Extra\Inky\Tests;
 
+use PHPUnit\Framework\Attributes\IgnoreDeprecations;
 use PHPUnit\Framework\TestCase;
 use Twig\Extra\Inky\InkyExtension;
 
@@ -21,6 +22,7 @@ use function Twig\Extra\Inky\twig_inky;
  */
 class LegacyFunctionsTest extends TestCase
 {
+    #[IgnoreDeprecations]
     public function testInlineCss()
     {
         $this->assertSame(InkyExtension::inky('<p>Foo</p>'), twig_inky('<p>Foo</p>'));
diff --git a/extra/markdown-extra/Tests/FunctionalTest.php b/extra/markdown-extra/Tests/FunctionalTest.php
index 40449b3..ecfffb2 100644
--- a/extra/markdown-extra/Tests/FunctionalTest.php
+++ b/extra/markdown-extra/Tests/FunctionalTest.php
@@ -12,6 +12,7 @@
 namespace Twig\Extra\Markdown\Tests;
 
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\IgnoreDeprecations;
 use PHPUnit\Framework\TestCase;
 use Twig\Environment;
 use Twig\Extra\Markdown\DefaultMarkdown;
@@ -26,7 +27,8 @@ use Twig\RuntimeLoader\RuntimeLoaderInterface;
 class FunctionalTest extends TestCase
 {
     #[DataProvider('getMarkdownTests')]
-    public function testMarkdown(string $template, string $expected)
+    #[IgnoreDeprecations]
+    public function testMarkdown(string $template, string $expected): void
     {
         foreach ([LeagueMarkdown::class, ErusevMarkdown::class, /* MichelfMarkdown::class, */ DefaultMarkdown::class] as $class) {
             $twig = new Environment(new ArrayLoader([
diff --git a/extra/markdown-extra/Tests/LegacyFunctionsTest.php b/extra/markdown-extra/Tests/LegacyFunctionsTest.php
index 19a861d..c3a8708 100644
--- a/extra/markdown-extra/Tests/LegacyFunctionsTest.php
+++ b/extra/markdown-extra/Tests/LegacyFunctionsTest.php
@@ -11,6 +11,7 @@
 
 namespace Twig\Extra\Markdown\Tests;
 
+use PHPUnit\Framework\Attributes\IgnoreDeprecations;
 use PHPUnit\Framework\TestCase;
 
 use function Twig\Extra\Markdown\html_to_markdown;
@@ -22,6 +23,7 @@ use Twig\Extra\Markdown\MarkdownExtension;
  */
 class LegacyFunctionsTest extends TestCase
 {
+    #[IgnoreDeprecations]
     public function testHtmlToMarkdown()
     {
         $this->assertSame(MarkdownExtension::htmlToMarkdown('<p>foo</p>'), html_to_markdown('<p>foo</p>'));
diff --git a/tests/EnvironmentTest.php b/tests/EnvironmentTest.php
index fb9090c..4526808 100644
--- a/tests/EnvironmentTest.php
+++ b/tests/EnvironmentTest.php
@@ -435,11 +435,9 @@ class EnvironmentTest extends TestCase
         $this->assertSame('dynamic', $parser->getTag());
     }
 
-    /**
-     * @group legacy
-     *
-     * @requires PHP 8
-     */
+    #[\PHPUnit\Framework\Attributes\RequiresPhp('8')]
+    #[\PHPUnit\Framework\Attributes\Group('legacy')]
+    #[\PHPUnit\Framework\Attributes\Group('nophpunit12')]
     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']);
diff --git a/tests/ErrorTest.php b/tests/ErrorTest.php
index 35afbe8..c54011c 100644
--- a/tests/ErrorTest.php
+++ b/tests/ErrorTest.php
@@ -259,9 +259,7 @@ EOHTML,
         }
     }
 
-    /**
-     * @dataProvider getErrorWithoutLineAndContextData
-     */
+    #[\PHPUnit\Framework\Attributes\DataProvider('getErrorWithoutLineAndContextData')]
     public function testErrorWithoutLineAndContext(LoaderInterface $loader, bool $debug, bool $addDebugInfo, bool $exceptionWithLineAndContext, int $errorLine)
     {
         $twig = new Environment($loader, ['debug' => $debug, 'cache' => false]);
diff --git a/tests/ExpressionParserTest.php b/tests/ExpressionParserTest.php
index 5e60dfc..d527840 100644
--- a/tests/ExpressionParserTest.php
+++ b/tests/ExpressionParserTest.php
@@ -471,9 +471,8 @@ class ExpressionParserTest extends TestCase
         $this->expectNotToPerformAssertions();
     }
 
-    /**
-     * @group legacy
-     */
+    #[\PHPUnit\Framework\Attributes\Group('legacy')]
+    #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
     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.');
@@ -486,9 +485,8 @@ class ExpressionParserTest extends TestCase
         $parser->parse($env->tokenize(new Source('{{ foo() }}', 'index')));
     }
 
-    /**
-     * @group legacy
-     */
+    #[\PHPUnit\Framework\Attributes\Group('legacy')]
+    #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
     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.');
@@ -501,9 +499,8 @@ class ExpressionParserTest extends TestCase
         $parser->parse($env->tokenize(new Source('{{ 1|foo }}', 'index')));
     }
 
-    /**
-     * @group legacy
-     */
+    #[\PHPUnit\Framework\Attributes\Group('legacy')]
+    #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
     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.');
@@ -581,9 +578,7 @@ class ExpressionParserTest extends TestCase
         $this->expectNotToPerformAssertions();
     }
 
-    /**
-     * @dataProvider getBindingPowerTests
-     */
+    #[\PHPUnit\Framework\Attributes\DataProvider('getBindingPowerTests')]
     public function testBindingPower(string $expression, string $expectedExpression, mixed $expectedResult, array $context = [])
     {
         $env = new Environment(new ArrayLoader([
diff --git a/tests/Extension/AttributeExtensionTest.php b/tests/Extension/AttributeExtensionTest.php
index 68e3bfe..34e3161 100644
--- a/tests/Extension/AttributeExtensionTest.php
+++ b/tests/Extension/AttributeExtensionTest.php
@@ -16,9 +16,7 @@ use Twig\TwigTest;
 
 class AttributeExtensionTest extends TestCase
 {
-    /**
-     * @dataProvider provideFilters
-     */
+    #[\PHPUnit\Framework\Attributes\DataProvider('provideFilters')]
     public function testFilter(string $name, string $method, array $options)
     {
         $extension = new AttributeExtension(ExtensionWithAttributes::class);
@@ -44,9 +42,7 @@ class AttributeExtensionTest extends TestCase
         yield 'pattern' => ['pattern_*_filter', 'patternFilter', []];
     }
 
-    /**
-     * @dataProvider provideFunctions
-     */
+    #[\PHPUnit\Framework\Attributes\DataProvider('provideFunctions')]
     public function testFunction(string $name, string $method, array $options)
     {
         $extension = new AttributeExtension(ExtensionWithAttributes::class);
@@ -72,9 +68,7 @@ class AttributeExtensionTest extends TestCase
         yield 'deprecated' => ['deprecated_function', 'deprecatedFunction', ['deprecation_info' => new DeprecatedCallableInfo('foo/bar', '1.2')]];
     }
 
-    /**
-     * @dataProvider provideTests
-     */
+    #[\PHPUnit\Framework\Attributes\DataProvider('provideTests')]
     public function testTest(string $name, string $method, array $options)
     {
         $extension = new AttributeExtension(ExtensionWithAttributes::class);
diff --git a/tests/Extension/EscaperTest.php b/tests/Extension/EscaperTest.php
index 28df82d..7b59644 100644
--- a/tests/Extension/EscaperTest.php
+++ b/tests/Extension/EscaperTest.php
@@ -11,6 +11,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\Extension\EscaperExtension;
@@ -24,6 +25,7 @@ class EscaperTest extends TestCase
      *
      * @group legacy
      */
+    #[DataProvider('provideCustomEscaperCases')]
     public function testCustomEscaper($expected, $string, $strategy)
     {
         $twig = new Environment(new ArrayLoader());
@@ -46,6 +48,7 @@ class EscaperTest extends TestCase
      *
      * @group legacy
      */
+    #[DataProvider('provideCustomEscaperCases')]
     public function testCustomEscaperWithoutCallingSetEscaperRuntime($expected, $string, $strategy)
     {
         $twig = new Environment(new ArrayLoader());
diff --git a/tests/Extension/SandboxTest.php b/tests/Extension/SandboxTest.php
index fd655f7..beb40fe 100644
--- a/tests/Extension/SandboxTest.php
+++ b/tests/Extension/SandboxTest.php
@@ -111,11 +111,9 @@ class SandboxTest extends TestCase
         yield ['with', '{% with foo %}{% endwith %}'];
     }
 
-    /**
-     * @dataProvider getSandboxedForExtendsAndUseTagsTests
-     *
-     * @group legacy
-     */
+    #[DataProvider('getSandboxedForExtendsAndUseTagsTests')]
+    #[\PHPUnit\Framework\Attributes\Group('legacy')]
+    #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
     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.', $tag));
@@ -174,9 +172,7 @@ class SandboxTest extends TestCase
         }
     }
 
-    /**
-     * @group legacy
-     */
+    #[\PHPUnit\Framework\Attributes\Group('legacy')]
     public function testIfSandBoxIsDisabledAfterSyntaxErrorLegacy()
     {
         $twig = $this->getEnvironment(false, [], self::$templates);
diff --git a/tests/LexerTest.php b/tests/LexerTest.php
index a22a2fb..3f62c91 100644
--- a/tests/LexerTest.php
+++ b/tests/LexerTest.php
@@ -249,6 +249,7 @@ class LexerTest extends TestCase
      *
      * @dataProvider getStringWithEscapedDelimiterProducingDeprecation
      */
+    #[DataProvider('getStringWithEscapedDelimiterProducingDeprecation')]
     public function testStringWithEscapedDelimiterProducingDeprecation(string $template, string $expected, string $expectedDeprecation)
     {
         $this->expectDeprecation($expectedDeprecation);
@@ -615,6 +616,7 @@ bar
     /**
      * @dataProvider getTemplateForUnclosedBracketInExpression
      */
+    #[DataProvider('getTemplateForUnclosedBracketInExpression')]
     public function testUnclosedBracketInExpression(string $template, string $bracket)
     {
         $lexer = new Lexer(new Environment(new ArrayLoader()));
@@ -636,6 +638,7 @@ bar
     /**
      * @dataProvider getTemplateForUnexpectedBracketInExpression
      */
+    #[DataProvider('getTemplateForUnexpectedBracketInExpression')]
     public function testUnexpectedBracketInExpression(string $template, string $bracket)
     {
         $lexer = new Lexer(new Environment(new ArrayLoader()));
diff --git a/tests/NodeVisitor/OptimizerTest.php b/tests/NodeVisitor/OptimizerTest.php
index b765b48..fd00624 100644
--- a/tests/NodeVisitor/OptimizerTest.php
+++ b/tests/NodeVisitor/OptimizerTest.php
@@ -56,6 +56,7 @@ class OptimizerTest extends TestCase
         $this->assertTrue($node->getAttribute('output'));
     }
 
+    #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
     public function testForVarOptimizer()
     {
         $env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
diff --git a/tests/TemplateTest.php b/tests/TemplateTest.php
index afe2882..a9bc20b 100644
--- a/tests/TemplateTest.php
+++ b/tests/TemplateTest.php
@@ -202,7 +202,7 @@ class TemplateTest extends TestCase
     }
 
     #[DataProvider('getGetAttributeTests')]
-    public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
+    public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
     {
         $twig = new Environment(new ArrayLoader());
         $template = new TemplateForTest($twig);
@@ -228,7 +228,7 @@ class TemplateTest extends TestCase
     }
 
     #[DataProvider('getGetAttributeTests')]
-    public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
+    public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
     {
         $twig = new Environment(new ArrayLoader());
         $template = new TemplateForTest($twig);
@@ -237,7 +237,7 @@ class TemplateTest extends TestCase
     }
 
     #[DataProvider('getGetAttributeTests')]
-    public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
+    public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
     {
         $twig = new Environment(new ArrayLoader(), ['strict_variables' => true]);
         $template = new TemplateForTest($twig);