function BigPipeResponseAttachmentsProcessorTest::attachmentsProvider

Same name in other branches
  1. 9 core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php \Drupal\Tests\big_pipe\Unit\Render\BigPipeResponseAttachmentsProcessorTest::attachmentsProvider()
  2. 8.9.x core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php \Drupal\Tests\big_pipe\Unit\Render\BigPipeResponseAttachmentsProcessorTest::attachmentsProvider()
  3. 11.x 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 91

Class

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

Namespace

Drupal\Tests\big_pipe\Unit\Render

Code

public static 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] = Random::machineName();
    }
    $random_attachments = [
        'random' . Random::machineName() => Random::machineName(),
    ];
    $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' => [
            Random::machineName(),
        ],
    ];
    $big_pipe_nojs_placeholder_attachments = [
        'big_pipe_nojs_placeholders' => [
            Random::machineName(),
        ],
    ];
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.