public function RendererBubblingTest::providerTestContextBubblingEdgeCases in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\RendererBubblingTest::providerTestContextBubblingEdgeCases()
- 9 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\RendererBubblingTest::providerTestContextBubblingEdgeCases()
File
- core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php, line 152
- Contains \Drupal\Tests\Core\Render\RendererBubblingTest.
Class
- RendererBubblingTest
- @coversDefaultClass \Drupal\Core\Render\Renderer
@group Render
Namespace
Drupal\Tests\Core\Render
Code
public function providerTestContextBubblingEdgeCases() {
$data = [];
$test_element = [
'#cache' => [
'keys' => [
'parent',
],
'contexts' => [],
],
'#markup' => 'parent',
'child' => [
'#access' => FALSE,
'#cache' => [
'contexts' => [
'foo',
],
],
],
];
$expected_cache_items = [
'parent' => [
'#attached' => [],
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
'#markup' => 'parent',
],
];
$data[] = [
$test_element,
[],
$expected_cache_items,
];
$test_element = [
'#cache' => [
'keys' => [
'set_test',
],
'contexts' => [],
],
];
$expected_cache_items = [
'set_test:bar:baz:foo' => [
'#attached' => [],
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
'#markup' => '',
],
];
$context_orders = [
[
'foo',
'bar',
'baz',
],
[
'foo',
'baz',
'bar',
],
[
'bar',
'foo',
'baz',
],
[
'bar',
'baz',
'foo',
],
[
'baz',
'foo',
'bar',
],
[
'baz',
'bar',
'foo',
],
];
foreach ($context_orders as $context_order) {
$test_element['#cache']['contexts'] = $context_order;
$expected_cache_items['set_test:bar:baz:foo']['#cache']['contexts'] = $context_order;
$data[] = [
$test_element,
$context_order,
$expected_cache_items,
];
}
$test_element = [
'#cache' => [
'keys' => [
'parent',
],
'contexts' => [
'foo',
'bar',
'baz',
],
],
'#markup' => 'parent',
'child' => [
'#cache' => [
'contexts' => [
'foo',
'baz',
],
'max-age' => 3600,
],
],
];
$expected_cache_items = [
'parent:bar:baz:foo' => [
'#attached' => [],
'#cache' => [
'contexts' => [
'foo',
'bar',
'baz',
],
'tags' => [],
'max-age' => 3600,
],
'#markup' => 'parent',
],
];
$data[] = [
$test_element,
[
'bar',
'baz',
'foo',
],
$expected_cache_items,
];
$test_element = [
'#cache' => [
'keys' => [
'parent',
],
'contexts' => [
'foo',
],
'tags' => [
'yar',
'har',
],
],
'#markup' => 'parent',
'child' => [
'#cache' => [
'contexts' => [
'bar',
],
'tags' => [
'fiddle',
'dee',
],
],
'#markup' => '',
],
];
$expected_cache_items = [
'parent:foo' => [
'#cache_redirect' => TRUE,
'#cache' => [
'keys' => [
'parent',
],
'contexts' => [
'foo',
'bar',
],
'tags' => [
'yar',
'har',
'fiddle',
'dee',
],
'bin' => 'render',
'max-age' => Cache::PERMANENT,
],
],
'parent:bar:foo' => [
'#attached' => [],
'#cache' => [
'contexts' => [
'foo',
'bar',
],
'tags' => [
'yar',
'har',
'fiddle',
'dee',
],
'max-age' => Cache::PERMANENT,
],
'#markup' => 'parent',
],
];
$data[] = [
$test_element,
[
'bar',
'foo',
],
$expected_cache_items,
];
$test_element = [
'#cache' => [
'keys' => [
'parent',
],
'tags' => [
'yar',
'har',
],
],
'#markup' => 'parent',
'child' => [
'#render_children' => TRUE,
'subchild' => [
'#cache' => [
'contexts' => [
'foo',
],
'tags' => [
'fiddle',
'dee',
],
],
'#attached' => [
'library' => [
'foo/bar',
],
],
'#markup' => '',
],
],
];
$expected_cache_items = [
'parent:foo' => [
'#attached' => [
'library' => [
'foo/bar',
],
],
'#cache' => [
'contexts' => [
'foo',
],
'tags' => [
'yar',
'har',
'fiddle',
'dee',
],
'max-age' => Cache::PERMANENT,
],
'#markup' => 'parent',
],
];
$data[] = [
$test_element,
[
'foo',
],
$expected_cache_items,
];
return $data;
}