You are here

public function PluginTestBase::testInvalidExpressions in Purge 8.3

Test if all invalid string expressions fail to instantiate the object.

See also

\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__construct

File

tests/src/Kernel/Invalidation/PluginTestBase.php, line 427

Class

PluginTestBase
Provides an abstract test class to thoroughly test invalidation types.

Namespace

Drupal\Tests\purge\Kernel\Invalidation

Code

public function testInvalidExpressions() : void {
  foreach ($this->expressionsInvalid as $exp) {
    $thrown = FALSE;
    try {
      $this->purgeInvalidationFactory
        ->get($this->pluginId, $exp);
    } catch (\Exception $e) {
      $thrown = $e;
    }
    if (is_null($exp)) {
      $this
        ->assertInstanceOf(MissingExpressionException::class, $thrown);
    }
    else {
      $this
        ->assertInstanceOf(InvalidExpressionException::class, $thrown);
    }
  }
}