diff --git a/src/Tests/DiagnosticCheck/HookRequirementsTest.php b/src/Tests/DiagnosticCheck/HookRequirementsTest.php
deleted file mode 100644
index 49965e4..0000000
--- a/src/Tests/DiagnosticCheck/HookRequirementsTest.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\DiagnosticCheck\HookRequirementsTest.
- */
-
-namespace Drupal\purge\Tests\DiagnosticCheck;
-
-use Drupal\purge\Tests\KernelTestBase;
-
-/**
- * Tests that purge_requirements() passes on our diagnostic checks.
- *
- * @group purge
- */
-class HookRequirementsTest extends KernelTestBase {
-
-  /**
-   * Modules to enable.
-   *
-   * @var array
-   */
-  public static $modules = [
-    'system',
-    'purge_check_test',
-    'purge_check_error_test',
-    'purge_check_warning_test'
-  ];
-
-  /**
-   * Tests that purge_requirements() passes on our diagnostic checks.
-   */
-  public function testHookRequirements() {
-    $module_handler = \Drupal::service('module_handler');
-    $module_handler->loadInclude('purge', 'install');
-    $r = $module_handler->invoke('purge', 'requirements', ['runtime']);
-    // Assert presence of all DiagnosticCheck plugins we're know off.
-    $this->assertTrue(isset($r['capacity']));
-    $this->assertTrue(isset($r['processorsavailable']));
-    $this->assertTrue(isset($r['queuersavailable']));
-    $this->assertTrue(isset($r['purgersavailable']));
-    $this->assertTrue(isset($r['memoryqueuewarning']));
-    $this->assertTrue(isset($r['alwaysinfo']));
-    $this->assertTrue(isset($r['alwaysok']));
-    $this->assertTrue(isset($r['alwayserror']));
-    $this->assertTrue(isset($r['alwayswarning']));
-    // Assert a couple of titles.
-    $this->assertEqual('Purge - Always ok', (string)$r['alwaysok']['title']);
-    $this->assertEqual('Purge - Always a warning', (string)$r['alwayswarning']['title']);
-    $this->assertEqual('Purge - Always an error', (string)$r['alwayserror']['title']);
-    // Assert that the descriptions come through.
-    $this->assertEqual('This is an ok for testing.', (string)$r['alwaysok']['description']);
-    $this->assertEqual('This is a warning for testing.', (string)$r['alwayswarning']['description']);
-    $this->assertEqual('This is an error for testing.', (string)$r['alwayserror']['description']);
-    // Assert that the severities come through properly.
-    $this->assertEqual(0, $r['alwaysok']['severity']);
-    $this->assertEqual(1, $r['alwayswarning']['severity']);
-    $this->assertEqual(2, $r['alwayserror']['severity']);
-    // Assert that the values come through properly.
-    $this->assertTrue(is_string($r['capacity']['value']));
-    $this->assertEqual("0", $r['capacity']['value']);
-    $this->assertEqual("", $r['alwaysinfo']['value']);
-    $this->assertEqual("", $r['alwaysok']['value']);
-  }
-
-}
diff --git a/src/Tests/DiagnosticCheck/PluginManagerTest.php b/src/Tests/DiagnosticCheck/PluginManagerTest.php
deleted file mode 100644
index adf646f..0000000
--- a/src/Tests/DiagnosticCheck/PluginManagerTest.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\DiagnosticCheck\PluginManagerTest.
- */
-
-namespace Drupal\purge\Tests\DiagnosticCheck;
-
-use Drupal\purge\Tests\KernelServiceTestBase;
-use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
-use Drupal\Core\Plugin\DefaultPluginManager;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\PluginManager.
- *
- * @group purge
- * @see \Drupal\Core\Plugin\DefaultPluginManager
- */
-class PluginManagerTest extends KernelServiceTestBase {
-  protected $serviceId = 'plugin.manager.purge.diagnostics';
-  public static $modules = [
-    'purge_check_test',
-    'purge_check_error_test',
-    'purge_check_warning_test'
-  ];
-
-  /**
-   * All metadata from \Drupal\purge\Annotation\PurgeDiagnosticCheck.
-   *
-   * @var string[]
-   */
-  protected $annotationFields = [
-    'provider',
-    'class',
-    'id',
-    'title',
-    'description',
-    'dependent_purger_plugins',
-    'dependent_queue_plugins',
-  ];
-
-  /**
-   * All bundled plugins in purge core, including in the test module.
-   *
-   * @var string[]
-   */
-  protected $plugins = [
-    'capacity',
-    'memoryqueuewarning',
-    'processorsavailable',
-    'purgersavailable',
-    'queuersavailable',
-    'alwayswarning',
-    'alwayserror',
-    'alwaysinfo',
-    'alwaysok',
-    'purgerwarning',
-    'queuewarning'
-  ];
-
-  /**
-   * Test if the plugin manager is built as we'd like.
-   */
-  public function testCodeContract() {
-    $this->assertTrue($this->service instanceof PluginManagerInterface);
-    $this->assertTrue($this->service instanceof DefaultPluginManager);
-    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
-  }
-
-  /**
-   * Test the plugins we expect to be available.
-   */
-  public function testDefinitions() {
-    $definitions = $this->service->getDefinitions();
-    foreach ($this->plugins as $plugin_id) {
-      $this->assertTrue(isset($definitions[$plugin_id]));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      $this->assertTrue(in_array($plugin_id, $this->plugins));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      foreach ($md as $field => $value) {
-        $this->assertTrue(in_array($field, $this->annotationFields));
-      }
-      foreach ($this->annotationFields as $field) {
-        $this->assertTrue(isset($md[$field]));
-      }
-    }
-  }
-
-}
diff --git a/src/Tests/DiagnosticCheck/ServiceSmokeAndFireTest.php b/src/Tests/DiagnosticCheck/ServiceSmokeAndFireTest.php
deleted file mode 100644
index f582371..0000000
--- a/src/Tests/DiagnosticCheck/ServiceSmokeAndFireTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\DiagnosticCheck\ServiceSmokeAndFireTest.
- */
-
-namespace Drupal\purge\Tests\DiagnosticCheck;
-
-use Drupal\purge\Tests\KernelServiceTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService
- * @see \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsServiceInterface
- */
-class ServiceSmokeAndFireTest extends KernelServiceTestBase {
-  protected $serviceId = 'purge.diagnostics';
-  public static $modules = ['purge_purger_test', 'purge_processor_test'];
-
-  /**
-   * Set up the test.
-   */
-  function setUp() {
-
-    // Skip parent::setUp() as we don't want the service initialized here.
-    KernelServiceTestBase::setUp();
-    $this->installConfig(['purge_processor_test']);
-  }
-
-  /**
-   * Tests:
-   *   - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemOnFire()
-   *   - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemShowingSmoke()
-   */
-  public function testIsSystemOnFireOrShowingSmoke() {
-    $this->initializePurgersService(['ida' => 'a']);
-    $this->initializeService();
-    $this->assertFalse(is_object($this->service->isSystemOnFire()));
-    if ($this->assertTrue(is_bool($this->service->isSystemOnFire()))) {
-      $this->assertFalse($this->service->isSystemOnFire());
-    }
-    $this->assertTrue(is_object($this->service->isSystemShowingSmoke()));
-  }
-
-}
diff --git a/src/Tests/Invalidation/DomainInvalidationTest.php b/src/Tests/Invalidation/DomainInvalidationTest.php
deleted file mode 100644
index 386d513..0000000
--- a/src/Tests/Invalidation/DomainInvalidationTest.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\DomainInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\DomainInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class DomainInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'domain';
-  protected $expressions = ['sitea.com', 'www.site.com'];
-  protected $expressionsInvalid = [NULL, ''];
-
-}
diff --git a/src/Tests/Invalidation/EverythingInvalidationTest.php b/src/Tests/Invalidation/EverythingInvalidationTest.php
deleted file mode 100644
index f1e5b26..0000000
--- a/src/Tests/Invalidation/EverythingInvalidationTest.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\EverythingInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\EverythingInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class EverythingInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'everything';
-  protected $expressions = [NULL];
-  protected $expressionsInvalid = ['', 'foobar'];
-
-}
diff --git a/src/Tests/Invalidation/PathInvalidationTest.php b/src/Tests/Invalidation/PathInvalidationTest.php
deleted file mode 100644
index 6ea620e..0000000
--- a/src/Tests/Invalidation/PathInvalidationTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\PathInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\PathInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class PathInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'path';
-  protected $expressions = [
-    '',
-    '?page=0',
-    'news',
-    'news/',
-    '012/442',
-    'news/article-1',
-    'news/article-1?page=0&secondparam=1'
-  ];
-  protected $expressionsInvalid = [
-    NULL,
-    '/news',
-    'news/*',
-    '/news/*',
-    '*'
-  ];
-
-}
diff --git a/src/Tests/Invalidation/PluginManagerTest.php b/src/Tests/Invalidation/PluginManagerTest.php
deleted file mode 100644
index 07db833..0000000
--- a/src/Tests/Invalidation/PluginManagerTest.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\PluginManagerTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\KernelServiceTestBase;
-use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
-use Drupal\Core\Plugin\DefaultPluginManager;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\PluginManager.
- *
- * @group purge
- * @see \Drupal\Core\Plugin\DefaultPluginManager
- */
-class PluginManagerTest extends KernelServiceTestBase {
-  protected $serviceId = 'plugin.manager.purge.invalidation';
-
-  /**
-   * All metadata from \Drupal\purge\Annotation\PurgeInvalidation.
-   *
-   * @var string[]
-   */
-  protected $annotationFields = [
-    'provider',
-    'class',
-    'id',
-    'label',
-    'description',
-    'examples',
-    'expression_required',
-    'expression_can_be_empty',
-    'expression_must_be_string'
-  ];
-
-  /**
-   * All bundled plugins.
-   *
-   * @var string[]
-   */
-  protected $plugins = [
-    'domain',
-    'everything',
-    'path',
-    'regex',
-    'tag',
-    'url',
-    'wildcardpath',
-    'wildcardurl'
-  ];
-
-  /**
-   * Test if the plugin manager is built as we'd like.
-   */
-  public function testCodeContract() {
-    $this->assertTrue($this->service instanceof PluginManagerInterface);
-    $this->assertTrue($this->service instanceof DefaultPluginManager);
-    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
-  }
-
-  /**
-   * Test the plugins we expect to be available.
-   */
-  public function testDefinitions() {
-    $definitions = $this->service->getDefinitions();
-    foreach ($this->plugins as $plugin_id) {
-      $this->assertTrue(isset($definitions[$plugin_id]));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      $this->assertTrue(in_array($plugin_id, $this->plugins));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      foreach ($md as $field => $value) {
-        $this->assertTrue(in_array($field, $this->annotationFields));
-      }
-      foreach ($this->annotationFields as $field) {
-        $this->assertTrue(isset($md[$field]));
-      }
-    }
-  }
-
-}
diff --git a/src/Tests/Invalidation/PluginTestBase.php b/src/Tests/Invalidation/PluginTestBase.php
deleted file mode 100644
index 473322a..0000000
--- a/src/Tests/Invalidation/PluginTestBase.php
+++ /dev/null
@@ -1,281 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\PluginTestBase.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\Core\StringTranslation\TranslatableMarkup;
-use Drupal\purge\Plugin\Purge\Purger\Exception\BadPluginBehaviorException;
-use Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface;
-use Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationBase;
-use Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface;
-use Drupal\purge\Plugin\Purge\Invalidation\InvalidationBase;
-use Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidPropertyException;
-use Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidExpressionException;
-use Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidStateException;
-use Drupal\purge\Plugin\Purge\Invalidation\Exception\MissingExpressionException;
-use Drupal\purge\Tests\KernelTestBase;
-
-/**
- * Provides an abstract test class to thoroughly test invalidation types.
- *
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-abstract class PluginTestBase extends KernelTestBase {
-
-  /**
-   * The plugin ID of the invalidation type being tested.
-   *
-   * @var string
-   */
-  protected $plugin_id;
-
-  /**
-   * String expressions valid to the invalidation type being tested.
-   *
-   * @var string[]|null
-   */
-  protected $expressions = NULL;
-
-  /**
-   * String expressions INvalid to the invalidation type being tested.
-   *
-   * @var string[]|null
-   */
-  protected $expressionsInvalid;
-
-  /**
-   * Set up the test.
-   */
-  function setUp() {
-    parent::setUp();
-    $this->initializeInvalidationFactoryService();
-  }
-
-  /**
-   * Retrieve a invalidation object provided by the plugin.
-   */
-  function getInstance() {
-    return $this->purgeInvalidationFactory->get(
-      $this->plugin_id,
-      $this->expressions[0]
-    );
-  }
-
-  /**
-   * Retrieve a immutable invalidation object, which wraps the plugin.
-   */
-  function getImmutableInstance() {
-    return $this->purgeInvalidationFactory->getImmutable(
-      $this->plugin_id,
-      $this->expressions[0]
-    );
-  }
-
-  /**
-   * Tests the code contract strictly enforced on invalidation type plugins.
-   */
-  function testCodeContract() {
-    $this->assertTrue($this->getInstance() instanceof ImmutableInvalidationInterface);
-    $this->assertTrue($this->getInstance() instanceof InvalidationInterface);
-    $this->assertTrue($this->getInstance() instanceof ImmutableInvalidationBase);
-    $this->assertTrue($this->getInstance() instanceof InvalidationBase);
-    $this->assertTrue($this->getImmutableInstance() instanceof ImmutableInvalidationInterface);
-    $this->assertFalse($this->getImmutableInstance() instanceof InvalidationInterface);
-    $this->assertTrue($this->getImmutableInstance() instanceof ImmutableInvalidationBase);
-    $this->assertFalse($this->getImmutableInstance() instanceof InvalidationBase);
-  }
-
-  /**
-   * Tests \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidation.
-   */
-  function testImmutable() {
-    $immutable = $this->getImmutableInstance();
-    $mutable = $this->getInstance();
-    $this->assertEqual($immutable->__toString(), $mutable->__toString());
-    $this->assertEqual($immutable->getExpression(), $mutable->getExpression());
-    $this->assertEqual($immutable->getState(), $mutable->getState());
-    $this->assertEqual($immutable->getStateString(), $mutable->getStateString());
-    $this->assertEqual($immutable->getType(), $mutable->getType());
-  }
-
-  /**
-   * Test if setting and getting the object state goes well.
-   *
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface::getProperties
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface::getProperty
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::deleteProperty
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setProperty
-   */
-  function testProperties() {
-    $i = $this->getInstance();
-    // Verify that getProperties() has the right initial state (of emptyness).
-    $this->assertEqual($i->getProperties(), []);
-    // Verify that exceptions are thrown when they should.
-    $this->assertException('\LogicException', [$i, 'getProperty'], ['key1']);
-    $this->assertException('\LogicException', [$i, 'setProperty'], ['key1', 'foobar']);
-    $this->assertNoException('\LogicException', [$i, 'getProperties']);
-    $i->setStateContext('purger1');
-    $this->assertException('\LogicException', [$i, 'getProperties']);
-    $this->assertNoException('\LogicException', [$i, 'getProperty'], ['key1']);
-    $this->assertNoException('\LogicException', [$i, 'setProperty'], ['key1', 'foobar']);
-    // Verify retrieving and setting properties.
-    $this->assertNull($i->getProperty('doesntexist'));
-    $this->assertEqual($i->getProperty('key1'), 'foobar');
-    $this->assertNull($i->deleteProperty('key1'));
-    $this->assertNull($i->getProperty('key1'));
-    $this->assertNull($i->setProperty('key1', 'foobar2'));
-    $this->assertEqual($i->getProperty('key1'), 'foobar2');
-    // Switch state to add some more properties.
-    $i->setState(InvalidationInterface::FAILED);
-    $i->setStateContext('purger2');
-    $i->setProperty('key2', 'baz');
-    $i->setState(InvalidationInterface::FAILED);
-    $i->setStateContext(NULL);
-    // Verify that getProperties() works as it should.
-    $p = $i->getProperties();
-    $this->assertEqual(count($p), 2);
-    $this->assertTrue(isset($p['purger1']['key1']));
-    $this->assertEqual($p['purger1']['key1'], 'foobar2');
-    $this->assertTrue(isset($p['purger2']['key2']));
-    $this->assertEqual($p['purger2']['key2'], 'baz');
-  }
-
-  /**
-   * Test if setting and getting the object state goes well.
-   *
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setState
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getState
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getStateString
-   */
-  function testState() {
-    $i = $this->getInstance();
-    // Test the initial state of the invalidation object. Then verify that a
-    // BadPluginBehaviorException is thrown when left as FRESH.
-    $this->assertEqual($i->getState(), InvalidationInterface::FRESH);
-    $this->assertEqual($i->getStateString(), 'FRESH');
-    $i->setStateContext('test');
-    $this->assertException('\Drupal\purge\Plugin\Purge\Purger\Exception\BadPluginBehaviorException', [$i, 'setStateContext'], [NULL]);
-    $i->setState(InvalidationInterface::FAILED);
-    $i->setStateContext(NULL);
-    // Verify that setting state in general context throws exceptions.
-    $this->assertException('\LogicException', [$i, 'setState'], [InvalidationInterface::FAILED]);
-    // Test \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setState catches bad input.
-    foreach(['2', 'FRESH', -1, 5, 100] as $badstate) {
-      $this->assertException('\Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidStateException', [$i, 'setState'], [$badstate]);
-    }
-    // Test setting normal states results in the same return state.
-    $test_states = [
-      InvalidationInterface::PROCESSING    => 'PROCESSING',
-      InvalidationInterface::SUCCEEDED     => 'SUCCEEDED',
-      InvalidationInterface::FAILED        => 'FAILED',
-      InvalidationInterface::NOT_SUPPORTED => 'NOT_SUPPORTED',
-    ];
-    $context = 0;
-    $i->setStateContext((string)$context);
-    foreach ($test_states as $state => $string) {
-      $this->assertNull($i->setStateContext((string) ($context++)));
-      $this->assertNull($i->setState($state));
-      $this->assertEqual($i->getState(), $state);
-      $this->assertEqual($i->getStateString(), $string);
-    }
-    $i->setStateContext(NULL);
-  }
-
-  /**
-   * Test if typecasting invalidation objects to strings gets us a string.
-   *
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__toString
-   */
-  function testStringExpression() {
-    $this->assertEqual( (string)$this->getInstance(), $this->expressions[0],
-      'The __toString method returns $expression.');
-  }
-
-  /**
-   * Test if all valid string expressions properly instantiate the object.
-   *
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__construct
-   */
-  function testValidExpressions() {
-    if (is_null($this->expressions)) {
-      $invalidation = $this->purgeInvalidationFactory->get($this->plugin_id);
-    }
-    else {
-      foreach ($this->expressions as $e) {
-        $invalidation = $this->purgeInvalidationFactory->get($this->plugin_id, $e);
-      }
-    }
-  }
-
-  /**
-   * Test if all invalid string expressions fail to instantiate the object.
-   *
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__construct
-   */
-  function testInvalidExpressions($expressions = NULL) {
-    foreach ($this->expressionsInvalid as $exp) {
-      $thrown = FALSE;
-      try {
-        $invalidation = $this->purgeInvalidationFactory->get($this->plugin_id, $exp);
-      }
-      catch (\Exception $e) {
-        $thrown = $e;
-      }
-      if (is_null($exp)) {
-        $this->assertTrue($thrown instanceof MissingExpressionException, var_export($exp, TRUE));
-      }
-      else {
-        $this->assertTrue($thrown instanceof InvalidExpressionException, var_export($exp, TRUE));
-      }
-    }
-  }
-
-  /**
-   * Test retrieving the plugin ID and definition.
-   *
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getPluginId
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getType
-   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getPluginDefinition
-   */
-  function testPluginIdAndDefinition() {
-    // Test mutable objects.
-    $mutable = $this->getInstance();
-    $this->assertEqual($this->plugin_id, $mutable->getPluginId());
-    $this->assertEqual($this->plugin_id, $mutable->getType());
-    $d = $mutable->getPluginDefinition();
-    $this->assertTrue(is_array($d));
-    $this->assertTrue(is_array($d['examples']));
-    $this->assertTrue($d['label'] instanceof TranslatableMarkup);
-    $this->assertFalse(empty((string) $d['label']));
-    $this->assertTrue($d['description'] instanceof TranslatableMarkup);
-    $this->assertFalse(empty((string) $d['description']));
-    $this->assertTrue(isset($d['expression_required']));
-    $this->assertTrue(isset($d['expression_can_be_empty']));
-    $this->assertTrue(isset($d['expression_must_be_string']));
-    if (!$d["expression_required"]) {
-      $this->assertFalse($d["expression_can_be_empty"]);
-    }
-    // Test the immutable objects.
-    $immutable = $this->getImmutableInstance();
-    $this->assertEqual($this->plugin_id, $immutable->getPluginId());
-    $this->assertEqual($this->plugin_id, $immutable->getType());
-    $d = $immutable->getPluginDefinition();
-    $this->assertTrue(is_array($d));
-    $this->assertTrue(is_array($d['examples']));
-    $this->assertTrue($d['label'] instanceof TranslatableMarkup);
-    $this->assertFalse(empty((string) $d['label']));
-    $this->assertTrue($d['description'] instanceof TranslatableMarkup);
-    $this->assertFalse(empty((string) $d['description']));
-    $this->assertTrue(isset($d['expression_required']));
-    $this->assertTrue(isset($d['expression_can_be_empty']));
-    $this->assertTrue(isset($d['expression_must_be_string']));
-    if (!$d["expression_required"]) {
-      $this->assertFalse($d["expression_can_be_empty"]);
-    }
-  }
-
-}
diff --git a/src/Tests/Invalidation/RegularExpressionInvalidationTest.php b/src/Tests/Invalidation/RegularExpressionInvalidationTest.php
deleted file mode 100644
index c5a188a..0000000
--- a/src/Tests/Invalidation/RegularExpressionInvalidationTest.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\RegularExpressionInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\RegularExpressionInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class RegularExpressionInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'regex';
-  protected $expressions = ['\.(jpg|jpeg|css|js)$'];
-  protected $expressionsInvalid = [NULL, ''];
-
-}
diff --git a/src/Tests/Invalidation/TagInvalidationTest.php b/src/Tests/Invalidation/TagInvalidationTest.php
deleted file mode 100644
index 7490793..0000000
--- a/src/Tests/Invalidation/TagInvalidationTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\TagInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\TagInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class TagInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'tag';
-  protected $expressions = [
-    'tag',
-    'user:1',
-    'menu:footer'
-  ];
-  protected $expressionsInvalid = [
-    NULL,
-    '',
-    ['node', '1'],
-    'wildtag:*'
-  ];
-
-}
diff --git a/src/Tests/Invalidation/UrlInvalidationTest.php b/src/Tests/Invalidation/UrlInvalidationTest.php
deleted file mode 100644
index 68df913..0000000
--- a/src/Tests/Invalidation/UrlInvalidationTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\UrlInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\UrlInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class UrlInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'url';
-  protected $expressions = [
-    'http://www.test.com',
-    'https://domain/path',
-    'http://domain/path?param=1',
-  ];
-  protected $expressionsInvalid = [
-    NULL,
-    '',
-    "35423523",
-    'http:// /aa',
-    'http://www.test.com/*',
-  ];
-
-}
diff --git a/src/Tests/Invalidation/WildcardPathInvalidationTest.php b/src/Tests/Invalidation/WildcardPathInvalidationTest.php
deleted file mode 100644
index fb460b4..0000000
--- a/src/Tests/Invalidation/WildcardPathInvalidationTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\WildcardPathInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\WildcardPathInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class WildcardPathInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'wildcardpath';
-  protected $expressions = [
-    '*',
-    '*?page=0',
-    'news/*',
-    'products/*'
-  ];
-  protected $expressionsInvalid = [
-    NULL,
-    '',
-    '/*',
-    '/',
-    '?page=0',
-    'news',
-    'news/',
-    '012/442',
-    'news/article-1',
-    'news/article-1?page=0&secondparam=1'
-  ];
-
-}
diff --git a/src/Tests/Invalidation/WildcardUrlInvalidationTest.php b/src/Tests/Invalidation/WildcardUrlInvalidationTest.php
deleted file mode 100644
index 0cefb4c..0000000
--- a/src/Tests/Invalidation/WildcardUrlInvalidationTest.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Invalidation\WildcardUrlInvalidationTest.
- */
-
-namespace Drupal\purge\Tests\Invalidation;
-
-use Drupal\purge\Tests\Invalidation\PluginTestBase;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Invalidation\WildcardUrlInvalidation.
- *
- * @group purge
- * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
- */
-class WildcardUrlInvalidationTest extends PluginTestBase {
-  protected $plugin_id = 'wildcardurl';
-  protected $expressions = ['http://www.test.com/*', 'https://domain/path/*'];
-  protected $expressionsInvalid = [
-    NULL,
-    '',
-    'http:// /aa',
-    'http://www.test.com',
-    'https://domain/path'
-  ];
-
-}
diff --git a/src/Tests/Processor/PluginManagerTest.php b/src/Tests/Processor/PluginManagerTest.php
deleted file mode 100644
index 289ca14..0000000
--- a/src/Tests/Processor/PluginManagerTest.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Processor\PluginManagerTest.
- */
-
-namespace Drupal\purge\Tests\Processor;
-
-use Drupal\purge\Tests\KernelServiceTestBase;
-use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
-use Drupal\Core\Plugin\DefaultPluginManager;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Processor\PluginManager.
- *
- * @group purge
- * @see \Drupal\Core\Plugin\DefaultPluginManager
- */
-class PluginManagerTest extends KernelServiceTestBase {
-  protected $serviceId = 'plugin.manager.purge.processor';
-  public static $modules = ['purge_processor_test'];
-
-  /**
-   * All metadata from \Drupal\purge\Annotation\PurgeProcessor.
-   *
-   * @var string[]
-   */
-  protected $annotationFields = [
-    'provider',
-    'class',
-    'id',
-    'label',
-    'description',
-    'enable_by_default',
-    'configform'
-  ];
-
-  /**
-   * All bundled plugins in purge core, including in the test module.
-   *
-   * @var string[]
-   */
-  protected $plugins = [
-    'a',
-    'b',
-    'c',
-    'withform'
-  ];
-
-  /**
-   * Test if the plugin manager is built as we'd like.
-   */
-  public function testCodeContract() {
-    $this->assertTrue($this->service instanceof PluginManagerInterface);
-    $this->assertTrue($this->service instanceof DefaultPluginManager);
-    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
-  }
-
-  /**
-   * Test the plugins we expect to be available.
-   */
-  public function testDefinitions() {
-    $definitions = $this->service->getDefinitions();
-    foreach ($this->plugins as $plugin_id) {
-      $this->assertTrue(isset($definitions[$plugin_id]));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      $this->assertTrue(in_array($plugin_id, $this->plugins));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      foreach ($md as $field => $value) {
-        $this->assertTrue(in_array($field, $this->annotationFields));
-      }
-      foreach ($this->annotationFields as $field) {
-        $this->assertTrue(isset($md[$field]));
-      }
-    }
-  }
-
-}
diff --git a/src/Tests/Purger/PluginManagerTest.php b/src/Tests/Purger/PluginManagerTest.php
deleted file mode 100644
index 33ad380..0000000
--- a/src/Tests/Purger/PluginManagerTest.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\purge\Tests\Purger\PluginManagerTest.
- */
-
-namespace Drupal\purge\Tests\Purger;
-
-use Drupal\purge\Tests\KernelServiceTestBase;
-use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
-use Drupal\Core\Plugin\DefaultPluginManager;
-
-/**
- * Tests \Drupal\purge\Plugin\Purge\Purger\PluginManager.
- *
- * @group purge
- * @see \Drupal\Core\Plugin\DefaultPluginManager
- */
-class PluginManagerTest extends KernelServiceTestBase {
-  protected $serviceId = 'plugin.manager.purge.purgers';
-  public static $modules = ['purge_purger_test'];
-
-  /**
-   * All metadata from \Drupal\purge\Annotation\PurgePurger.
-   *
-   * @var string[]
-   */
-  protected $annotationFields = [
-    'class',
-    'provider',
-    'id',
-    'label',
-    'configform',
-    'cooldown_time',
-    'description',
-    'multi_instance',
-    'types',
-  ];
-
-  /**
-   * All bundled plugins in purge core, including in the test module.
-   *
-   * @var string[]
-   */
-  protected $plugins = [
-    'a',
-    'b',
-    'c',
-    'good',
-    'withform'
-  ];
-
-  /**
-   * Test if the plugin manager is built as we'd like.
-   */
-  public function testCodeContract() {
-    $this->assertTrue($this->service instanceof PluginManagerInterface);
-    $this->assertTrue($this->service instanceof DefaultPluginManager);
-    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
-  }
-
-  /**
-   * Test the plugins we expect to be available.
-   */
-  public function testDefinitions() {
-    $definitions = $this->service->getDefinitions();
-    foreach ($this->plugins as $plugin_id) {
-      $this->assertTrue(isset($definitions[$plugin_id]));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      $this->assertTrue(in_array($plugin_id, $this->plugins));
-    }
-    foreach ($definitions as $plugin_id => $md) {
-      foreach ($md as $field => $value) {
-        $this->assertTrue(in_array($field, $this->annotationFields));
-      }
-      foreach ($this->annotationFields as $field) {
-        $this->assertTrue(isset($md[$field]));
-      }
-    }
-  }
-
-}
diff --git a/tests/src/ServiceTestTrait.php b/tests/src/ServiceTestTrait.php
new file mode 100644
index 0000000..d1231b4
--- /dev/null
+++ b/tests/src/ServiceTestTrait.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace Drupal\Tests\purge;
+
+use Drupal\purge\ServiceBase;
+use Drupal\purge\ServiceInterface;
+
+/**
+ * Properties and methods for services.yml exposed classes.
+ *
+ * @see \Drupal\purge\Tests\KernelTestBase
+ * @see \Drupal\purge\Tests\WebTestBase
+ */
+trait ServiceTestTrait {
+
+  /**
+   * The name of the service as defined in services.yml.
+   */
+  protected $serviceId;
+
+  /**
+   * Instance of the service being tested, instantiated by the container.
+   *
+   * @var mixed
+   */
+  protected $service;
+
+  /**
+   * Set up the test.
+   */
+  function setUp($switch_to_memory_queue = TRUE) {
+    parent::setUp($switch_to_memory_queue);
+    $this->initializeService();
+  }
+
+  /**
+   * Initialize the requested service as $this->$variable (or reload).
+   *
+   * @param string $variable
+   *   The place to put the loaded/reloaded service, defaults to $this->service.
+   * @param string $service
+   *   The name of the service to load, defaults to $this->serviceId.
+   */
+  protected function initializeService($variable = 'service', $service = NULL) {
+    if (is_null($this->$variable)) {
+      if (is_null($service)) {
+        $this->$variable = $this->container->get($this->serviceId);
+      }
+      else {
+        $this->$variable = $this->container->get($service);
+      }
+    }
+    if ($this->$variable instanceof ServiceInterface) {
+      $this->$variable->reload();
+    }
+  }
+
+  /**
+   * Test for \Drupal\purge\ServiceBase and \Drupal\purge\ServiceInterface.
+   *
+   * Services not derived from \Drupal\purge\ServiceInterface, should overload
+   * this test. This applies to plugin managers for instance.
+   */
+  public function testCodeContract() {
+    $this->assertTrue($this->service instanceof ServiceInterface);
+    $this->assertTrue($this->service instanceof ServiceBase);
+  }
+
+}
diff --git a/tests/src/TestTrait.php b/tests/src/TestTrait.php
new file mode 100644
index 0000000..04fefc9
--- /dev/null
+++ b/tests/src/TestTrait.php
@@ -0,0 +1,272 @@
+<?php
+
+namespace Drupal\Tests\purge;
+
+/**
+ * Several helper properties and methods for purge tests.
+ *
+ * @see \Drupal\Tests\purge\KernelTestBase
+ * @see \Drupal\purge\Tests\WebTestBase
+ */
+trait TestTrait {
+
+  /**
+   * Configuration object factory.
+   *
+   * @var \Drupal\Core\Config\ConfigFactoryInterface
+   */
+  protected $configFactory;
+
+  /**
+   * Logging services to purge and its submodules.
+   *
+   * @var \Drupal\purge\Logger\LoggerServiceInterface
+   */
+  protected $purgeLogger;
+
+  /**
+   * Provides access to loaded processors.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Processor\ProcessorsServiceInterface
+   */
+  protected $purgeProcessors;
+
+  /**
+   * Distributes access to one or more purgers.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Purger\PurgersServiceInterface
+   */
+  protected $purgePurgers;
+
+  /**
+   * Instantiates invalidation objects on-demand.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Invalidation\InvalidationsServiceInterface
+   */
+  protected $purgeInvalidationFactory;
+
+  /**
+   * Lets invalidations interact with a queue backend.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Queue\QueueServiceInterface
+   */
+  protected $purgeQueue;
+
+  /**
+   * Statistics tracker.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Queue\StatsTrackerInterface
+   */
+  protected $purgeQueueStats;
+
+  /**
+   * Transaction buffer.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Queue\TxBufferInterface
+   */
+  protected $purgeQueueTxbuffer;
+
+  /**
+   * Provides access to loaded queuers.
+   *
+   * @var \Drupal\purge\Plugin\Purge\Queuer\QueuersServiceInterface
+   */
+  protected $purgeQueuers;
+
+  /**
+   * Interacts with diagnostic checks.
+   *
+   * @var \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsServiceInterface
+   */
+  protected $purgeDiagnostics;
+
+  /**
+   * Provides access to available tags headers.
+   *
+   * @var \Drupal\purge\Plugin\Purge\TagsHeader\TagsHeadersServiceInterface
+   */
+  protected $purgeTagsHeaders;
+
+  /**
+   * Assert that the named exception is thrown.
+   *
+   * @param string $exception
+   *   The full name of the exception to be thrown.
+   * @param callable $call
+   *   The callable to call from within the try statement.
+   * @param mixed[] $args
+   *   Arguments to be passed to the callable.
+   */
+  protected function assertException($exception, callable $call, $args = []) {
+    $thrown = FALSE;
+    eval("
+      try {
+        call_user_func_array(\$call, \$args);
+      }
+      catch ($exception \$e) {
+        \$thrown = TRUE;
+      }");
+    $this->assertTrue($thrown, "Exception $exception thrown.");
+  }
+
+  /**
+   * Assert that the named exception is thrown.
+   *
+   * @param string $exception
+   *   The full name of the exception to be thrown.
+   * @param callable $call
+   *   The callable to call from within the try statement.
+   * @param mixed[] $args
+   *   Arguments to be passed to the callable.
+   */
+  protected function assertNoException($exception, callable $call, $args = []) {
+    $thrown = FALSE;
+    eval("
+      try {
+        call_user_func_array(\$call, \$args);
+      }
+      catch ($exception \$e) {
+        \$thrown = TRUE;
+      }");
+    $this->assertFalse($thrown, "Exception $exception isn't thrown.");
+  }
+
+  /**
+   * Make $this->purgeLogger available.
+   */
+  protected function initializeLoggerService() {
+    if (is_null($this->purgeLogger)) {
+      $this->purgeLogger = $this->container->get('purge.logger');
+    }
+  }
+
+  /**
+   * Make $this->purgeProcessors available.
+   *
+   * @param string[] $plugin_ids
+   *   Array of plugin ids to be enabled.
+   */
+  protected function initializeProcessorsService($plugin_ids = []) {
+    if (is_null($this->purgeProcessors)) {
+      $this->purgeProcessors = $this->container->get('purge.processors');
+    }
+    if (count($plugin_ids)) {
+      $this->purgeProcessors->reload();
+      $this->purgeProcessors->setPluginsEnabled($plugin_ids);
+    }
+  }
+
+  /**
+   * Make $this->purgePurgers available.
+   *
+   * @param string[] $plugin_ids
+   *   Array of plugin ids to be enabled.
+   */
+  protected function initializePurgersService($plugin_ids = []) {
+    if (is_null($this->purgePurgers)) {
+      $this->purgePurgers = $this->container->get('purge.purgers');
+    }
+    if (count($plugin_ids)) {
+      $ids = [];
+      foreach ($plugin_ids as $i => $plugin_id) {
+        $ids["id$i"] = $plugin_id;
+      }
+      $this->purgePurgers->reload();
+      $this->purgePurgers->setPluginsEnabled($ids);
+    }
+  }
+
+  /**
+   * Make $this->purgeInvalidationFactory available.
+   */
+  protected function initializeInvalidationFactoryService() {
+    if (is_null($this->purgeInvalidationFactory)) {
+      $this->purgeInvalidationFactory = $this->container->get('purge.invalidation.factory');
+    }
+  }
+
+  /**
+   * Make $this->purgeQueue available.
+   *
+   * @param null|string[] $plugin_id
+   *   The plugin ID of the queue to be configured.
+   */
+  protected function initializeQueueService($plugin_id = NULL) {
+    if (is_null($this->purgeQueue)) {
+      $this->purgeQueue = $this->container->get('purge.queue');
+    }
+    if (!is_null($plugin_id)) {
+      $this->purgeQueue->reload();
+      $this->purgeQueue->setPluginsEnabled([$plugin_id]);
+    }
+  }
+
+  /**
+   * Make $this->purgeQueuers available.
+   *
+   * @param string[] $plugin_ids
+   *   Array of plugin ids to be enabled.
+   */
+  protected function initializeQueuersService($plugin_ids = []) {
+    if (is_null($this->purgeQueuers)) {
+      $this->purgeQueuers = $this->container->get('purge.queuers');
+    }
+    if (count($plugin_ids)) {
+      $this->purgeQueuers->reload();
+      $this->purgeQueuers->setPluginsEnabled($plugin_ids);
+    }
+  }
+
+  /**
+   * Make $this->purgeDiagnostics available.
+   */
+  protected function initializeDiagnosticsService() {
+    if (is_null($this->purgeDiagnostics)) {
+      $this->purgeDiagnostics = $this->container->get('purge.diagnostics');
+    }
+    else {
+      $this->purgeDiagnostics->reload();
+    }
+  }
+
+  /**
+   * Make $this->purgeTagsheaders available.
+   */
+  protected function initializeTagsHeadersService() {
+    if (is_null($this->purgeTagsHeaders)) {
+      $this->purgeTagsHeaders = $this->container->get('purge.tagsheaders');
+    }
+    else {
+      $this->purgeTagsHeaders->reload();
+    }
+  }
+
+  /**
+   * Create $number requested invalidation objects.
+   *
+   * @param int $number
+   *   The number of objects to generate.
+   *
+   * @return array|\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+   *   Invalidation object.
+   */
+  public function getInvalidations($number) {
+    $this->initializeInvalidationFactoryService();
+    $set = [];
+    for ($i = 0; $i < $number; $i++) {
+      $set[] = $this->purgeInvalidationFactory->get('everything');
+    }
+    return ($number === 1) ? $set[0] : $set;
+  }
+
+  /**
+   * Switch to the memory queue backend.
+   */
+  public function setMemoryQueue() {
+    $this->configFactory = $this->container->get('config.factory');
+    $this->config('purge.plugins')
+      ->set('queue', 'memory')
+      ->save();
+  }
+
+}
diff --git a/tests/src/Unit/DiagnosticCheck/HookRequirementsTest.php b/tests/src/Unit/DiagnosticCheck/HookRequirementsTest.php
new file mode 100644
index 0000000..add224f
--- /dev/null
+++ b/tests/src/Unit/DiagnosticCheck/HookRequirementsTest.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\DiagnosticCheck;
+
+use Drupal\Tests\purge\Unit\KernelTestBase;
+
+/**
+ * Tests that purge_requirements() passes on our diagnostic checks.
+ *
+ * @group purge
+ */
+class HookRequirementsTest extends KernelTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'system',
+    'purge_check_test',
+    'purge_check_error_test',
+    'purge_check_warning_test',
+  ];
+
+  /**
+   * Tests that purge_requirements() passes on our diagnostic checks.
+   */
+  public function testHookRequirements() {
+    $module_handler = \Drupal::service('module_handler');
+    $module_handler->loadInclude('purge', 'install');
+    $r = $module_handler->invoke('purge', 'requirements', ['runtime']);
+    // Assert presence of all DiagnosticCheck plugins we're know off.
+    $this->assertTrue(isset($r['capacity']));
+    $this->assertTrue(isset($r['processorsavailable']));
+    $this->assertTrue(isset($r['queuersavailable']));
+    $this->assertTrue(isset($r['purgersavailable']));
+    $this->assertTrue(isset($r['memoryqueuewarning']));
+    $this->assertTrue(isset($r['alwaysinfo']));
+    $this->assertTrue(isset($r['alwaysok']));
+    $this->assertTrue(isset($r['alwayserror']));
+    $this->assertTrue(isset($r['alwayswarning']));
+    // Assert a couple of titles.
+    $this->assertEquals('Purge - Always ok', (string) $r['alwaysok']['title']);
+    $this->assertEquals('Purge - Always a warning', (string) $r['alwayswarning']['title']);
+    $this->assertEquals('Purge - Always an error', (string) $r['alwayserror']['title']);
+    // Assert that the descriptions come through.
+    $this->assertEquals('This is an ok for testing.', (string) $r['alwaysok']['description']);
+    $this->assertEquals('This is a warning for testing.', (string) $r['alwayswarning']['description']);
+    $this->assertEquals('This is an error for testing.', (string) $r['alwayserror']['description']);
+    // Assert that the severities come through properly.
+    $this->assertEquals(0, $r['alwaysok']['severity']);
+    $this->assertEquals(1, $r['alwayswarning']['severity']);
+    $this->assertEquals(2, $r['alwayserror']['severity']);
+    // Assert that the values come through properly.
+    $this->assertTrue(is_string($r['capacity']['value']));
+    $this->assertEquals("0", $r['capacity']['value']);
+    $this->assertEquals("", $r['alwaysinfo']['value']);
+    $this->assertEquals("", $r['alwaysok']['value']);
+  }
+
+}
diff --git a/tests/src/Unit/DiagnosticCheck/PluginManagerTest.php b/tests/src/Unit/DiagnosticCheck/PluginManagerTest.php
new file mode 100644
index 0000000..90e9dce
--- /dev/null
+++ b/tests/src/Unit/DiagnosticCheck/PluginManagerTest.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\DiagnosticCheck;
+
+use Drupal\Tests\purge\Unit\KernelServiceTestBase;
+use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
+use Drupal\Core\Plugin\DefaultPluginManager;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\PluginManager.
+ *
+ * @group purge
+ * @see \Drupal\Core\Plugin\DefaultPluginManager
+ */
+class PluginManagerTest extends KernelServiceTestBase {
+  protected $serviceId = 'plugin.manager.purge.diagnostics';
+  public static $modules = [
+    'purge_check_test',
+    'purge_check_error_test',
+    'purge_check_warning_test',
+  ];
+
+  /**
+   * All metadata from \Drupal\purge\Annotation\PurgeDiagnosticCheck.
+   *
+   * @var string[]
+   */
+  protected $annotationFields = [
+    'provider',
+    'class',
+    'id',
+    'title',
+    'description',
+    'dependent_purger_plugins',
+    'dependent_queue_plugins',
+  ];
+
+  /**
+   * All bundled plugins in purge core, including in the test module.
+   *
+   * @var string[]
+   */
+  protected $plugins = [
+    'capacity',
+    'memoryqueuewarning',
+    'processorsavailable',
+    'purgersavailable',
+    'queuersavailable',
+    'alwayswarning',
+    'alwayserror',
+    'alwaysinfo',
+    'alwaysok',
+    'purgerwarning',
+    'queuewarning',
+  ];
+
+  /**
+   * Test if the plugin manager is built as we'd like.
+   */
+  public function testCodeContract() {
+    $this->assertTrue($this->service instanceof PluginManagerInterface);
+    $this->assertTrue($this->service instanceof DefaultPluginManager);
+    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
+  }
+
+  /**
+   * Test the plugins we expect to be available.
+   */
+  public function testDefinitions() {
+    $definitions = $this->service->getDefinitions();
+    foreach ($this->plugins as $plugin_id) {
+      $this->assertTrue(isset($definitions[$plugin_id]));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      $this->assertTrue(in_array($plugin_id, $this->plugins));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      foreach ($md as $field => $value) {
+        $this->assertTrue(in_array($field, $this->annotationFields));
+      }
+      foreach ($this->annotationFields as $field) {
+        $this->assertTrue(isset($md[$field]));
+      }
+    }
+  }
+
+}
diff --git a/tests/src/Unit/DiagnosticCheck/ServiceSmokeAndFireTest.php b/tests/src/Unit/DiagnosticCheck/ServiceSmokeAndFireTest.php
new file mode 100644
index 0000000..d0b0c57
--- /dev/null
+++ b/tests/src/Unit/DiagnosticCheck/ServiceSmokeAndFireTest.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\DiagnosticCheck;
+
+use Drupal\Tests\purge\Unit\KernelServiceTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService
+ * @see \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsServiceInterface
+ */
+class ServiceSmokeAndFireTest extends KernelServiceTestBase {
+  protected $serviceId = 'purge.diagnostics';
+  public static $modules = ['purge_purger_test', 'purge_processor_test'];
+
+  /**
+   * Set up the test.
+   */
+  public function setUp($switch_to_memory_queue = TRUE) {
+
+    // Skip parent::setUp() as we don't want the service initialized here.
+    KernelServiceTestBase::setUp($switch_to_memory_queue);
+    $this->installConfig(['purge_processor_test']);
+  }
+
+  /**
+   * Tests:
+   *   - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemOnFire()
+   *   - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemShowingSmoke()
+   */
+  public function testIsSystemOnFireOrShowingSmoke() {
+    $this->initializePurgersService(['ida' => 'a']);
+    $this->initializeService();
+    $this->assertFalse(is_object($this->service->isSystemOnFire()));
+    $this->assertTrue(is_bool($this->service->isSystemOnFire()));
+    if (is_bool($this->service->isSystemOnFire())) {
+      $this->assertFalse($this->service->isSystemOnFire());
+    }
+    $this->assertTrue(is_object($this->service->isSystemShowingSmoke()));
+  }
+
+}
diff --git a/tests/src/Unit/Invalidation/DomainInvalidationTest.php b/tests/src/Unit/Invalidation/DomainInvalidationTest.php
new file mode 100644
index 0000000..340a22a
--- /dev/null
+++ b/tests/src/Unit/Invalidation/DomainInvalidationTest.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\DomainInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class DomainInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'domain';
+  protected $expressions = ['sitea.com', 'www.site.com'];
+  protected $expressionsInvalid = [NULL, ''];
+
+}
diff --git a/tests/src/Unit/Invalidation/EverythingInvalidationTest.php b/tests/src/Unit/Invalidation/EverythingInvalidationTest.php
new file mode 100644
index 0000000..79b54ff
--- /dev/null
+++ b/tests/src/Unit/Invalidation/EverythingInvalidationTest.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\EverythingInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class EverythingInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'everything';
+  protected $expressions = [NULL];
+  protected $expressionsInvalid = ['', 'foobar'];
+
+}
diff --git a/tests/src/Unit/Invalidation/PathInvalidationTest.php b/tests/src/Unit/Invalidation/PathInvalidationTest.php
new file mode 100644
index 0000000..6a946e5
--- /dev/null
+++ b/tests/src/Unit/Invalidation/PathInvalidationTest.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\PathInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class PathInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'path';
+  protected $expressions = [
+    '',
+    '?page=0',
+    'news',
+    'news/',
+    '012/442',
+    'news/article-1',
+    'news/article-1?page=0&secondparam=1',
+  ];
+  protected $expressionsInvalid = [
+    NULL,
+    '/news',
+    'news/*',
+    '/news/*',
+    '*',
+  ];
+
+}
diff --git a/tests/src/Unit/Invalidation/PluginManagerTest.php b/tests/src/Unit/Invalidation/PluginManagerTest.php
new file mode 100644
index 0000000..fdda2bd
--- /dev/null
+++ b/tests/src/Unit/Invalidation/PluginManagerTest.php
@@ -0,0 +1,82 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\KernelServiceTestBase;
+use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
+use Drupal\Core\Plugin\DefaultPluginManager;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\PluginManager.
+ *
+ * @group purge
+ * @see \Drupal\Core\Plugin\DefaultPluginManager
+ */
+class PluginManagerTest extends KernelServiceTestBase {
+  protected $serviceId = 'plugin.manager.purge.invalidation';
+
+  /**
+   * All metadata from \Drupal\purge\Annotation\PurgeInvalidation.
+   *
+   * @var string[]
+   */
+  protected $annotationFields = [
+    'provider',
+    'class',
+    'id',
+    'label',
+    'description',
+    'examples',
+    'expression_required',
+    'expression_can_be_empty',
+    'expression_must_be_string',
+  ];
+
+  /**
+   * All bundled plugins.
+   *
+   * @var string[]
+   */
+  protected $plugins = [
+    'domain',
+    'everything',
+    'path',
+    'regex',
+    'tag',
+    'url',
+    'wildcardpath',
+    'wildcardurl',
+  ];
+
+  /**
+   * Test if the plugin manager is built as we'd like.
+   */
+  public function testCodeContract() {
+    $this->assertTrue($this->service instanceof PluginManagerInterface);
+    $this->assertTrue($this->service instanceof DefaultPluginManager);
+    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
+  }
+
+  /**
+   * Test the plugins we expect to be available.
+   */
+  public function testDefinitions() {
+    $definitions = $this->service->getDefinitions();
+    foreach ($this->plugins as $plugin_id) {
+      $this->assertTrue(isset($definitions[$plugin_id]));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      $this->assertTrue(in_array($plugin_id, $this->plugins));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      foreach ($md as $field => $value) {
+        $this->assertTrue(in_array($field, $this->annotationFields));
+      }
+      foreach ($this->annotationFields as $field) {
+        $this->assertTrue(isset($md[$field]));
+      }
+    }
+  }
+
+}
diff --git a/tests/src/Unit/Invalidation/RegularExpressionInvalidationTest.php b/tests/src/Unit/Invalidation/RegularExpressionInvalidationTest.php
new file mode 100644
index 0000000..8575301
--- /dev/null
+++ b/tests/src/Unit/Invalidation/RegularExpressionInvalidationTest.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\RegularExpressionInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class RegularExpressionInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'regex';
+  protected $expressions = ['\.(jpg|jpeg|css|js)$'];
+  protected $expressionsInvalid = [NULL, ''];
+
+}
diff --git a/tests/src/Unit/Invalidation/TagInvalidationTest.php b/tests/src/Unit/Invalidation/TagInvalidationTest.php
new file mode 100644
index 0000000..6218f79
--- /dev/null
+++ b/tests/src/Unit/Invalidation/TagInvalidationTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\TagInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class TagInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'tag';
+  protected $expressions = [
+    'tag',
+    'user:1',
+    'menu:footer',
+  ];
+  protected $expressionsInvalid = [
+    NULL,
+    '',
+    ['node', '1'],
+    'wildtag:*',
+  ];
+
+}
diff --git a/tests/src/Unit/Invalidation/UrlInvalidationTest.php b/tests/src/Unit/Invalidation/UrlInvalidationTest.php
new file mode 100644
index 0000000..833c628
--- /dev/null
+++ b/tests/src/Unit/Invalidation/UrlInvalidationTest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\UrlInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class UrlInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'url';
+  protected $expressions = [
+    'http://www.test.com',
+    'https://domain/path',
+    'http://domain/path?param=1',
+  ];
+  protected $expressionsInvalid = [
+    NULL,
+    '',
+    "35423523",
+    'http:// /aa',
+    'http://www.test.com/*',
+  ];
+
+}
diff --git a/tests/src/Unit/Invalidation/WildcardPathInvalidationTest.php b/tests/src/Unit/Invalidation/WildcardPathInvalidationTest.php
new file mode 100644
index 0000000..79a2bbd
--- /dev/null
+++ b/tests/src/Unit/Invalidation/WildcardPathInvalidationTest.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\WildcardPathInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class WildcardPathInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'wildcardpath';
+  protected $expressions = [
+    '*',
+    '*?page=0',
+    'news/*',
+    'products/*',
+  ];
+  protected $expressionsInvalid = [
+    NULL,
+    '',
+    '/*',
+    '/',
+    '?page=0',
+    'news',
+    'news/',
+    '012/442',
+    'news/article-1',
+    'news/article-1?page=0&secondparam=1',
+  ];
+
+}
diff --git a/tests/src/Unit/Invalidation/WildcardUrlInvalidationTest.php b/tests/src/Unit/Invalidation/WildcardUrlInvalidationTest.php
new file mode 100644
index 0000000..bc8a88d
--- /dev/null
+++ b/tests/src/Unit/Invalidation/WildcardUrlInvalidationTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Invalidation;
+
+use Drupal\Tests\purge\Unit\PluginTestBase;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Invalidation\WildcardUrlInvalidation.
+ *
+ * @group purge
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+class WildcardUrlInvalidationTest extends PluginTestBase {
+  protected $plugin_id = 'wildcardurl';
+  protected $expressions = ['http://www.test.com/*', 'https://domain/path/*'];
+  protected $expressionsInvalid = [
+    NULL,
+    '',
+    'http:// /aa',
+    'http://www.test.com',
+    'https://domain/path',
+  ];
+
+}
diff --git a/tests/src/Unit/KernelServiceTestBase.php b/tests/src/Unit/KernelServiceTestBase.php
new file mode 100644
index 0000000..f7c10c7
--- /dev/null
+++ b/tests/src/Unit/KernelServiceTestBase.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit;
+
+use Drupal\Tests\purge\ServiceTestTrait;
+
+/**
+ * Thin and generic KTB for testing services.yml exposed classes.
+ *
+ * @see \Drupal\purge\Tests\KernelTestBase
+ * @see \Drupal\purge\Tests\ServiceTestTrait
+ */
+abstract class KernelServiceTestBase extends KernelTestBase {
+  use ServiceTestTrait;
+
+}
diff --git a/tests/src/Unit/KernelTestBase.php b/tests/src/Unit/KernelTestBase.php
new file mode 100644
index 0000000..0bf5fdf
--- /dev/null
+++ b/tests/src/Unit/KernelTestBase.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit;
+
+use Drupal\Tests\purge\TestTrait;
+use Drupal\KernelTests\KernelTestBase as RealKernelTestBase;
+
+/**
+ * Thin and generic KTB for purge tests.
+ *
+ * @see \Drupal\simpletest\KernelTestBase
+ * @see \Drupal\purge\Tests\TestTrait
+ */
+abstract class KernelTestBase extends RealKernelTestBase {
+  use TestTrait;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['purge'];
+
+  /**
+   * Set up the test object.
+   *
+   * @param bool $switch_to_memory_queue
+   *   Whether to switch the default queue to the memory backend or not.
+   */
+  public function setUp($switch_to_memory_queue = TRUE) {
+    parent::setUp();
+    $this->installConfig(['purge']);
+
+    // The default 'database' queue backend gives issues, switch to 'memory'.
+    if ($switch_to_memory_queue) {
+      $this->setMemoryQueue();
+    }
+  }
+
+}
diff --git a/tests/src/Unit/Logger/LoggerChannelPartTest.php b/tests/src/Unit/Logger/LoggerChannelPartTest.php
index 2dff678..f27c6ce 100644
--- a/tests/src/Unit/Logger/LoggerChannelPartTest.php
+++ b/tests/src/Unit/Logger/LoggerChannelPartTest.php
@@ -34,7 +34,7 @@ class LoggerChannelPartTest extends UnitTestCase {
   /**
    * Helper to all severity methods.
    */
-  private function testHelper($id, array $grants, $output, $severity) {
+  private function severityMethodsHelper($id, array $grants, $output, $severity) {
     $occurence = is_null($output) ? $this->never() : $this->once();
     $this->loggerChannelPurge
       ->expects($occurence)
@@ -98,7 +98,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestEmergency()
    */
   public function testEmergency($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'emergency');
+    $this->severityMethodsHelper($id, $grants, $output, 'emergency');
   }
 
   /**
@@ -117,7 +117,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestAlert()
    */
   public function testAlert($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'alert');
+    $this->severityMethodsHelper($id, $grants, $output, 'alert');
   }
 
   /**
@@ -136,7 +136,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestCritical()
    */
   public function testCritical($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'critical');
+    $this->severityMethodsHelper($id, $grants, $output, 'critical');
   }
 
   /**
@@ -155,7 +155,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestError()
    */
   public function testError($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'error');
+    $this->severityMethodsHelper($id, $grants, $output, 'error');
   }
 
   /**
@@ -174,7 +174,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestWarning()
    */
   public function testWarning($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'warning');
+    $this->severityMethodsHelper($id, $grants, $output, 'warning');
   }
 
   /**
@@ -193,7 +193,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestNotice()
    */
   public function testNotice($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'notice');
+    $this->severityMethodsHelper($id, $grants, $output, 'notice');
   }
 
   /**
@@ -212,7 +212,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestInfo()
    */
   public function testInfo($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'info');
+    $this->severityMethodsHelper($id, $grants, $output, 'info');
   }
 
   /**
@@ -231,7 +231,7 @@ class LoggerChannelPartTest extends UnitTestCase {
    * @dataProvider providerTestDebug()
    */
   public function testDebug($id, array $grants, $output) {
-    $this->testHelper($id, $grants, $output, 'debug');
+    $this->severityMethodsHelper($id, $grants, $output, 'debug');
   }
 
   /**
diff --git a/tests/src/Unit/PluginTestBase.php b/tests/src/Unit/PluginTestBase.php
new file mode 100644
index 0000000..4f38cae
--- /dev/null
+++ b/tests/src/Unit/PluginTestBase.php
@@ -0,0 +1,275 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit;
+
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\purge\Plugin\Purge\Purger\Exception\BadPluginBehaviorException;
+use Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface;
+use Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationBase;
+use Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface;
+use Drupal\purge\Plugin\Purge\Invalidation\InvalidationBase;
+use Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidPropertyException;
+use Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidExpressionException;
+use Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidStateException;
+use Drupal\purge\Plugin\Purge\Invalidation\Exception\MissingExpressionException;
+
+/**
+ * Provides an abstract test class to thoroughly test invalidation types.
+ *
+ * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface
+ */
+abstract class PluginTestBase extends KernelTestBase {
+
+  /**
+   * The plugin ID of the invalidation type being tested.
+   *
+   * @var string
+   */
+  protected $plugin_id;
+
+  /**
+   * String expressions valid to the invalidation type being tested.
+   *
+   * @var string[]|null
+   */
+  protected $expressions = NULL;
+
+  /**
+   * String expressions INvalid to the invalidation type being tested.
+   *
+   * @var string[]|null
+   */
+  protected $expressionsInvalid;
+
+  /**
+   * Set up the test.
+   */
+  public function setUp($switch_to_memory_queue = TRUE) {
+    parent::setUp($switch_to_memory_queue);
+    $this->initializeInvalidationFactoryService();
+  }
+
+  /**
+   * Retrieve a invalidation object provided by the plugin.
+   */
+  public function getInstance() {
+    return $this->purgeInvalidationFactory->get(
+      $this->plugin_id,
+      $this->expressions[0]
+    );
+  }
+
+  /**
+   * Retrieve a immutable invalidation object, which wraps the plugin.
+   */
+  public function getImmutableInstance() {
+    return $this->purgeInvalidationFactory->getImmutable(
+      $this->plugin_id,
+      $this->expressions[0]
+    );
+  }
+
+  /**
+   * Tests the code contract strictly enforced on invalidation type plugins.
+   */
+  public function testCodeContract() {
+    $this->assertTrue($this->getInstance() instanceof ImmutableInvalidationInterface);
+    $this->assertTrue($this->getInstance() instanceof InvalidationInterface);
+    $this->assertTrue($this->getInstance() instanceof ImmutableInvalidationBase);
+    $this->assertTrue($this->getInstance() instanceof InvalidationBase);
+    $this->assertTrue($this->getImmutableInstance() instanceof ImmutableInvalidationInterface);
+    $this->assertFalse($this->getImmutableInstance() instanceof InvalidationInterface);
+    $this->assertTrue($this->getImmutableInstance() instanceof ImmutableInvalidationBase);
+    $this->assertFalse($this->getImmutableInstance() instanceof InvalidationBase);
+  }
+
+  /**
+   * Tests \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidation.
+   */
+  public function testImmutable() {
+    $immutable = $this->getImmutableInstance();
+    $mutable = $this->getInstance();
+    $this->assertEquals($immutable->__toString(), $mutable->__toString());
+    $this->assertEquals($immutable->getExpression(), $mutable->getExpression());
+    $this->assertEquals($immutable->getState(), $mutable->getState());
+    $this->assertEquals($immutable->getStateString(), $mutable->getStateString());
+    $this->assertEquals($immutable->getType(), $mutable->getType());
+  }
+
+  /**
+   * Test if setting and getting the object state goes well.
+   *
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface::getProperties
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface::getProperty
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::deleteProperty
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setProperty
+   */
+  public function testProperties() {
+    $i = $this->getInstance();
+    // Verify that getProperties() has the right initial state (of emptyness).
+    $this->assertEquals($i->getProperties(), []);
+    // Verify that exceptions are thrown when they should.
+    $this->assertException('\LogicException', [$i, 'getProperty'], ['key1']);
+    $this->assertException('\LogicException', [$i, 'setProperty'], ['key1', 'foobar']);
+    $this->assertNoException('\LogicException', [$i, 'getProperties']);
+    $i->setStateContext('purger1');
+    $this->assertException('\LogicException', [$i, 'getProperties']);
+    $this->assertNoException('\LogicException', [$i, 'getProperty'], ['key1']);
+    $this->assertNoException('\LogicException', [$i, 'setProperty'], ['key1', 'foobar']);
+    // Verify retrieving and setting properties.
+    $this->assertNull($i->getProperty('doesntexist'));
+    $this->assertEquals($i->getProperty('key1'), 'foobar');
+    $this->assertNull($i->deleteProperty('key1'));
+    $this->assertNull($i->getProperty('key1'));
+    $this->assertNull($i->setProperty('key1', 'foobar2'));
+    $this->assertEquals($i->getProperty('key1'), 'foobar2');
+    // Switch state to add some more properties.
+    $i->setState(InvalidationInterface::FAILED);
+    $i->setStateContext('purger2');
+    $i->setProperty('key2', 'baz');
+    $i->setState(InvalidationInterface::FAILED);
+    $i->setStateContext(NULL);
+    // Verify that getProperties() works as it should.
+    $p = $i->getProperties();
+    $this->assertEquals(count($p), 2);
+    $this->assertTrue(isset($p['purger1']['key1']));
+    $this->assertEquals($p['purger1']['key1'], 'foobar2');
+    $this->assertTrue(isset($p['purger2']['key2']));
+    $this->assertEquals($p['purger2']['key2'], 'baz');
+  }
+
+  /**
+   * Test if setting and getting the object state goes well.
+   *
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setState
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getState
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getStateString
+   */
+  public function testState() {
+    $i = $this->getInstance();
+    // Test the initial state of the invalidation object. Then verify that a
+    // BadPluginBehaviorException is thrown when left as FRESH.
+    $this->assertEquals($i->getState(), InvalidationInterface::FRESH);
+    $this->assertEquals($i->getStateString(), 'FRESH');
+    $i->setStateContext('test');
+    $this->assertException('\Drupal\purge\Plugin\Purge\Purger\Exception\BadPluginBehaviorException', [$i, 'setStateContext'], [NULL]);
+    $i->setState(InvalidationInterface::FAILED);
+    $i->setStateContext(NULL);
+    // Verify that setting state in general context throws exceptions.
+    $this->assertException('\LogicException', [$i, 'setState'], [InvalidationInterface::FAILED]);
+    // Test \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setState catches bad input.
+    foreach (['2', 'FRESH', -1, 5, 100] as $badstate) {
+      $this->assertException('\Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidStateException', [$i, 'setState'], [$badstate]);
+    }
+    // Test setting normal states results in the same return state.
+    $test_states = [
+      InvalidationInterface::PROCESSING    => 'PROCESSING',
+      InvalidationInterface::SUCCEEDED     => 'SUCCEEDED',
+      InvalidationInterface::FAILED        => 'FAILED',
+      InvalidationInterface::NOT_SUPPORTED => 'NOT_SUPPORTED',
+    ];
+    $context = 0;
+    $i->setStateContext((string) $context);
+    foreach ($test_states as $state => $string) {
+      $this->assertNull($i->setStateContext((string) ($context++)));
+      $this->assertNull($i->setState($state));
+      $this->assertEquals($i->getState(), $state);
+      $this->assertEquals($i->getStateString(), $string);
+    }
+    $i->setStateContext(NULL);
+  }
+
+  /**
+   * Test if typecasting invalidation objects to strings gets us a string.
+   *
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__toString
+   */
+  public function testStringExpression() {
+    $this->assertEquals((string) $this->getInstance(), $this->expressions[0],
+      'The __toString method returns $expression.');
+  }
+
+  /**
+   * Test if all valid string expressions properly instantiate the object.
+   *
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__construct
+   */
+  public function testValidExpressions() {
+    if (is_null($this->expressions)) {
+      $invalidation = $this->purgeInvalidationFactory->get($this->plugin_id);
+    }
+    else {
+      foreach ($this->expressions as $e) {
+        $invalidation = $this->purgeInvalidationFactory->get($this->plugin_id, $e);
+      }
+    }
+  }
+
+  /**
+   * Test if all invalid string expressions fail to instantiate the object.
+   *
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::__construct
+   */
+  public function testInvalidExpressions($expressions = NULL) {
+    foreach ($this->expressionsInvalid as $exp) {
+      $thrown = FALSE;
+      try {
+        $invalidation = $this->purgeInvalidationFactory->get($this->plugin_id, $exp);
+      }
+      catch (\Exception $e) {
+        $thrown = $e;
+      }
+      if (is_null($exp)) {
+        $this->assertTrue($thrown instanceof MissingExpressionException, var_export($exp, TRUE));
+      }
+      else {
+        $this->assertTrue($thrown instanceof InvalidExpressionException, var_export($exp, TRUE));
+      }
+    }
+  }
+
+  /**
+   * Test retrieving the plugin ID and definition.
+   *
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getPluginId
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getType
+   * @see \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::getPluginDefinition
+   */
+  public function testPluginIdAndDefinition() {
+    // Test mutable objects.
+    $mutable = $this->getInstance();
+    $this->assertEquals($this->plugin_id, $mutable->getPluginId());
+    $this->assertEquals($this->plugin_id, $mutable->getType());
+    $d = $mutable->getPluginDefinition();
+    $this->assertTrue(is_array($d));
+    $this->assertTrue(is_array($d['examples']));
+    $this->assertTrue($d['label'] instanceof TranslatableMarkup);
+    $this->assertFalse(empty((string) $d['label']));
+    $this->assertTrue($d['description'] instanceof TranslatableMarkup);
+    $this->assertFalse(empty((string) $d['description']));
+    $this->assertTrue(isset($d['expression_required']));
+    $this->assertTrue(isset($d['expression_can_be_empty']));
+    $this->assertTrue(isset($d['expression_must_be_string']));
+    if (!$d["expression_required"]) {
+      $this->assertFalse($d["expression_can_be_empty"]);
+    }
+    // Test the immutable objects.
+    $immutable = $this->getImmutableInstance();
+    $this->assertEquals($this->plugin_id, $immutable->getPluginId());
+    $this->assertEquals($this->plugin_id, $immutable->getType());
+    $d = $immutable->getPluginDefinition();
+    $this->assertTrue(is_array($d));
+    $this->assertTrue(is_array($d['examples']));
+    $this->assertTrue($d['label'] instanceof TranslatableMarkup);
+    $this->assertFalse(empty((string) $d['label']));
+    $this->assertTrue($d['description'] instanceof TranslatableMarkup);
+    $this->assertFalse(empty((string) $d['description']));
+    $this->assertTrue(isset($d['expression_required']));
+    $this->assertTrue(isset($d['expression_can_be_empty']));
+    $this->assertTrue(isset($d['expression_must_be_string']));
+    if (!$d["expression_required"]) {
+      $this->assertFalse($d["expression_can_be_empty"]);
+    }
+  }
+
+}
diff --git a/tests/src/Unit/Processor/PluginManagerTest.php b/tests/src/Unit/Processor/PluginManagerTest.php
new file mode 100644
index 0000000..8820b1c
--- /dev/null
+++ b/tests/src/Unit/Processor/PluginManagerTest.php
@@ -0,0 +1,77 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Processor;
+
+use Drupal\Tests\purge\Unit\KernelServiceTestBase;
+use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
+use Drupal\Core\Plugin\DefaultPluginManager;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Processor\PluginManager.
+ *
+ * @group purge
+ * @see \Drupal\Core\Plugin\DefaultPluginManager
+ */
+class PluginManagerTest extends KernelServiceTestBase {
+  protected $serviceId = 'plugin.manager.purge.processor';
+  public static $modules = ['purge_processor_test'];
+
+  /**
+   * All metadata from \Drupal\purge\Annotation\PurgeProcessor.
+   *
+   * @var string[]
+   */
+  protected $annotationFields = [
+    'provider',
+    'class',
+    'id',
+    'label',
+    'description',
+    'enable_by_default',
+    'configform',
+  ];
+
+  /**
+   * All bundled plugins in purge core, including in the test module.
+   *
+   * @var string[]
+   */
+  protected $plugins = [
+    'a',
+    'b',
+    'c',
+    'withform',
+  ];
+
+  /**
+   * Test if the plugin manager is built as we'd like.
+   */
+  public function testCodeContract() {
+    $this->assertTrue($this->service instanceof PluginManagerInterface);
+    $this->assertTrue($this->service instanceof DefaultPluginManager);
+    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
+  }
+
+  /**
+   * Test the plugins we expect to be available.
+   */
+  public function testDefinitions() {
+    $definitions = $this->service->getDefinitions();
+    foreach ($this->plugins as $plugin_id) {
+      $this->assertTrue(isset($definitions[$plugin_id]));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      $this->assertTrue(in_array($plugin_id, $this->plugins));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      foreach ($md as $field => $value) {
+        $this->assertTrue(in_array($field, $this->annotationFields));
+      }
+      foreach ($this->annotationFields as $field) {
+        $this->assertTrue(isset($md[$field]));
+      }
+    }
+  }
+
+}
diff --git a/tests/src/Unit/Purger/PluginManagerTest.php b/tests/src/Unit/Purger/PluginManagerTest.php
new file mode 100644
index 0000000..d13b8cf
--- /dev/null
+++ b/tests/src/Unit/Purger/PluginManagerTest.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace Drupal\Tests\purge\Unit\Purger;
+
+use Drupal\Tests\purge\Unit\KernelServiceTestBase;
+use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
+use Drupal\Core\Plugin\DefaultPluginManager;
+
+/**
+ * Tests \Drupal\purge\Plugin\Purge\Purger\PluginManager.
+ *
+ * @group purge
+ * @see \Drupal\Core\Plugin\DefaultPluginManager
+ */
+class PluginManagerTest extends KernelServiceTestBase {
+  protected $serviceId = 'plugin.manager.purge.purgers';
+  public static $modules = ['purge_purger_test'];
+
+  /**
+   * All metadata from \Drupal\purge\Annotation\PurgePurger.
+   *
+   * @var string[]
+   */
+  protected $annotationFields = [
+    'class',
+    'provider',
+    'id',
+    'label',
+    'configform',
+    'cooldown_time',
+    'description',
+    'multi_instance',
+    'types',
+  ];
+
+  /**
+   * All bundled plugins in purge core, including in the test module.
+   *
+   * @var string[]
+   */
+  protected $plugins = [
+    'a',
+    'b',
+    'c',
+    'good',
+    'withform',
+  ];
+
+  /**
+   * Test if the plugin manager is built as we'd like.
+   */
+  public function testCodeContract() {
+    $this->assertTrue($this->service instanceof PluginManagerInterface);
+    $this->assertTrue($this->service instanceof DefaultPluginManager);
+    $this->assertTrue($this->service instanceof CachedDiscoveryInterface);
+  }
+
+  /**
+   * Test the plugins we expect to be available.
+   */
+  public function testDefinitions() {
+    $definitions = $this->service->getDefinitions();
+    foreach ($this->plugins as $plugin_id) {
+      $this->assertTrue(isset($definitions[$plugin_id]));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      $this->assertTrue(in_array($plugin_id, $this->plugins));
+    }
+    foreach ($definitions as $plugin_id => $md) {
+      foreach ($md as $field => $value) {
+        $this->assertTrue(in_array($field, $this->annotationFields));
+      }
+      foreach ($this->annotationFields as $field) {
+        $this->assertTrue(isset($md[$field]));
+      }
+    }
+  }
+
+}
