You are here

public function ServiceTest::testSettingAndGettingPlugins in Purge 8.3

Tests ::getPluginsEnabled, ::setPluginsEnabled and ::reload.

File

tests/src/Kernel/Queue/ServiceTest.php, line 62

Class

ServiceTest
Tests \Drupal\purge\Plugin\Purge\Queue\QueueService.

Namespace

Drupal\Tests\purge\Kernel\Queue

Code

public function testSettingAndGettingPlugins() : void {
  $this->service
    ->setPluginsEnabled([
    'file',
  ]);
  $this
    ->assertTrue(in_array('file', $this->service
    ->getPluginsEnabled()));
  $this->service
    ->setPluginsEnabled([
    'memory',
  ]);
  $this
    ->assertTrue(in_array('memory', $this->service
    ->getPluginsEnabled()));
  $thrown = FALSE;
  try {
    $this->service
      ->setPluginsEnabled([
      'DOESNOTEXIST',
    ]);
  } catch (\LogicException $e) {
    $thrown = $e instanceof \LogicException;
  }
  $this
    ->assertTrue($thrown);
  $thrown = FALSE;
  try {
    $this->service
      ->setPluginsEnabled([]);
  } catch (\LogicException $e) {
    $thrown = $e instanceof \LogicException;
  }
  $this
    ->assertTrue($thrown);
}