You are here

public function TestTrait::getInvalidations in Purge 8.3

Create $amount requested invalidation objects.

Parameters

int $amount: The amount of objects to return.

string $plugin_id: The id of the invalidation type being instantiated.

mixed|null $expression: Value - usually string - that describes the kind of invalidation, NULL when the type of invalidation doesn't require $expression. Types usually validate the given expression and throw exceptions for bad input.

bool $initialize_purger: Initialize a purger that supports all invalidation types. When FALSE is passed, expect a \Drupal\purge\Plugin\Purge\Invalidation\Exception\TypeUnsupportedException.

Return value

array|\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface Array of InvalidationInterface objects or a single InvalidationInterface.

24 calls to TestTrait::getInvalidations()
PluginTestBase::getInstance in tests/src/Kernel/Invalidation/PluginTestBase.php
Retrieve a invalidation object provided by the plugin.
PluginTestBase::testTypeUnsupportedException in tests/src/Kernel/Invalidation/PluginTestBase.php
Tests TypeUnsupportedException.
ProxyItemTest::testGet in tests/src/Kernel/Queue/ProxyItemTest.php
Tests \Drupal\purge\Plugin\Purge\Queue\ProxyItem::__get.
ProxyItemTest::testSet in tests/src/Kernel/Queue/ProxyItemTest.php
Tests \Drupal\purge\Plugin\Purge\Queue\ProxyItem::__set.
QueueEmptyFormTest::testConfirm in modules/purge_ui/tests/src/Functional/Form/QueueEmptyFormTest.php
Tests that the confirm button clears the queue.

... See full list

File

tests/src/Traits/TestTrait.php, line 226

Class

TestTrait
Several helper properties and methods for purge tests.

Namespace

Drupal\Tests\purge\Traits

Code

public function getInvalidations($amount, $plugin_id = 'everything', $expression = NULL, $initialize_purger = TRUE) {
  $this
    ->initializeInvalidationFactoryService();
  if ($initialize_purger) {
    $this
      ->initializePurgersService([
      'id' => 'good',
    ]);
  }
  $set = [];
  for ($i = 0; $i < $amount; $i++) {
    $set[] = $this->purgeInvalidationFactory
      ->get($plugin_id, $expression);
  }
  return $amount === 1 ? $set[0] : $set;
}