You are here

public function BubbleableMetadataTest::providerTestCreateFromRenderArray in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::providerTestCreateFromRenderArray()

Provides test data for createFromRenderArray().

Return value

array

File

core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php, line 214
Contains \Drupal\Tests\Core\Render\BubbleableMetadataTest.

Class

BubbleableMetadataTest
@coversDefaultClass \Drupal\Core\Render\BubbleableMetadata @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function providerTestCreateFromRenderArray() {
  $data = [];
  $empty_metadata = new BubbleableMetadata();
  $nonempty_metadata = new BubbleableMetadata();
  $nonempty_metadata
    ->setCacheContexts([
    'qux',
  ])
    ->setCacheTags([
    'foo:bar',
  ])
    ->setAttachments([
    'settings' => [
      'foo' => 'bar',
    ],
  ]);
  $empty_render_array = [];
  $nonempty_render_array = [
    '#cache' => [
      'contexts' => [
        'qux',
      ],
      'tags' => [
        'foo:bar',
      ],
      'max-age' => Cache::PERMANENT,
    ],
    '#attached' => [
      'settings' => [
        'foo' => 'bar',
      ],
    ],
  ];
  $data[] = [
    $empty_render_array,
    $empty_metadata,
  ];
  $data[] = [
    $nonempty_render_array,
    $nonempty_metadata,
  ];
  return $data;
}