Skip to content

Commit 50c28c4

Browse files
authored
Merge pull request #426 from mglaman/gh424
Test #lazy_builder and static::class concat for callback
2 parents 4de76b2 + 3505b00 commit 50c28c4

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

tests/src/Rules/RenderCallbackRuleTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ public function fileData(): \Generator
108108
__DIR__ . '/../../fixtures/drupal/core/lib/Drupal/Core/Render/Renderer.php',
109109
[]
110110
];
111+
yield [
112+
__DIR__ . '/data/bug-424.php',
113+
[
114+
[
115+
"#lazy_builder value 'non-empty-string' at key '0' is invalid.",
116+
10,
117+
"Refactor concatenation of `static::class` with method name to an array callback: [static::class, 'contentLazyBuilder']"
118+
],
119+
[
120+
"#lazy_builder callback class 'static(Bug424\Foo)' at key '0' does not implement Drupal\Core\Security\TrustedCallbackInterface.",
121+
17,
122+
"Change record: https://www.drupal.org/node/2966725."
123+
]
124+
]
125+
];
111126
}
112127

113128

tests/src/Rules/data/bug-424.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Bug424;
4+
5+
class Foo {
6+
public function render(): array {
7+
$build = [
8+
'one' => [
9+
'#lazy_builder' => [
10+
static::class . '::contentLazyBuilder',
11+
['foo'],
12+
],
13+
'#create_placeholder' => TRUE,
14+
],
15+
'two' => [
16+
'#lazy_builder' => [
17+
[static::class, 'contentLazyBuilder'],
18+
['foo'],
19+
],
20+
'#create_placeholder' => TRUE,
21+
]
22+
];
23+
24+
return $build;
25+
}
26+
27+
public static function contentLazyBuilder(string $foo): void {
28+
29+
}
30+
}

0 commit comments

Comments
 (0)