/**
  * @see \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases
  */
 public function placeholdersProvider()
 {
     $cases = \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases::cases();
     // Generate $placeholders variable as expected by
     // \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface::processPlaceholders().
     $placeholders = [$cases['html']->placeholder => $cases['html']->placeholderRenderArray, $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->placeholderRenderArray, $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->placeholderRenderArray, $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->placeholderRenderArray, $cases['edge_case__html_non_lazy_builder']->placeholder => $cases['edge_case__html_non_lazy_builder']->placeholderRenderArray];
     return ['_no_big_pipe absent, no session, no-JS cookie absent' => [$placeholders, FALSE, FALSE, FALSE, []], '_no_big_pipe absent, no session, no-JS cookie present' => [$placeholders, FALSE, FALSE, TRUE, []], '_no_big_pipe present, no session, no-JS cookie absent' => [$placeholders, TRUE, FALSE, FALSE, []], '_no_big_pipe present, no session, no-JS cookie present' => [$placeholders, TRUE, FALSE, TRUE, []], '_no_big_pipe present, session, no-JS cookie absent' => [$placeholders, TRUE, TRUE, FALSE, []], '_no_big_pipe present, session, no-JS cookie present' => [$placeholders, TRUE, TRUE, TRUE, []], '_no_big_pipe absent, session, no-JS cookie absent: (JS-powered) BigPipe placeholder used for HTML placeholders' => [$placeholders, FALSE, TRUE, FALSE, [$cases['html']->placeholder => $cases['html']->bigPipePlaceholderRenderArray, $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->bigPipeNoJsPlaceholderRenderArray, $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->bigPipeNoJsPlaceholderRenderArray, $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->bigPipeNoJsPlaceholderRenderArray, $cases['edge_case__html_non_lazy_builder']->placeholder => $cases['edge_case__html_non_lazy_builder']->bigPipePlaceholderRenderArray]], '_no_big_pipe absent, session, no-JS cookie present: no-JS BigPipe placeholder used for HTML placeholders' => [$placeholders, FALSE, TRUE, TRUE, [$cases['html']->placeholder => $cases['html']->bigPipeNoJsPlaceholderRenderArray, $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->bigPipeNoJsPlaceholderRenderArray, $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->bigPipeNoJsPlaceholderRenderArray, $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->bigPipeNoJsPlaceholderRenderArray, $cases['edge_case__html_non_lazy_builder']->placeholder => $cases['edge_case__html_non_lazy_builder']->bigPipeNoJsPlaceholderRenderArray]]];
 }
 /**
  * Returns a all BigPipe placeholder test case render arrays.
  *
  * @return array
  */
 public function test()
 {
     $build = [];
     $cases = \Drupal\big_pipe\Tests\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.
     drupal_set_message('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.
     $build['edge_case__html_non_lazy_builder'] = $cases['edge_case__html_non_lazy_builder']->renderArray;
     return $build;
 }
예제 #3
0
 /**
  * @return \Drupal\big_pipe\Tests\BigPipePlaceholderTestCase[]
  */
 protected function getTestCases()
 {
     // Ensure we can generate CSRF tokens for the current user's session.
     $session_data = $this->container->get('session_handler.write_safe')->read($this->cookies[$this->getSessionName()]['value']);
     $csrf_token_seed = unserialize(explode('_sf2_meta|', $session_data)[1])['s'];
     $this->container->get('session_manager.metadata_bag')->setCsrfTokenSeed($csrf_token_seed);
     return \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases::cases($this->container, $this->rootUser);
 }