You are here

public function WebformBubbleableMetadataTest::providerTestAppendTo in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Unit/Cache/WebformBubbleableMetadataTest.php \Drupal\Tests\webform\Unit\Cache\WebformBubbleableMetadataTest::providerTestAppendTo()

Provides test data for testAppendTo().

Return value

array

File

tests/src/Unit/Cache/WebformBubbleableMetadataTest.php, line 55

Class

WebformBubbleableMetadataTest
Tests webform bubbleable metadata.

Namespace

Drupal\Tests\webform\Unit\Cache

Code

public function providerTestAppendTo() {
  return [
    [
      (new WebformBubbleableMetadata())
        ->setCacheContexts([
        'bar',
      ]),
      [],
      [
        '#cache' => [
          'contexts' => [
            'bar',
          ],
          'tags' => [],
          'max-age' => Cache::PERMANENT,
        ],
        '#attached' => [],
      ],
    ],
    [
      (new WebformBubbleableMetadata())
        ->setCacheContexts([
        'bar',
      ]),
      [
        '#cache' => [
          'contexts' => [
            'bar',
          ],
        ],
      ],
      [
        '#cache' => [
          'contexts' => [
            'bar',
          ],
          'tags' => [],
          'max-age' => Cache::PERMANENT,
        ],
        '#attached' => [],
      ],
    ],
    [
      (new WebformBubbleableMetadata())
        ->setCacheContexts([
        'bar',
        'foo',
      ]),
      [
        '#cache' => [
          'contexts' => [
            'bar',
          ],
        ],
      ],
      [
        '#cache' => [
          'contexts' => [
            'bar',
            'foo',
          ],
          'tags' => [],
          'max-age' => Cache::PERMANENT,
        ],
        '#attached' => [],
      ],
    ],
    [
      (new WebformBubbleableMetadata())
        ->setCacheMaxAge(99),
      [],
      [
        '#cache' => [
          'contexts' => [],
          'tags' => [],
          'max-age' => 99,
        ],
        '#attached' => [],
      ],
    ],
    [
      (new WebformBubbleableMetadata())
        ->setCacheContexts([
        'bar',
      ]),
      [
        '#cache' => [
          'max-age' => 99,
        ],
      ],
      [
        '#cache' => [
          'contexts' => [
            'bar',
          ],
          'tags' => [],
          'max-age' => 99,
        ],
        '#attached' => [],
      ],
    ],
  ];
}