function BigPipeTestController::test
Same name in other branches
- 9 core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php \Drupal\big_pipe_test\BigPipeTestController::test()
- 8.9.x core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php \Drupal\big_pipe_test\BigPipeTestController::test()
- 10 core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php \Drupal\big_pipe_test\BigPipeTestController::test()
Returns all BigPipe placeholder test case render arrays.
Return value
array
1 string reference to 'BigPipeTestController::test'
- big_pipe_test.routing.yml in core/
modules/ big_pipe/ tests/ modules/ big_pipe_test/ big_pipe_test.routing.yml - core/modules/big_pipe/tests/modules/big_pipe_test/big_pipe_test.routing.yml
File
-
core/
modules/ big_pipe/ tests/ modules/ big_pipe_test/ src/ BigPipeTestController.php, line 23
Class
- BigPipeTestController
- Returns responses for Big Pipe routes.
Namespace
Drupal\big_pipe_testCode
public function test() {
$has_session = \Drupal::service('session_configuration')->hasSession(\Drupal::requestStack()->getMainRequest());
$build = [];
$cases = BigPipePlaceholderTestCases::cases(\Drupal::getContainer());
// 1. HTML placeholder: status messages. Drupal renders those automatically,
// so all that we need to do in this controller is set a message.
if ($has_session) {
// Only set a message if a session already exists, otherwise we always
// trigger a session, which means we can't test no-session requests.
\Drupal::messenger()->addStatus('Hello from BigPipe!');
}
$build['html'] = $cases['html']->renderArray;
// 2. HTML attribute value placeholder: form action.
$build['html_attribute_value'] = $cases['html_attribute_value']->renderArray;
// 3. HTML attribute value subset placeholder: CSRF token in link.
$build['html_attribute_value_subset'] = $cases['html_attribute_value_subset']->renderArray;
// 4. Edge case: custom string to be considered as a placeholder that
// happens to not be valid HTML.
$build['edge_case__invalid_html'] = $cases['edge_case__invalid_html']->renderArray;
// 5. Edge case: non-#lazy_builder placeholder that suspends.
$build['edge_case__html_non_lazy_builder_suspend'] = $cases['edge_case__html_non_lazy_builder_suspend']->renderArray;
// 6. Edge case: non-#lazy_builder placeholder.
$build['edge_case__html_non_lazy_builder'] = $cases['edge_case__html_non_lazy_builder']->renderArray;
// 7. Exception: #lazy_builder that throws an exception.
$build['exception__lazy_builder'] = $cases['exception__lazy_builder']->renderArray;
// 8. Exception: placeholder that causes response filter to throw exception.
$build['exception__embedded_response'] = $cases['exception__embedded_response']->renderArray;
return $build;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.