You are here

public function BigPipeResponseAttachmentsProcessorTest::attachmentsProvider in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php \Drupal\Tests\big_pipe\Unit\Render\BigPipeResponseAttachmentsProcessorTest::attachmentsProvider()
  2. 9 core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php \Drupal\Tests\big_pipe\Unit\Render\BigPipeResponseAttachmentsProcessorTest::attachmentsProvider()

File

core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php, line 86

Class

BigPipeResponseAttachmentsProcessorTest
@coversDefaultClass \Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor @group big_pipe

Namespace

Drupal\Tests\big_pipe\Unit\Render

Code

public function attachmentsProvider() {
  $typical_cases = [
    'no attachments' => [
      [],
    ],
    'libraries' => [
      [
        'library' => [
          'core/drupal',
        ],
      ],
    ],
    'libraries + drupalSettings' => [
      [
        'library' => [
          'core/drupal',
        ],
        'drupalSettings' => [
          'foo' => 'bar',
        ],
      ],
    ],
  ];
  $official_attachment_types = [
    'html_head',
    'feed',
    'html_head_link',
    'http_header',
    'library',
    'placeholders',
    'drupalSettings',
    'html_response_attachment_placeholders',
  ];
  $official_attachments_with_random_values = [];
  foreach ($official_attachment_types as $type) {
    $official_attachments_with_random_values[$type] = $this
      ->randomMachineName();
  }
  $random_attachments = [
    'random' . $this
      ->randomMachineName() => $this
      ->randomMachineName(),
  ];
  $edge_cases = [
    'all official attachment types, with random assigned values, even if technically not valid, to prove BigPipeResponseAttachmentsProcessor is a perfect decorator' => [
      $official_attachments_with_random_values,
    ],
    'random attachment type (unofficial), with random assigned value, to prove BigPipeResponseAttachmentsProcessor is a perfect decorator' => [
      $random_attachments,
    ],
  ];
  $big_pipe_placeholder_attachments = [
    'big_pipe_placeholders' => [
      $this
        ->randomMachineName(),
    ],
  ];
  $big_pipe_nojs_placeholder_attachments = [
    'big_pipe_nojs_placeholders' => [
      $this
        ->randomMachineName(),
    ],
  ];
  $big_pipe_cases = [
    'only big_pipe_placeholders' => [
      $big_pipe_placeholder_attachments,
    ],
    'only big_pipe_nojs_placeholders' => [
      $big_pipe_nojs_placeholder_attachments,
    ],
    'big_pipe_placeholders + big_pipe_nojs_placeholders' => [
      $big_pipe_placeholder_attachments + $big_pipe_nojs_placeholder_attachments,
    ],
  ];
  $combined_cases = [
    'all official attachment types + big_pipe_placeholders + big_pipe_nojs_placeholders' => [
      $official_attachments_with_random_values + $big_pipe_placeholder_attachments + $big_pipe_nojs_placeholder_attachments,
    ],
    'random attachment types + big_pipe_placeholders + big_pipe_nojs_placeholders' => [
      $random_attachments + $big_pipe_placeholder_attachments + $big_pipe_nojs_placeholder_attachments,
    ],
  ];
  return $typical_cases + $edge_cases + $big_pipe_cases + $combined_cases;
}