You are here

public function CacheTest::validateTagsProvider in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/CacheTest.php \Drupal\Tests\Core\Cache\CacheTest::validateTagsProvider()

Provides a list of cache tags arrays.

Return value

array

File

core/tests/Drupal/Tests/Core/Cache/CacheTest.php, line 19

Class

CacheTest
@coversDefaultClass \Drupal\Core\Cache\Cache @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function validateTagsProvider() {
  return [
    [
      [],
      FALSE,
    ],
    [
      [
        'foo',
      ],
      FALSE,
    ],
    [
      [
        'foo',
        'bar',
      ],
      FALSE,
    ],
    [
      [
        'foo',
        'bar',
        'llama:2001988',
        'baz',
        'llama:14031991',
      ],
      FALSE,
    ],
    // Invalid.
    [
      [
        FALSE,
      ],
      'Cache tags must be strings, boolean given.',
    ],
    [
      [
        TRUE,
      ],
      'Cache tags must be strings, boolean given.',
    ],
    [
      [
        'foo',
        FALSE,
      ],
      'Cache tags must be strings, boolean given.',
    ],
    [
      [
        NULL,
      ],
      'Cache tags must be strings, NULL given.',
    ],
    [
      [
        'foo',
        NULL,
      ],
      'Cache tags must be strings, NULL given.',
    ],
    [
      [
        1337,
      ],
      'Cache tags must be strings, integer given.',
    ],
    [
      [
        'foo',
        1337,
      ],
      'Cache tags must be strings, integer given.',
    ],
    [
      [
        3.14,
      ],
      'Cache tags must be strings, double given.',
    ],
    [
      [
        'foo',
        3.14,
      ],
      'Cache tags must be strings, double given.',
    ],
    [
      [
        [],
      ],
      'Cache tags must be strings, array given.',
    ],
    [
      [
        'foo',
        [],
      ],
      'Cache tags must be strings, array given.',
    ],
    [
      [
        'foo',
        [
          'bar',
        ],
      ],
      'Cache tags must be strings, array given.',
    ],
    [
      [
        new \stdClass(),
      ],
      'Cache tags must be strings, object given.',
    ],
    [
      [
        'foo',
        new \stdClass(),
      ],
      'Cache tags must be strings, object given.',
    ],
  ];
}