diff --git a/composer.json b/composer.json
index 71dcc96..db1e3a4 100644
--- a/composer.json
+++ b/composer.json
@@ -50,10 +50,12 @@
     "scripts": {
         "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
         "post-autoload-dump": [
-          "Drupal\\Core\\Composer\\Composer::ensureHtaccess"
+          "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
+          "Drupal\\Core\\Composer\\Composer::upgradePHPUnit"
         ],
         "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
         "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
+        "drupal-phpunit-upgrade": "@composer upgrade phpunit/phpunit --with-dependencies --no-progress",
         "phpcs": "phpcs --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --",
         "phpcbf": "phpcbf --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --"
     },
diff --git a/core/composer.json b/core/composer.json
index 31bc51a..c4bb384 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -44,7 +44,7 @@
         "jcalderonzumba/gastonjs": "^1.0.2",
         "jcalderonzumba/mink-phantomjs-driver": "^0.3.1",
         "mikey179/vfsStream": "^1.2",
-        "phpunit/phpunit": ">=4.8.35 <5",
+        "phpunit/phpunit": "^4.8.35 || ^6.1",
         "phpspec/prophecy": "^1.4",
         "symfony/css-selector": "~3.2.8",
         "symfony/phpunit-bridge": "^3.4.0@beta"
diff --git a/core/lib/Drupal/Component/Assertion/Inspector.php b/core/lib/Drupal/Component/Assertion/Inspector.php
index 17cd434..dbf3f51 100644
--- a/core/lib/Drupal/Component/Assertion/Inspector.php
+++ b/core/lib/Drupal/Component/Assertion/Inspector.php
@@ -13,7 +13,7 @@
  *
  * Example call:
  * @code
- *   assert('Drupal\\Component\\Assertion\\Inspector::assertAllStrings($array)');
+ *   assert(Inspector::assertAllStrings($array));
  * @endcode
  *
  * @ingroup php_assert
@@ -187,8 +187,8 @@ public static function assertAllStrictArrays($traversable) {
    * As an example, this assertion tests for the keys of a theme registry.
    *
    * @code
-   *   assert('Drupal\\Component\\Assertion\\Inspector::assertAllHaveKey(
-   *     $arrayToTest, "type", "theme path", "function", "template", "variables", "render element", "preprocess functions")');
+   *   assert(Inspector::assertAllHaveKey(
+   *     $arrayToTest, "type", "theme path", "function", "template", "variables", "render element", "preprocess functions"));
    * @endcode
    *
    * Note: If a method requires certain keys to be present it will usually be
@@ -375,16 +375,13 @@ public static function assertAllRegularExpressionMatch($pattern, $traversable) {
    * Here are some examples:
    * @code
    *   // Just test all are objects, like a cache.
-   *   assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects(
-   *     $collection');
+   *   assert(Inspector::assertAllObjects($collection));
    *
    *   // Test if traversable objects (arrays won't pass this)
-   *   assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects(
-   *     $collection', \'\\Traversable\');
+   *   assert(Inspector::assertAllObjects($collection, '\\Traversable'));
    *
    *   // Test for the Foo class or Bar\None interface
-   *   assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects(
-   *     $collection', \'\\Foo\', \'\\Bar\\None\'');
+   *   assert(Inspector::assertAllObjects($collection, '\\Foo', '\\Bar\\None'));
    * @endcode
    *
    * @param mixed $traversable
diff --git a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
index e7c2941..c32017e 100644
--- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
+++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
@@ -344,7 +344,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) {
     $i = 0;
     $j = 0;
 
-    $this::USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)');
+    $this::USE_ASSERTS && assert(sizeof($lines) == sizeof($changed));
     $len = sizeof($lines);
     $other_len = sizeof($other_changed);
 
@@ -364,7 +364,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) {
         $j++;
       }
       while ($i < $len && !$changed[$i]) {
-        $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
+        $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]);
         $i++;
         $j++;
         while ($j < $other_len && $other_changed[$j]) {
@@ -400,11 +400,11 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) {
           while ($start > 0 && $changed[$start - 1]) {
             $start--;
           }
-          $this::USE_ASSERTS && assert('$j > 0');
+          $this::USE_ASSERTS && assert($j > 0);
           while ($other_changed[--$j]) {
             continue;
           }
-          $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
+          $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]);
         }
 
         /*
@@ -427,7 +427,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) {
           while ($i < $len && $changed[$i]) {
             $i++;
           }
-          $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
+          $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]);
           $j++;
           if ($j < $other_len && $other_changed[$j]) {
             $corresponding = $i;
@@ -445,11 +445,11 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) {
       while ($corresponding < $i) {
         $changed[--$start] = 1;
         $changed[--$i] = 0;
-        $this::USE_ASSERTS && assert('$j > 0');
+        $this::USE_ASSERTS && assert($j > 0);
         while ($other_changed[--$j]) {
           continue;
         }
-        $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
+        $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]);
       }
     }
   }
diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
index 97a14ec..353dac2 100644
--- a/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -451,9 +451,9 @@ public static function escape($text) {
    *   The updated (X)HTML snippet.
    */
   public static function transformRootRelativeUrlsToAbsolute($html, $scheme_and_host) {
-    assert('empty(array_diff(array_keys(parse_url($scheme_and_host)), ["scheme", "host", "port"]))', '$scheme_and_host contains scheme, host and port at most.');
-    assert('isset(parse_url($scheme_and_host)["scheme"])', '$scheme_and_host is absolute and hence has a scheme.');
-    assert('isset(parse_url($scheme_and_host)["host"])', '$base_url is absolute and hence has a host.');
+    assert(empty(array_diff(array_keys(parse_url($scheme_and_host)), ["scheme", "host", "port"])), '$scheme_and_host contains scheme, host and port at most.');
+    assert(isset(parse_url($scheme_and_host)["scheme"]), '$scheme_and_host is absolute and hence has a scheme.');
+    assert(isset(parse_url($scheme_and_host)["host"]), '$base_url is absolute and hence has a host.');
 
     $html_dom = Html::load($html);
     $xpath = new \DOMXpath($html_dom);
diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php
index f4962ec..0070e08 100644
--- a/core/lib/Drupal/Core/Access/AccessResult.php
+++ b/core/lib/Drupal/Core/Access/AccessResult.php
@@ -39,7 +39,7 @@
    *   isNeutral() will be TRUE.
    */
   public static function neutral($reason = NULL) {
-    assert('is_string($reason) || is_null($reason)');
+    assert(is_string($reason) || is_null($reason));
     return new AccessResultNeutral($reason);
   }
 
@@ -64,7 +64,7 @@ public static function allowed() {
    *   isForbidden() will be TRUE.
    */
   public static function forbidden($reason = NULL) {
-    assert('is_string($reason) || is_null($reason)');
+    assert(is_string($reason) || is_null($reason));
     return new AccessResultForbidden($reason);
   }
 
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 91f702f..07df709 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -129,11 +129,11 @@ public function buildByExtension($extension) {
         //   properly resolve dependencies for all (css) libraries per category,
         //   and only once prior to rendering out an HTML page.
         if ($type == 'css' && !empty($library[$type])) {
-          assert('\Drupal\Core\Asset\LibraryDiscoveryParser::validateCssLibrary($library[$type]) < 2', 'CSS files should be specified as key/value pairs, where the values are configuration options. See https://www.drupal.org/node/2274843.');
-          assert('\Drupal\Core\Asset\LibraryDiscoveryParser::validateCssLibrary($library[$type]) === 0', 'CSS must be nested under a category. See https://www.drupal.org/node/2274843.');
+          assert(static::validateCssLibrary($library[$type]) < 2, 'CSS files should be specified as key/value pairs, where the values are configuration options. See https://www.drupal.org/node/2274843.');
+          assert(static::validateCssLibrary($library[$type]) === 0, 'CSS must be nested under a category. See https://www.drupal.org/node/2274843.');
           foreach ($library[$type] as $category => $files) {
             $category_weight = 'CSS_' . strtoupper($category);
-            assert('defined($category_weight)', 'Invalid CSS category: ' . $category . '. See https://www.drupal.org/node/2274843.');
+            assert(defined($category_weight), 'Invalid CSS category: ' . $category . '. See https://www.drupal.org/node/2274843.');
             foreach ($files as $source => $options) {
               if (!isset($options['weight'])) {
                 $options['weight'] = 0;
diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php
index d7847ff..e04e014 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackend.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
+
 /**
  * Stores cache items in the Alternative PHP Cache User Cache (APCu).
  */
@@ -161,7 +163,7 @@ protected function prepareItem($cache, $allow_invalid) {
    * {@inheritdoc}
    */
   public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = []) {
-    assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
+    assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.');
     $tags = array_unique($tags);
     $cache = new \stdClass();
     $cache->cid = $cid;
diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php
index 9257aab..53aa181 100644
--- a/core/lib/Drupal/Core/Cache/Cache.php
+++ b/core/lib/Drupal/Core/Cache/Cache.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
 use Drupal\Core\Database\Query\SelectInterface;
 
 /**
@@ -29,7 +30,7 @@ class Cache {
    */
   public static function mergeContexts(array $a = [], array $b = []) {
     $cache_contexts = array_unique(array_merge($a, $b));
-    assert('\Drupal::service(\'cache_contexts_manager\')->assertValidTokens($cache_contexts)');
+    assert(\Drupal::service('cache_contexts_manager')->assertValidTokens($cache_contexts));
     sort($cache_contexts);
     return $cache_contexts;
   }
@@ -54,7 +55,7 @@ public static function mergeContexts(array $a = [], array $b = []) {
    *   The merged array of cache tags.
    */
   public static function mergeTags(array $a = [], array $b = []) {
-    assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($a) && \Drupal\Component\Assertion\Inspector::assertAllStrings($b)', 'Cache tags must be valid strings');
+    assert(Inspector::assertAllStrings($a) && Inspector::assertAllStrings($b), 'Cache tags must be valid strings');
 
     $cache_tags = array_unique(array_merge($a, $b));
     sort($cache_tags);
@@ -96,7 +97,7 @@ public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT
    *   An array of cache tags.
    *
    * @deprecated
-   *   Use assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)');
+   *   Use assert(Inspector::assertAllStrings($tags));
    *
    * @throws \LogicException
    */
diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php
index b0c9f45..912b60f 100644
--- a/core/lib/Drupal/Core/Cache/CacheCollector.php
+++ b/core/lib/Drupal/Core/Cache/CacheCollector.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
 use Drupal\Component\Utility\Crypt;
 use Drupal\Core\DestructableInterface;
 use Drupal\Core\Lock\LockBackendInterface;
@@ -111,7 +112,7 @@
    *   (optional) The tags to specify for the cache item.
    */
   public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = []) {
-    assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
+    assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.');
     $this->cid = $cid;
     $this->cache = $cache;
     $this->tags = $tags;
diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
index ceb8f49..820da98 100644
--- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
+++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 
 /**
@@ -22,7 +23,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {
    * {@inheritdoc}
    */
   public function invalidateTags(array $tags) {
-    assert('Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
+    assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.');
 
     // Notify all added cache tags invalidators.
     foreach ($this->invalidators as $invalidator) {
diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
index 9a555f8..056f838 100644
--- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
+++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
@@ -100,7 +100,7 @@ public function getLabels($include_calculated_cache_contexts = FALSE) {
    *   cacheability metadata.
    */
   public function convertTokensToKeys(array $context_tokens) {
-    assert('$this->assertValidTokens($context_tokens)');
+    assert($this->assertValidTokens($context_tokens));
     $cacheable_metadata = new CacheableMetadata();
     $optimized_tokens = $this->optimizeTokens($context_tokens);
     // Iterate over cache contexts that have been optimized away and get their
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index 747186b..88f018f 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
 use Drupal\Component\Utility\Crypt;
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Database\SchemaObjectExistsException;
@@ -222,7 +223,7 @@ protected function doSetMultiple(array $items) {
         'tags' => [],
       ];
 
-      assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($item[\'tags\'])', 'Cache Tags must be strings.');
+      assert(Inspector::assertAllStrings($item['tags']), 'Cache Tags must be strings.');
       $item['tags'] = array_unique($item['tags']);
       // Sort the cache tags so that they are stored consistently in the DB.
       sort($item['tags']);
diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php
index edda4d3..99e6e3a 100644
--- a/core/lib/Drupal/Core/Cache/MemoryBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
+
 /**
  * Defines a memory cache implementation.
  *
@@ -98,7 +100,7 @@ protected function prepareItem($cache, $allow_invalid) {
    * {@inheritdoc}
    */
   public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
-    assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
+    assert(Inspector::assertAllStrings($tags), 'Cache Tags must be strings.');
     $tags = array_unique($tags);
     // Sort the cache tags so that they are stored consistently in the database.
     sort($tags);
diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php
index 2404493..d3af7f5 100644
--- a/core/lib/Drupal/Core/Cache/PhpBackend.php
+++ b/core/lib/Drupal/Core/Cache/PhpBackend.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Assertion\Inspector;
 use Drupal\Core\PhpStorage\PhpStorageFactory;
 use Drupal\Component\Utility\Crypt;
 
@@ -143,7 +144,8 @@ protected function prepareItem($cache, $allow_invalid) {
    * {@inheritdoc}
    */
   public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
-    assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
+    assert(Inspector::assertAllStrings($tags), 'Cache Tags must be strings.');
+
     $item = (object) [
       'cid' => $cid,
       'data' => $data,
diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php
index 016f93a..8bfc7bb 100644
--- a/core/lib/Drupal/Core/Composer/Composer.php
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -6,6 +6,7 @@
 use Composer\Script\Event;
 use Composer\Installer\PackageEvent;
 use Composer\Semver\Constraint\Constraint;
+use PHPUnit\Runner\Version;
 
 /**
  * Provides static functions for composer script events.
@@ -144,6 +145,24 @@ public static function ensureHtaccess(Event $event) {
   }
 
   /**
+   * Fires the drupal-phpunit-upgrade script event if necessary.
+   *
+   * @param \Composer\Script\Event $event
+   */
+  public static function upgradePHPUnit(Event $event) {
+    if (class_exists('PHPUnit_Runner_Version')) {
+      $phpunit_version = \PHPUnit_Runner_Version::id();
+    }
+    if (class_exists('\PHPUnit\Runner\Version')) {
+      $phpunit_version = Version::id();
+    }
+    // @todo if we haven't determine version throw an error.
+    if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.1') >= 0 && version_compare($phpunit_version, '6.0') < 0) {
+      $event->getComposer()->getEventDispatcher()->dispatchScript('drupal-phpunit-upgrade');
+    }
+  }
+
+  /**
    * Remove possibly problematic test files from vendored projects.
    *
    * @param \Composer\Installer\PackageEvent $event
diff --git a/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php b/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php
index f51dd36..aa51cbc 100644
--- a/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php
+++ b/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php
@@ -22,7 +22,7 @@ class BundleEntityFormBase extends EntityForm {
   protected function protectBundleIdElement(array $form) {
     $entity = $this->getEntity();
     $id_key = $entity->getEntityType()->getKey('id');
-    assert('isset($form[$id_key])');
+    assert(isset($form[$id_key]));
     $element = &$form[$id_key];
 
     // Make sure the element is not accidentally re-enabled if it has already
diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index 7c736e8..34ce858 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -250,7 +250,7 @@ public function id() {
   /**
    * {@inheritdoc}
    */
-  public function preSave(EntityStorageInterface $storage, $update = TRUE) {
+  public function preSave(EntityStorageInterface $storage) {
     // Ensure that a region is set on each component.
     foreach ($this->getComponents() as $name => $component) {
       $this->handleHiddenType($name, $component);
@@ -263,7 +263,7 @@ public function preSave(EntityStorageInterface $storage, $update = TRUE) {
 
     ksort($this->content);
     ksort($this->hidden);
-    parent::preSave($storage, $update);
+    parent::preSave($storage);
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
index 5b659a0..7cb585f 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
@@ -245,7 +245,7 @@ public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterfac
    *   The schema data.
    */
   protected function getSchemaFromStorageDefinition(FieldStorageDefinitionInterface $storage_definition) {
-    assert('!$storage_definition->hasCustomStorage();');
+    assert(!$storage_definition->hasCustomStorage());
     $table_mapping = $this->storage->getTableMapping();
     $schema = [];
     if ($table_mapping->requiresDedicatedTableStorage($storage_definition)) {
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index 152005b..52bf9c9 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -97,18 +97,6 @@ public function filterEmptyItems() {
 
   /**
    * {@inheritdoc}
-   * @todo Revisit the need when all entity types are converted to NG entities.
-   */
-  public function getValue($include_computed = FALSE) {
-    $values = [];
-    foreach ($this->list as $delta => $item) {
-      $values[$delta] = $item->getValue($include_computed);
-    }
-    return $values;
-  }
-
-  /**
-   * {@inheritdoc}
    */
   public function setValue($values, $notify = TRUE) {
     // Support passing in only the value of the first item, either as a literal
diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
index 62260a2..389850c 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Plugin;
 
+use Drupal\Component\Assertion\Inspector;
 use Drupal\Component\Plugin\Definition\PluginDefinitionInterface;
 use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
 use Drupal\Core\Cache\CacheableDependencyInterface;
@@ -148,7 +149,7 @@ public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInte
    *   definitions should be cleared along with other, related cache entries.
    */
   public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = []) {
-    assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($cache_tags)', 'Cache Tags must be strings.');
+    assert(Inspector::assertAllStrings($cache_tags), 'Cache Tags must be strings.');
     $this->cacheBackend = $cache_backend;
     $this->cacheKey = $cache_key;
     $this->cacheTags = $cache_tags;
diff --git a/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php
index 8e90faa..7ca4123 100644
--- a/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php
+++ b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php
@@ -35,7 +35,7 @@ public function processPlaceholders(array $placeholders) {
     }
 
     // Assert that there is at least one strategy.
-    assert('!empty($this->placeholderStrategies)', 'At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.');
+    assert(!empty($this->placeholderStrategies), 'At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.');
 
     $new_placeholders = [];
 
@@ -44,7 +44,7 @@ public function processPlaceholders(array $placeholders) {
     // and this uses a variation of the "chain of responsibility" design pattern.
     foreach ($this->placeholderStrategies as $strategy) {
       $processed_placeholders = $strategy->processPlaceholders($placeholders);
-      assert('array_intersect_key($processed_placeholders, $placeholders) === $processed_placeholders', 'Processed placeholders must be a subset of all placeholders.');
+      assert(array_intersect_key($processed_placeholders, $placeholders) === $processed_placeholders, 'Processed placeholders must be a subset of all placeholders.');
       $placeholders = array_diff_key($placeholders, $processed_placeholders);
       $new_placeholders += $processed_placeholders;
 
diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php
index ef658c2..79aba6f 100644
--- a/core/modules/big_pipe/src/Render/BigPipe.php
+++ b/core/modules/big_pipe/src/Render/BigPipe.php
@@ -420,7 +420,7 @@ protected function sendNoJsPlaceholders($html, $no_js_placeholders, AttachedAsse
       }
 
       $placeholder = $fragment;
-      assert('isset($no_js_placeholders[$placeholder])');
+      assert(isset($no_js_placeholders[$placeholder]));
       $token = Crypt::randomBytesBase64(55);
 
       // Render the placeholder, but include the cumulative settings assets, so
@@ -629,7 +629,7 @@ protected function sendPlaceholders(array $placeholders, array $placeholder_orde
    *   AJAX page state.
    */
   protected function filterEmbeddedResponse(Request $fake_request, Response $embedded_response) {
-    assert('$embedded_response instanceof \Drupal\Core\Render\HtmlResponse || $embedded_response instanceof \Drupal\Core\Ajax\AjaxResponse');
+    assert($embedded_response instanceof HtmlResponse || $embedded_response instanceof AjaxResponse);
     return $this->filterResponse($fake_request, HttpKernelInterface::SUB_REQUEST, $embedded_response);
   }
 
@@ -649,7 +649,7 @@ protected function filterEmbeddedResponse(Request $fake_request, Response $embed
    *   The filtered response.
    */
   protected function filterResponse(Request $request, $request_type, Response $response) {
-    assert('$request_type === \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST || $request_type === \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST');
+    assert($request_type === HttpKernelInterface::MASTER_REQUEST || $request_type === HttpKernelInterface::SUB_REQUEST);
     $this->requestStack->push($request);
     $event = new FilterResponseEvent($this->httpKernel, $request, $request_type, $response);
     $this->eventDispatcher->dispatch(KernelEvents::RESPONSE, $event);
diff --git a/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php b/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php
index 94b8923..66ed363 100644
--- a/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php
+++ b/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php
@@ -9,6 +9,7 @@
 use Drupal\Core\Form\EnforcedResponseException;
 use Drupal\Core\Render\AttachmentsInterface;
 use Drupal\Core\Render\AttachmentsResponseProcessorInterface;
+use Drupal\Core\Render\HtmlResponse;
 use Drupal\Core\Render\HtmlResponseAttachmentsProcessor;
 use Drupal\Core\Render\RendererInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
@@ -57,7 +58,7 @@ public function __construct(AttachmentsResponseProcessorInterface $html_response
    * {@inheritdoc}
    */
   public function processAttachments(AttachmentsInterface $response) {
-    assert('$response instanceof \Drupal\Core\Render\HtmlResponse');
+    assert($response instanceof HtmlResponse);
 
     // First, render the actual placeholders; this will cause the BigPipe
     // placeholder strategy to generate BigPipe placeholders. We need those to
diff --git a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
index 3d9f45c..3e0f460 100644
--- a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
+++ b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
@@ -180,7 +180,7 @@ protected function doProcessPlaceholders(array $placeholders) {
    *   a placeholder for a HTML attribute value or a subset of it).
    */
   protected static function placeholderIsAttributeSafe($placeholder) {
-    assert('is_string($placeholder)');
+    assert(is_string($placeholder));
     return $placeholder[0] !== '<' || $placeholder !== Html::normalize($placeholder);
   }
 
diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
index 1569411..5d3a20b 100644
--- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
+++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
@@ -49,6 +49,7 @@ public function setUpDisplayVariant($configuration = [], $definition = []) {
     $container = new Container();
     $cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
       ->disableOriginalConstructor()
+      ->setMethods(['assertValidTokens'])
       ->getMock();
     $container->set('cache_contexts_manager', $cache_context_manager);
     $cache_context_manager->expects($this->any())
@@ -209,9 +210,6 @@ public function testBuild(array $blocks_config, $visible_block_count, array $exp
     $title_block_plugin = $this->getMock('Drupal\Core\Block\TitleBlockPluginInterface');
     foreach ($blocks_config as $block_id => $block_config) {
       $block = $this->getMock('Drupal\block\BlockInterface');
-      $block->expects($this->any())
-        ->method('getContexts')
-        ->willReturn([]);
       $block->expects($this->atLeastOnce())
         ->method('getPlugin')
         ->willReturn($block_config[1] ? $main_content_block_plugin : ($block_config[2] ? $messages_block_plugin : ($block_config[3] ? $title_block_plugin : $block_plugin)));
diff --git a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
index 89542d3..e946bfb 100644
--- a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
+++ b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
@@ -7,6 +7,7 @@
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Provides a local task that shows the amount of unapproved comments.
@@ -53,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return $this->t('Unapproved comments (@count)', ['@count' => $this->commentStorage->getUnapprovedCount()]);
   }
 
diff --git a/core/modules/comment/src/Tests/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php
index 3d10858..c364e26 100644
--- a/core/modules/comment/src/Tests/Views/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
@@ -63,8 +63,8 @@
    */
   protected $comment;
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
 
diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
index 8a0a0f5..8aaae75 100644
--- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
@@ -269,7 +269,7 @@ public function getLinkCombinations() {
    */
   protected function getMockNode($has_field, $comment_status, $form_location, $comment_count) {
     $node = $this->getMock('\Drupal\node\NodeInterface');
-    $node->expects($this->once())
+    $node->expects($this->any())
       ->method('hasField')
       ->willReturn($has_field);
 
diff --git a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
index 63145a5..fff82f0 100644
--- a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
+++ b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Menu\ContextualLinkDefault;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a contextual link plugin with a dynamic title.
@@ -22,7 +23,7 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     // Use the custom 'config_translation_plugin_id' plugin definition key to
     // retrieve the title. We need to retrieve a runtime title (as opposed to
     // storing the title on the plugin definition for the link) because it
diff --git a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
index 5a88d91..0aa84d2 100644
--- a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
+++ b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Menu\LocalTaskDefault;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a local task plugin with a dynamic title.
@@ -22,7 +23,7 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     // Take custom 'config_translation_plugin_id' plugin definition key to
     // retrieve title. We need to retrieve a runtime title (as opposed to
     // storing the title on the plugin definition for the link) because
diff --git a/core/modules/contact/tests/src/Unit/MailHandlerTest.php b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
index 04a12b8..a96b0c6 100644
--- a/core/modules/contact/tests/src/Unit/MailHandlerTest.php
+++ b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
@@ -367,7 +367,7 @@ protected function getAuthenticatedMockMessage($copy_sender = FALSE) {
     $recipient->expects($this->once())
       ->method('getEmail')
       ->willReturn('user2@drupal.org');
-    $recipient->expects($this->once())
+    $recipient->expects($this->any())
       ->method('getDisplayName')
       ->willReturn('user2');
     $recipient->expects($this->once())
diff --git a/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php b/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php
index 2fefc01..d72000b 100644
--- a/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php
+++ b/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php
@@ -217,7 +217,7 @@ public function testInvalidStateMultilingual() {
   /**
    * Tests that content without prior moderation information can be moderated.
    */
-  public function testLegacyContent() {
+  public function testExistingContentWithNoModeration() {
     $node_type = NodeType::create([
       'type' => 'example',
     ]);
@@ -251,7 +251,7 @@ public function testLegacyContent() {
   /**
    * Tests that content without prior moderation information can be translated.
    */
-  public function testLegacyMultilingualContent() {
+  public function testExistingMultilingualContentWithNoModeration() {
     // Enable French.
     ConfigurableLanguage::createFromLangcode('fr')->save();
 
diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php
index 2208ab7..73fb117 100644
--- a/core/modules/datetime/src/DateTimeComputed.php
+++ b/core/modules/datetime/src/DateTimeComputed.php
@@ -37,7 +37,7 @@ public function __construct(DataDefinitionInterface $definition, $name = NULL, T
   /**
    * {@inheritdoc}
    */
-  public function getValue($langcode = NULL) {
+  public function getValue() {
     if ($this->date !== NULL) {
       return $this->date;
     }
diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
index 0f068ab..854352e 100644
--- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
+++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
@@ -43,8 +43,8 @@
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     // Add a date field to page nodes.
     $node_type = NodeType::create([
diff --git a/core/modules/field/src/Tests/Views/FieldTestBase.php b/core/modules/field/src/Tests/Views/FieldTestBase.php
index f04e19f..c01e960 100644
--- a/core/modules/field/src/Tests/Views/FieldTestBase.php
+++ b/core/modules/field/src/Tests/Views/FieldTestBase.php
@@ -42,8 +42,8 @@
    */
   public $fields;
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     // Ensure the page node type exists.
     NodeType::create([
diff --git a/core/modules/field/src/Tests/Views/FieldUITest.php b/core/modules/field/src/Tests/Views/FieldUITest.php
index 851b7bd..efe7685 100644
--- a/core/modules/field/src/Tests/Views/FieldUITest.php
+++ b/core/modules/field/src/Tests/Views/FieldUITest.php
@@ -38,8 +38,8 @@ class FieldUITest extends FieldTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     $this->account = $this->drupalCreateUser(['administer views']);
     $this->drupalLogin($this->account);
diff --git a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
index dfbb89b..da958e9 100644
--- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
@@ -41,8 +41,8 @@ class HandlerFieldFieldTest extends FieldTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     // Setup basic fields.
     $this->setUpFieldStorages(3);
diff --git a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
index 6a5f53b..45e016d 100644
--- a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
+++ b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
@@ -30,8 +30,8 @@ class RelationshipUserFileDataTest extends ViewTestBase {
    */
   public static $testViews = ['test_file_user_file_data'];
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     // Create the user profile field and instance.
     FieldStorageConfig::create([
diff --git a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php
index e0e1934..0ab8ba4 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php
@@ -20,6 +20,7 @@ class CckFileTest extends MigrateDrupalTestBase {
    * Tests configurability of file migration name.
    *
    * @covers ::__construct
+   * @expectedDeprecation CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.
    */
   public function testConfigurableFileMigration() {
     $migration = Migration::create($this->container, [], 'custom_migration', []);
diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
index 5bad279..8781ef1 100644
--- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
@@ -17,6 +17,8 @@ class CckFileTest extends UnitTestCase {
 
   /**
    * Tests that alt and title attributes are included in transformed values.
+   *
+   * @expectedDeprecation CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.
    */
   public function testTransformAltTitle() {
     $executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php
index a51446b..efc9266 100644
--- a/core/modules/forum/src/Form/Overview.php
+++ b/core/modules/forum/src/Form/Overview.php
@@ -8,6 +8,7 @@
 use Drupal\Core\Url;
 use Drupal\taxonomy\Form\OverviewTerms;
 use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\taxonomy\VocabularyInterface;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
 /**
@@ -47,7 +48,7 @@ public function getFormId() {
   /**
    * {@inheritdoc}
    */
-  public function buildForm(array $form, FormStateInterface $form_state) {
+  public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
     $forum_config = $this->config('forum.settings');
     $vid = $forum_config->get('vocabulary');
     $vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
diff --git a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
index 55cecc0..374981f 100644
--- a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
+++ b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
@@ -30,8 +30,8 @@ class RelationshipUserImageDataTest extends ViewTestBase {
    */
   public static $testViews = ['test_image_user_image_data'];
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     // Create the user profile field and instance.
     FieldStorageConfig::create([
diff --git a/core/modules/layout_builder/src/Form/UpdateBlockForm.php b/core/modules/layout_builder/src/Form/UpdateBlockForm.php
index 2f2aa60..dfa33e0 100644
--- a/core/modules/layout_builder/src/Form/UpdateBlockForm.php
+++ b/core/modules/layout_builder/src/Form/UpdateBlockForm.php
@@ -39,7 +39,7 @@ public function getFormId() {
    * @return array
    *   The form array.
    */
-  public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $region = NULL, $uuid = NULL) {
+  public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $region = NULL, $uuid = NULL, array $configuration = []) {
     /** @var \Drupal\layout_builder\Field\LayoutSectionItemInterface $field */
     $field = $entity->layout_builder__layout->get($delta);
     $block = $field->getSection()->getBlock($region, $uuid);
diff --git a/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php b/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
index 80913ec..968c02f 100644
--- a/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
+++ b/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
@@ -38,8 +38,8 @@ class LinkViewsTokensTest extends ViewTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
     ViewTestData::createTestViews(get_class($this), ['link_test_views']);
 
     // Create Basic page node type.
diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php
index 896c15c..14345a6 100644
--- a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php
+++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php
@@ -53,6 +53,8 @@ protected function setUp() {
 
   /**
    * @covers ::processCckFieldValues
+   * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
+   * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.
    */
   public function testProcessCckFieldValues() {
     $this->plugin->processFieldInstance($this->migration);
diff --git a/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php b/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php
index 7029d72..dc3fe77 100644
--- a/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php
+++ b/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php
@@ -46,6 +46,8 @@ protected function setUp() {
 
   /**
    * @covers ::processCckFieldValues
+   * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
+   * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.
    */
   public function testProcessCckFieldValues() {
     $this->plugin->processCckFieldValues($this->migration, 'somefieldname', []);
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
index 8cee6dd..11f32cf 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
@@ -108,7 +108,7 @@ public function getIds() {
   /**
    * {@inheritdoc}
    */
-  public function count() {
+  public function count($refresh = FALSE) {
     return count($this->dataRows);
   }
 
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
index 5f44035..09f8a95 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
@@ -58,7 +58,7 @@ public function getIds() {
   /**
    * {@inheritdoc}
    */
-  public function count() {
+  public function count($refresh = FALSE) {
     return 1;
   }
 
diff --git a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php
index 576539e..ee56e32 100644
--- a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php
+++ b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php
@@ -9,7 +9,6 @@
 use Drupal\migrate\MigrateExecutableInterface;
 use Drupal\migrate\Row;
 use GuzzleHttp\Client;
-use GuzzleHttp\Psr7\Response;
 
 /**
  * Tests the download process plugin.
@@ -100,14 +99,8 @@ public function testWriteProtectedDestination() {
    *   The local URI of the downloaded file.
    */
   protected function doTransform($destination_uri, $configuration = []) {
-    // The HTTP client will return a file with contents 'It worked!'
-    $body = fopen('data://text/plain;base64,SXQgd29ya2VkIQ==', 'r');
-
     // Prepare a mock HTTP client.
     $this->container->set('http_client', $this->getMock(Client::class));
-    $this->container->get('http_client')
-      ->method('get')
-      ->willReturn(new Response(200, [], $body));
 
     // Instantiate the plugin statically so it can pull dependencies out of
     // the container.
diff --git a/core/modules/migrate/tests/src/Unit/MigrateTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
index 20d7662..558cecb 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
@@ -78,11 +78,6 @@ protected function getMigration() {
 
     $configuration = &$this->migrationConfiguration;
 
-    $migration->method('getHighWaterProperty')
-      ->willReturnCallback(function () use ($configuration) {
-        return isset($configuration['high_water_property']) ? $configuration['high_water_property'] : '';
-      });
-
     $migration->method('set')
       ->willReturnCallback(function ($argument, $value) use (&$configuration) {
         $configuration[$argument] = $value;
diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
index c7dfc69..8283bef 100644
--- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
@@ -109,7 +109,7 @@ public function setUp() {
       $user_role->revokePermission($permission);
     }
     $user_role->save();
-    assert('[] === $user_role->getPermissions()', 'The anonymous user role has no permissions at all.');
+    assert([] === $user_role->getPermissions(), 'The anonymous user role has no permissions at all.');
 
     if (static::$auth !== FALSE) {
       // Ensure the authenticated user role has no permissions at all.
@@ -118,7 +118,7 @@ public function setUp() {
         $user_role->revokePermission($permission);
       }
       $user_role->save();
-      assert('[] === $user_role->getPermissions()', 'The authenticated user role has no permissions at all.');
+      assert([] === $user_role->getPermissions(), 'The authenticated user role has no permissions at all.');
 
       // Create an account.
       $this->account = $this->createUser();
diff --git a/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php b/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php
index 51ad3e9..c885990 100644
--- a/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php
+++ b/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php
@@ -202,8 +202,9 @@ public function testOnDependencyRemovalRemoveAuthAndFormats() {
    * @dataProvider providerOnDependencyRemovalForResourceGranularity
    */
   public function testOnDependencyRemovalForResourceGranularity(array $configuration, $module, $expected_configuration) {
-    assert('is_string($module)');
-    assert('$expected_configuration === FALSE || is_array($expected_configuration)');
+    assert(is_string($module));
+    assert($expected_configuration === FALSE || is_array($expected_configuration));
+
     $config_dependencies = new ConfigDependencies(['hal_json' => 'hal', 'json' => 'serialization'], ['basic_auth' => 'basic_auth']);
 
     $rest_config = RestResourceConfig::create($configuration);
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 4b6f421..441b239 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -18,7 +18,7 @@
 use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
 use Drupal\Tests\EntityViewTrait;
 use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
-use Drupal\Tests\Listeners\DeprecationListener;
+use Drupal\Tests\Listeners\DeprecationListenerTrait;
 use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
 use Drupal\Tests\node\Traits\NodeCreationTrait;
 use Drupal\Tests\Traits\Core\CronRunTrait;
@@ -698,7 +698,7 @@ protected function curlHeaderCallback($curlHandler, $header) {
       if ($parameters[1] === 'User deprecated function') {
         if (getenv('SYMFONY_DEPRECATIONS_HELPER') !== 'disabled') {
           $message = (string) $parameters[0];
-          if (!in_array($message, DeprecationListener::getSkippedDeprecations())) {
+          if (!in_array($message, DeprecationListenerTrait::getSkippedDeprecations())) {
             call_user_func_array([&$this, 'error'], $parameters);
           }
         }
diff --git a/core/modules/statistics/src/Tests/Views/IntegrationTest.php b/core/modules/statistics/src/Tests/Views/IntegrationTest.php
index 18f5581..740ecf5 100644
--- a/core/modules/statistics/src/Tests/Views/IntegrationTest.php
+++ b/core/modules/statistics/src/Tests/Views/IntegrationTest.php
@@ -42,8 +42,8 @@ class IntegrationTest extends ViewTestBase {
    */
   public static $testViews = ['test_statistics_integration'];
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     ViewTestData::createTestViews(get_class($this), ['statistics_test_views']);
 
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php
index 2719229..8257d32 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php
@@ -3,6 +3,7 @@
 namespace Drupal\menu_test\Plugin\Menu\ContextualLink;
 
 use Drupal\Core\Menu\ContextualLinkDefault;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a contextual link plugin with a dynamic title from user input.
@@ -12,7 +13,7 @@ class TestContextualLink extends ContextualLinkDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return "<script>alert('Welcome to the jungle!')</script>";
   }
 
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php
index 4b9289e..13f2e5a 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php
@@ -3,6 +3,7 @@
 namespace Drupal\menu_test\Plugin\Menu\LocalAction;
 
 use Drupal\Core\Menu\LocalActionDefault;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a test local action plugin class.
@@ -12,7 +13,7 @@ class TestLocalAction extends LocalActionDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return 'Title override';
   }
 
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
index 1f8300a..eb8b189 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Menu\LocalActionDefault;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a local action plugin with a dynamic title.
@@ -15,7 +16,7 @@ class TestLocalAction4 extends LocalActionDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return $this->t('My @arg action', ['@arg' => 'dynamic-title']);
   }
 
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php
index 0bd7fc3..e960e26 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php
@@ -3,6 +3,7 @@
 namespace Drupal\menu_test\Plugin\Menu\LocalAction;
 
 use Drupal\Core\Menu\LocalActionDefault;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a local action plugin with a dynamic title from user input.
@@ -12,7 +13,7 @@ class TestLocalAction5 extends LocalActionDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return "<script>alert('Welcome to the jungle!')</script>";
   }
 
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
index 54a2f42..4f56977 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
@@ -6,6 +6,7 @@
 use Drupal\Core\Menu\LocalActionDefault;
 use Drupal\Core\Routing\RouteProviderInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Defines a test local action plugin class.
@@ -20,7 +21,7 @@ class TestLocalActionWithConfig extends LocalActionDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return $this->config->get('title');
   }
 
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
index 7ba7548..61ac970 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Menu\LocalTaskDefault;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
 
 class TestTasksSettingsSub1 extends LocalTaskDefault {
 
@@ -12,7 +13,7 @@ class TestTasksSettingsSub1 extends LocalTaskDefault {
   /**
    * {@inheritdoc}
    */
-  public function getTitle() {
+  public function getTitle(Request $request = NULL) {
     return $this->t('Dynamic title for @class', ['@class' => 'TestTasksSettingsSub1']);
   }
 
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index 2fe4a83..a24313f 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -134,8 +134,6 @@ protected function setUp() {
       ->disableOriginalConstructor()
       ->getMock();
     $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
-    $cache_contexts_manager->expects($this->any())
-      ->method('validate_tokens');
     $container = new Container();
     $container->set('cache_contexts_manager', $cache_contexts_manager);
     \Drupal::setContainer($container);
diff --git a/core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php b/core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php
new file mode 100644
index 0000000..e4490f3
--- /dev/null
+++ b/core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace Drupal\Tests\taxonomy\Functional;
+
+use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\taxonomy\Entity\Vocabulary;
+
+/**
+ * Posts an article with a taxonomy term and a date prior to 1970.
+ *
+ * @group taxonomy
+ */
+class EarlyDateTest extends TaxonomyTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['node', 'datetime'];
+
+  protected function setUp() {
+    parent::setUp();
+
+    // Create a tags vocabulary for the 'article' content type.
+    $vocabulary = Vocabulary::create([
+      'name' => 'Tags',
+      'vid' => 'tags',
+    ]);
+    $vocabulary->save();
+    $field_name = 'field_' . $vocabulary->id();
+
+    $handler_settings = [
+      'target_bundles' => [
+        $vocabulary->id() => $vocabulary->id(),
+      ],
+      'auto_create' => TRUE,
+    ];
+    $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
+
+    entity_get_form_display('node', 'article', 'default')
+      ->setComponent($field_name, [
+        'type' => 'entity_reference_autocomplete_tags',
+      ])
+      ->save();
+
+    $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access']));
+  }
+
+  /**
+   * Test taxonomy functionality with nodes prior to 1970.
+   */
+  public function testTaxonomyEarlyDateNode() {
+    // Posts an article with a taxonomy term and a date prior to 1970.
+    $date = new DrupalDateTime('1969-01-01 00:00:00');
+    $edit = [];
+    $edit['title[0][value]'] = $this->randomMachineName();
+    $edit['created[0][value][date]'] = $date->format('Y-m-d');
+    $edit['created[0][value][time]'] = $date->format('H:i:s');
+    $edit['body[0][value]'] = $this->randomMachineName();
+    $edit['field_tags[target_id]'] = $this->randomMachineName();
+    $this->drupalPostForm('node/add/article', $edit, t('Save'));
+    // Checks that the node has been saved.
+    $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
+    $this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.');
+  }
+
+}
diff --git a/core/modules/taxonomy/tests/src/Functional/LegacyTest.php b/core/modules/taxonomy/tests/src/Functional/LegacyTest.php
deleted file mode 100644
index 667ed55..0000000
--- a/core/modules/taxonomy/tests/src/Functional/LegacyTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-namespace Drupal\Tests\taxonomy\Functional;
-
-use Drupal\Core\Datetime\DrupalDateTime;
-use Drupal\Core\Field\FieldStorageDefinitionInterface;
-use Drupal\taxonomy\Entity\Vocabulary;
-
-/**
- * Posts an article with a taxonomy term and a date prior to 1970.
- *
- * @group taxonomy
- */
-class LegacyTest extends TaxonomyTestBase {
-
-  /**
-   * Modules to enable.
-   *
-   * @var array
-   */
-  public static $modules = ['node', 'datetime'];
-
-  protected function setUp() {
-    parent::setUp();
-
-    // Create a tags vocabulary for the 'article' content type.
-    $vocabulary = Vocabulary::create([
-      'name' => 'Tags',
-      'vid' => 'tags',
-    ]);
-    $vocabulary->save();
-    $field_name = 'field_' . $vocabulary->id();
-
-    $handler_settings = [
-      'target_bundles' => [
-        $vocabulary->id() => $vocabulary->id(),
-      ],
-      'auto_create' => TRUE,
-    ];
-    $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
-
-    entity_get_form_display('node', 'article', 'default')
-      ->setComponent($field_name, [
-        'type' => 'entity_reference_autocomplete_tags',
-      ])
-      ->save();
-
-    $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access']));
-  }
-
-  /**
-   * Test taxonomy functionality with nodes prior to 1970.
-   */
-  public function testTaxonomyLegacyNode() {
-    // Posts an article with a taxonomy term and a date prior to 1970.
-    $date = new DrupalDateTime('1969-01-01 00:00:00');
-    $edit = [];
-    $edit['title[0][value]'] = $this->randomMachineName();
-    $edit['created[0][value][date]'] = $date->format('Y-m-d');
-    $edit['created[0][value][time]'] = $date->format('H:i:s');
-    $edit['body[0][value]'] = $this->randomMachineName();
-    $edit['field_tags[target_id]'] = $this->randomMachineName();
-    $this->drupalPostForm('node/add/article', $edit, t('Save'));
-    // Checks that the node has been saved.
-    $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
-    $this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.');
-  }
-
-}
diff --git a/core/modules/tour/src/Tests/TourTestBase.php b/core/modules/tour/src/Tests/TourTestBase.php
index e139650..f551c81 100644
--- a/core/modules/tour/src/Tests/TourTestBase.php
+++ b/core/modules/tour/src/Tests/TourTestBase.php
@@ -15,6 +15,17 @@
 abstract class TourTestBase extends WebTestBase {
 
   /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    // Support both PHPUnit 4 and 6.
+    if (!class_exists('\PHPUnit_Util_XML') && class_exists('\PHPUnit\Util\XML')) {
+      class_alias('\PHPUnit\Util\XML', '\PHPUnit_Util_XML');
+    }
+    parent::setUp();
+  }
+
+  /**
    * Assert function to determine if tips rendered to the page
    * have a corresponding page element.
    *
diff --git a/core/modules/tour/tests/src/Functional/TourTestBase.php b/core/modules/tour/tests/src/Functional/TourTestBase.php
index 522e8e6..2d06d58 100644
--- a/core/modules/tour/tests/src/Functional/TourTestBase.php
+++ b/core/modules/tour/tests/src/Functional/TourTestBase.php
@@ -50,14 +50,13 @@ public function assertTourTips($tips = []) {
       // Check for corresponding page elements.
       $total = 0;
       $modals = 0;
-      $raw_content = $this->getSession()->getPage()->getContent();
       foreach ($tips as $tip) {
         if (!empty($tip['data-id'])) {
-          $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $raw_content, TRUE);
+          $elements = $this->getSession()->getPage()->find('css', '#' . $tip['data-id']);
           $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', ['%data-id' => $tip['data-id']]));
         }
         elseif (!empty($tip['data-class'])) {
-          $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $raw_content, TRUE);
+          $elements = $this->getSession()->getPage()->find('css', '.' . $tip['data-class']);
           $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', ['%data-class' => $tip['data-class']]));
         }
         else {
diff --git a/core/modules/tracker/src/Tests/Views/TrackerTestBase.php b/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
index 9746a22..4dfaab0 100644
--- a/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
+++ b/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
@@ -41,8 +41,8 @@
    */
   protected $comment;
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
 
diff --git a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
index c3e447d..61c767d 100644
--- a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
+++ b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
@@ -28,7 +28,7 @@ class UpdateFetcherTest extends UnitTestCase {
    */
   protected function setUp() {
     $config_factory = $this->getConfigFactoryStub(['update.settings' => ['fetch_url' => 'http://www.example.com']]);
-    $http_client_mock = $this->getMock('\GuzzleHttp\ClientInterface');
+    $http_client_mock = $this->createMock('\GuzzleHttp\ClientInterface');
     $this->updateFetcher = new UpdateFetcher($config_factory, $http_client_mock);
   }
 
diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php
index 5f9c978..7c17d2b 100644
--- a/core/modules/views/src/Plugin/views/PluginBase.php
+++ b/core/modules/views/src/Plugin/views/PluginBase.php
@@ -368,17 +368,17 @@ protected function viewsTokenReplace($text, $tokens) {
         // We need to validate tokens are valid Twig variables. Twig uses the
         // same variable naming rules as PHP.
         // @see http://php.net/manual/language.variables.basics.php
-        assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $token) === 1', 'Tokens need to be valid Twig variables.');
+        assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $token) === 1, 'Tokens need to be valid Twig variables.');
         $twig_tokens[$token] = $replacement;
       }
       else {
         $parts = explode('.', $token);
         $top = array_shift($parts);
-        assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
+        assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $top) === 1, 'Tokens need to be valid Twig variables.');
         $token_array = [array_pop($parts) => $replacement];
         foreach (array_reverse($parts) as $key) {
           // The key could also be numeric (array index) so allow that.
-          assert('is_numeric($key) || (preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1)', 'Tokens need to be valid Twig variables.');
+          assert(is_numeric($key) || preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $key) === 1, 'Tokens need to be valid Twig variables.');
           $token_array = [$key => $token_array];
         }
         if (!isset($twig_tokens[$top])) {
diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php
index f6d5159..d2d035c 100644
--- a/core/modules/views/src/Tests/FieldApiDataTest.php
+++ b/core/modules/views/src/Tests/FieldApiDataTest.php
@@ -35,8 +35,8 @@ class FieldApiDataTest extends FieldTestBase {
    */
   protected $translationNodes;
 
-  protected function setUp() {
-    parent::setUp(FALSE);
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     $field_names = $this->setUpFieldStorages(4);
 
diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
index e8d2549..04ba4ca 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
@@ -26,8 +26,8 @@ class DisplayFeedTest extends PluginTestBase {
    */
   public static $modules = ['block', 'node', 'views'];
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     $this->enableViewsTestModule();
 
diff --git a/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php b/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
index 4e84433..66a8bc8 100644
--- a/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
@@ -27,8 +27,8 @@ class StyleOpmlTest extends PluginTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     $this->enableViewsTestModule();
 
diff --git a/core/modules/views/src/Tests/ViewAjaxTest.php b/core/modules/views/src/Tests/ViewAjaxTest.php
index 5a966a8..820d9e2 100644
--- a/core/modules/views/src/Tests/ViewAjaxTest.php
+++ b/core/modules/views/src/Tests/ViewAjaxTest.php
@@ -19,8 +19,8 @@ class ViewAjaxTest extends ViewTestBase {
    */
   public static $testViews = ['test_ajax_view', 'test_view'];
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     $this->enableViewsTestModule();
   }
diff --git a/core/modules/views/src/Tests/Wizard/WizardTestBase.php b/core/modules/views/src/Tests/Wizard/WizardTestBase.php
index ba7509c..29b96d3 100644
--- a/core/modules/views/src/Tests/Wizard/WizardTestBase.php
+++ b/core/modules/views/src/Tests/Wizard/WizardTestBase.php
@@ -21,8 +21,8 @@
    */
   public static $modules = ['node', 'views_ui', 'block', 'rest'];
 
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     // Create and log in a user with administer views permission.
     $views_admin = $this->drupalCreateUser(['administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions']);
diff --git a/core/modules/views/tests/src/Functional/Update/BulkFormUpdateTest.php b/core/modules/views/tests/src/Functional/Update/BulkFormUpdateTest.php
new file mode 100644
index 0000000..5db54d2
--- /dev/null
+++ b/core/modules/views/tests/src/Functional/Update/BulkFormUpdateTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\Tests\views\Functional\Update;
+
+use Drupal\FunctionalTests\Update\UpdatePathTestBase;
+use Drupal\views\Entity\View;
+
+/**
+ * Tests Views image style dependencies update.
+ *
+ * @group views
+ */
+class BulkFormUpdateTest extends UpdatePathTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setDatabaseDumpFiles() {
+    $this->databaseDumpFiles = [
+      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
+      __DIR__ . '/../../../fixtures/update/legacy-bulk-form-update.php'
+    ];
+  }
+
+  /**
+   * Tests the updating of dependencies for Views using the bulk_form plugin.
+   */
+  public function testBulkFormDependencies() {
+    $module_dependencies = View::load('legacy_bulk_form')->getDependencies()['module'];
+
+    $this->assertTrue(in_array('system', $module_dependencies));
+
+    $this->runUpdates();
+
+    $module_dependencies = View::load('legacy_bulk_form')->getDependencies()['module'];
+
+    $this->assertFalse(in_array('system', $module_dependencies));
+  }
+
+}
diff --git a/core/modules/views/tests/src/Functional/Update/LegacyBulkFormUpdateTest.php b/core/modules/views/tests/src/Functional/Update/LegacyBulkFormUpdateTest.php
deleted file mode 100644
index 75e2b54..0000000
--- a/core/modules/views/tests/src/Functional/Update/LegacyBulkFormUpdateTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-namespace Drupal\Tests\views\Functional\Update;
-
-use Drupal\FunctionalTests\Update\UpdatePathTestBase;
-use Drupal\views\Entity\View;
-
-/**
- * Tests Views image style dependencies update.
- *
- * @group views
- */
-class LegacyBulkFormUpdateTest extends UpdatePathTestBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function setDatabaseDumpFiles() {
-    $this->databaseDumpFiles = [
-      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
-      __DIR__ . '/../../../fixtures/update/legacy-bulk-form-update.php'
-    ];
-  }
-
-  /**
-   * Tests the updating of dependencies for Views using the bulk_form plugin.
-   */
-  public function testBulkFormDependencies() {
-    $module_dependencies = View::load('legacy_bulk_form')->getDependencies()['module'];
-
-    $this->assertTrue(in_array('system', $module_dependencies));
-
-    $this->runUpdates();
-
-    $module_dependencies = View::load('legacy_bulk_form')->getDependencies()['module'];
-
-    $this->assertFalse(in_array('system', $module_dependencies));
-  }
-
-}
diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
index 9323b04..f9bd6d2 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
@@ -70,7 +70,7 @@ protected function setUp() {
 
     $this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
-      ->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage'])
+      ->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage', 'getShowAdminLinks'])
       ->getMock();
     $this->executable->expects($this->any())
       ->method('setDisplay')
diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php
index 83f2f85..752be6e 100644
--- a/core/modules/views_ui/src/Tests/UITestBase.php
+++ b/core/modules/views_ui/src/Tests/UITestBase.php
@@ -36,8 +36,8 @@
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
-    parent::setUp();
+  protected function setUp($import_test_views = TRUE) {
+    parent::setUp($import_test_views);
 
     $this->enableViewsTestModule();
 
diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist
index bfe7467..ed3216d 100644
--- a/core/phpunit.xml.dist
+++ b/core/phpunit.xml.dist
@@ -30,7 +30,7 @@
     <!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
     <env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
     <!-- To disable deprecation testing uncomment the next line. -->
-    <!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
+    <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors"/>
     <!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
     <!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
   </php>
@@ -49,16 +49,11 @@
     </testsuite>
   </testsuites>
   <listeners>
-    <listener class="\Drupal\Tests\Listeners\DeprecationListener">
+    <listener class="\Drupal\Tests\Listeners\DrupalListener">
     </listener>
-    <!-- The Symfony deprecation listener has to come after the Drupal
-    deprecation listener -->
+    <!-- The Symfony deprecation listener has to come after the Drupal listener -->
     <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
     </listener>
-    <listener class="\Drupal\Tests\Listeners\DrupalStandardsListener">
-    </listener>
-    <listener class="\Drupal\Tests\Listeners\DrupalComponentTestListener">
-    </listener>
   </listeners>
   <!-- Filter for coverage reports. -->
   <filter>
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5ebf9f0..e545318 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -793,7 +793,11 @@ function simpletest_script_run_one_test($test_id, $test_class) {
       putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
     }
     else {
-      putenv('SYMFONY_DEPRECATIONS_HELPER=strict');
+      // Prevent deprecations caused by vendor code calling deprecated code.
+      // This also prevents PHPUnit 6's mock code that triggers silenced
+      // deprecations from breaking the test suite. We should consider changing
+      // this to 'strict' once we are no longer use PHPUnit 4.
+      putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
     }
     if (is_subclass_of($test_class, TestCase::class)) {
       $status = simpletest_script_run_phpunit($test_id, $test_class);
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index 95ee39f..38e610c 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -188,7 +188,7 @@ public function testInvalidLinkNotExistsExact() {
   /**
    * Tests legacy text asserts.
    */
-  public function testLegacyTextAsserts() {
+  public function testTextAsserts() {
     $this->drupalGet('test-encoded');
     $dangerous = 'Bad html <script>alert(123);</script>';
     $sanitized = Html::escape($dangerous);
@@ -202,7 +202,7 @@ public function testLegacyTextAsserts() {
   /**
    * Tests legacy field asserts which use xpath directly.
    */
-  public function testLegacyXpathAsserts() {
+  public function testXpathAsserts() {
     $this->drupalGet('test-field-xpath');
     $this->assertFieldsByValue($this->xpath("//h1[@class = 'page-title']"), NULL);
     $this->assertFieldsByValue($this->xpath('//table/tbody/tr[2]/td[1]'), 'one');
@@ -245,7 +245,7 @@ public function testLegacyXpathAsserts() {
   /**
    * Tests legacy field asserts using textfields.
    */
-  public function testLegacyFieldAssertsForTextfields() {
+  public function testFieldAssertsForTextfields() {
     $this->drupalGet('test-field-xpath');
 
     // *** 1. assertNoField().
@@ -387,7 +387,7 @@ public function testLegacyFieldAssertsForTextfields() {
   /**
    * Tests legacy field asserts for options field type.
    */
-  public function testLegacyFieldAssertsForOptions() {
+  public function testFieldAssertsForOptions() {
     $this->drupalGet('test-field-xpath');
 
     // Option field type.
@@ -443,7 +443,7 @@ public function testLegacyFieldAssertsForOptions() {
   /**
    * Tests legacy field asserts for button field type.
    */
-  public function testLegacyFieldAssertsForButton() {
+  public function testFieldAssertsForButton() {
     $this->drupalGet('test-field-xpath');
 
     $this->assertFieldById('edit-save', NULL);
@@ -485,7 +485,7 @@ public function testLegacyFieldAssertsForButton() {
   /**
    * Tests legacy field asserts for checkbox field type.
    */
-  public function testLegacyFieldAssertsForCheckbox() {
+  public function testFieldAssertsForCheckbox() {
     $this->drupalGet('test-field-xpath');
 
     // Part 1 - Test by name.
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 32c97b6..91da81e 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -20,6 +20,7 @@
 use Drupal\simpletest\AssertContentTrait;
 use Drupal\Tests\AssertHelperTrait;
 use Drupal\Tests\ConfigTestTrait;
+use Drupal\Tests\Phpunit5FCTrait;
 use Drupal\Tests\RandomGeneratorTrait;
 use Drupal\Tests\TestRequirementsTrait;
 use Drupal\simpletest\TestServiceProvider;
@@ -76,6 +77,7 @@
   use RandomGeneratorTrait;
   use ConfigTestTrait;
   use TestRequirementsTrait;
+  use Phpunit5FCTrait;
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index b12ba60..d9a8ba0 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -66,6 +66,7 @@
     createUser as drupalCreateUser;
   }
   use XdebugRequestTrait;
+  use Phpunit5FCTrait;
 
   /**
    * The database prefix of this test run.
@@ -496,6 +497,11 @@ protected function setUp() {
     if ($disable_gc) {
       gc_enable();
     }
+
+    // Ensure that the test is not marked as risky because of no assertions. In
+    // PHPIUnit 6 tests that only make assertions using $this->assertSession()
+    // can be marked as risky.
+    $this->addToAssertionCount(1);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
index 297125b..b89d351 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
@@ -87,7 +87,13 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte
    * @dataProvider providerTestInvalidDateDiff
    */
   public function testInvalidDateDiff($input1, $input2, $absolute) {
-    $this->setExpectedException(\BadMethodCallException::class, 'Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\BadMethodCallException::class);
+      $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
+    }
+    else {
+      $this->setExpectedException(\BadMethodCallException::class, 'Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
+    }
     $interval = $input1->diff($input2, $absolute);
   }
 
@@ -104,7 +110,12 @@ public function testInvalidDateDiff($input1, $input2, $absolute) {
    * @dataProvider providerTestInvalidDateArrays
    */
   public function testInvalidDateArrays($input, $timezone, $class) {
-    $this->setExpectedException($class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException($class);
+    }
+    else {
+      $this->setExpectedException($class);
+    }
     $this->assertInstanceOf(
       '\Drupal\Component\DateTimePlus',
       DateTimePlus::createFromArray($input, $timezone)
@@ -242,7 +253,12 @@ public function testDateFormat($input, $timezone, $format, $format_date, $expect
    * @dataProvider providerTestInvalidDates
    */
   public function testInvalidDates($input, $timezone, $format, $message, $class) {
-    $this->setExpectedException($class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException($class);
+    }
+    else {
+      $this->setExpectedException($class);
+    }
     DateTimePlus::createFromFormat($format, $input, $timezone);
   }
 
@@ -800,7 +816,12 @@ public function testValidateFormat() {
 
     // Parse the same date with ['validate_format' => TRUE] and make sure we
     // get the expected exception.
-    $this->setExpectedException(\UnexpectedValueException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\UnexpectedValueException::class);
+    }
+    else {
+      $this->setExpectedException(\UnexpectedValueException::class);
+    }
     $date = DateTimePlus::createFromFormat('Y-m-d H:i:s', '11-03-31 17:44:00', 'UTC', ['validate_format' => TRUE]);
   }
 
@@ -859,7 +880,13 @@ public function testChainableNonChainable() {
    * @covers ::__call
    */
   public function testChainableNonCallable() {
-    $this->setExpectedException(\BadMethodCallException::class, 'Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\BadMethodCallException::class);
+      $this->expectExceptionMessage('Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
+    }
+    else {
+      $this->setExpectedException(\BadMethodCallException::class, 'Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
+    }
     $date = new DateTimePlus('now', 'Australia/Sydney');
     $date->setTimezone(new \DateTimeZone('America/New_York'))->nonexistent();
   }
diff --git a/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php b/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php
index 4a5fa80..29c27b2 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php
@@ -37,7 +37,12 @@ class TimeTest extends TestCase {
   protected function setUp() {
     parent::setUp();
 
-    $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+    if (method_exists($this, 'createMock')) {
+      $this->requestStack = $this->createMock('Symfony\Component\HttpFoundation\RequestStack');
+    }
+    else {
+      $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+    }
 
     $this->time = new Time($this->requestStack);
   }
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
index 0e6a147..1e2fbfe 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
@@ -983,6 +983,28 @@ protected function getCollection($collection, $resolve = TRUE) {
     ];
   }
 
+  /**
+   * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
+   *
+   * @param mixed $class
+   * @param string $message
+   * @param int $exception_code
+   */
+  public function setExpectedException($class, $message = '', $exception_code = NULL) {
+    if (method_exists($this, 'expectException')) {
+      $this->expectException($class);
+      if (!empty($message)) {
+        $this->expectExceptionMessage($message);
+      }
+      if ($exception_code !== NULL) {
+        $this->expectExceptionCode($exception_code);
+      }
+    }
+    else {
+      parent::setExpectedException($class, $message, $exception_code);
+    }
+  }
+
 }
 
 /**
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
index 3c44752..c1b7095 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
@@ -545,7 +545,12 @@ public function testGetServiceDefinitionForDecoratedService() {
       $services['bar'] = $bar_definition;
 
       $this->containerBuilder->getDefinitions()->willReturn($services);
-      $this->setExpectedException(InvalidArgumentException::class);
+      if (method_exists($this, 'expectException')) {
+        $this->expectException(InvalidArgumentException::class);
+      }
+      else {
+        $this->setExpectedException(InvalidArgumentException::class);
+      }
       $this->dumper->getArray();
     }
 
@@ -562,7 +567,12 @@ public function testGetServiceDefinitionForExpression() {
       $services['bar'] = $bar_definition;
 
       $this->containerBuilder->getDefinitions()->willReturn($services);
-      $this->setExpectedException(RuntimeException::class);
+      if (method_exists($this, 'expectException')) {
+        $this->expectException(RuntimeException::class);
+      }
+      else {
+        $this->setExpectedException(RuntimeException::class);
+      }
       $this->dumper->getArray();
     }
 
@@ -579,7 +589,12 @@ public function testGetServiceDefinitionForObject() {
       $services['bar'] = $bar_definition;
 
       $this->containerBuilder->getDefinitions()->willReturn($services);
-      $this->setExpectedException(RuntimeException::class);
+      if (method_exists($this, 'expectException')) {
+        $this->expectException(RuntimeException::class);
+      }
+      else {
+        $this->setExpectedException(RuntimeException::class);
+      }
       $this->dumper->getArray();
     }
 
@@ -596,7 +611,12 @@ public function testGetServiceDefinitionForResource() {
       $services['bar'] = $bar_definition;
 
       $this->containerBuilder->getDefinitions()->willReturn($services);
-      $this->setExpectedException(RuntimeException::class);
+      if (method_exists($this, 'expectException')) {
+        $this->expectException(RuntimeException::class);
+      }
+      else {
+        $this->setExpectedException(RuntimeException::class);
+      }
       $this->dumper->getArray();
     }
 
diff --git a/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php b/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
index 1a649ae..dbbb6ec 100644
--- a/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
+++ b/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
@@ -4,6 +4,7 @@
 
 use Drupal\Component\Diff\Engine\DiffOp;
 use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Error\Error;
 
 /**
  * Test DiffOp base class.
@@ -24,7 +25,12 @@ class DiffOpTest extends TestCase {
    * @covers ::reverse
    */
   public function testReverse() {
-    $this->setExpectedException(\PHPUnit_Framework_Error::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(Error::class);
+    }
+    else {
+      $this->setExpectedException(\PHPUnit_Framework_Error::class);
+    }
     $op = new DiffOp();
     $result = $op->reverse();
   }
diff --git a/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php
index 86134a7..9ac807d 100644
--- a/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php
@@ -124,7 +124,13 @@ public function testDiscoveryAlternateId() {
    * @covers ::getIdentifier
    */
   public function testDiscoveryNoIdException() {
-    $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(DiscoveryException::class);
+      $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
+    }
+    else {
+      $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
+    }
     vfsStream::setup('modules', NULL, [
       'test_1' => [
         'item_1.test.yml' => "",
@@ -144,7 +150,13 @@ public function testDiscoveryNoIdException() {
    * @covers ::findAll
    */
   public function testDiscoveryInvalidYamlException() {
-    $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(DiscoveryException::class);
+      $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
+    }
+    else {
+      $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
+    }
     vfsStream::setup('modules', NULL, [
       'test_1' => [
         'item_1.test.yml' => "id: invalid\nfoo : [bar}",
diff --git a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
index ea0685a..a750eca 100644
--- a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
+++ b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
@@ -38,7 +38,7 @@ public function testGetListenersWithCallables()
         // When passing in callables exclusively as listeners into the event
         // dispatcher constructor, the event dispatcher must not attempt to
         // resolve any services.
-        $container = $this->getMock(ContainerInterface::class);
+        $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
         $container->expects($this->never())->method($this->anything());
 
         $firstListener = new CallableClass();
@@ -73,7 +73,7 @@ public function testDispatchWithCallables()
         // When passing in callables exclusively as listeners into the event
         // dispatcher constructor, the event dispatcher must not attempt to
         // resolve any services.
-        $container = $this->getMock(ContainerInterface::class);
+        $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
         $container->expects($this->never())->method($this->anything());
 
         $firstListener = new CallableClass();
diff --git a/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php b/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php
index 995f5fc..f919598 100644
--- a/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php
@@ -59,7 +59,13 @@ public function testGet() {
    */
   public function testGetNoPrefix() {
     FileCacheFactory::setPrefix(NULL);
-    $this->setExpectedException(\InvalidArgumentException::class, 'Required prefix configuration is missing');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\InvalidArgumentException::class);
+      $this->expectExceptionMessage('Required prefix configuration is missing');
+    }
+    else {
+      $this->setExpectedException(\InvalidArgumentException::class, 'Required prefix configuration is missing');
+    }
     FileCacheFactory::get('test_foo_settings', []);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
index 52e1b83..168d160 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
@@ -5,7 +5,7 @@
 use Drupal\Component\PhpStorage\FileStorage;
 use Drupal\Component\Utility\Random;
 use org\bovigo\vfs\vfsStreamDirectory;
-use PHPUnit_Framework_Error_Warning;
+use PHPUnit\Framework\Error\Warning;
 
 /**
  * @coversDefaultClass \Drupal\Component\PhpStorage\FileStorage
@@ -99,7 +99,13 @@ public function testCreateDirectoryFailWarning() {
       'bin' => 'test',
     ]);
     $code = "<?php\n echo 'here';";
-    $this->setExpectedException(PHPUnit_Framework_Error_Warning::class, 'mkdir(): Permission Denied');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(Warning::class);
+      $this->expectExceptionMessage('mkdir(): Permission Denied');
+    }
+    else {
+      $this->setExpectedException(\PHPUnit_Framework_Error_Warning::class, 'mkdir(): Permission Denied');
+    }
     $storage->save('subdirectory/foo.php', $code);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
index 6a2cf46..aee8d09 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
@@ -71,10 +71,16 @@ public function testGetContextValue($expected, $context_value, $is_required, $da
 
       // Set expectation for exception.
       if ($is_required) {
-        $this->setExpectedException(
-          'Drupal\Component\Plugin\Exception\ContextException',
-          sprintf("The %s context is required and not present.", $data_type)
-        );
+        if (method_exists($this, 'expectException')) {
+          $this->expectException('Drupal\Component\Plugin\Exception\ContextException');
+          $this->expectExceptionMessage(sprintf("The %s context is required and not present.", $data_type));
+        }
+        else {
+          $this->setExpectedException(
+            'Drupal\Component\Plugin\Exception\ContextException',
+            sprintf("The %s context is required and not present.", $data_type)
+          );
+        }
       }
 
       // Exercise getContextValue().
diff --git a/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php
index b6bb32c..00e4072 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php
@@ -35,7 +35,7 @@ public function testGetPluginClassWithValidArrayPluginDefinition() {
    */
   public function testGetPluginClassWithValidObjectPluginDefinition() {
     $plugin_class = Cherry::class;
-    $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+    $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
     $plugin_definition->expects($this->atLeastOnce())
       ->method('getClass')
       ->willReturn($plugin_class);
@@ -60,7 +60,7 @@ public function testGetPluginClassWithMissingClassWithArrayPluginDefinition() {
    * @covers ::getPluginClass
    */
   public function testGetPluginClassWithMissingClassWithObjectPluginDefinition() {
-    $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+    $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
     $this->setExpectedException(PluginException::class, 'The plugin (cherry) did not specify an instance class.');
     DefaultFactory::getPluginClass('cherry', $plugin_definition);
   }
@@ -82,7 +82,7 @@ public function testGetPluginClassWithNotExistingClassWithArrayPluginDefinition(
    */
   public function testGetPluginClassWithNotExistingClassWithObjectPluginDefinition() {
     $plugin_class = '\Drupal\plugin_test\Plugin\plugin_test\fruit\Kiwifruit';
-    $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+    $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
     $plugin_definition->expects($this->atLeastOnce())
       ->method('getClass')
       ->willReturn($plugin_class);
@@ -109,7 +109,7 @@ public function testGetPluginClassWithInterfaceWithArrayPluginDefinition() {
    */
   public function testGetPluginClassWithInterfaceWithObjectPluginDefinition() {
     $plugin_class = Cherry::class;
-    $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+    $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
     $plugin_definition->expects($this->atLeastOnce())
       ->method('getClass')
       ->willReturn($plugin_class);
@@ -136,7 +136,7 @@ public function testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDef
    */
   public function testGetPluginClassWithInterfaceAndInvalidClassWithObjectPluginDefinition() {
     $plugin_class = Kale::class;
-    $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+    $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
     $plugin_definition->expects($this->atLeastOnce())
       ->method('getClass')
       ->willReturn($plugin_class);
@@ -144,4 +144,26 @@ public function testGetPluginClassWithInterfaceAndInvalidClassWithObjectPluginDe
     DefaultFactory::getPluginClass('cherry', $plugin_definition, FruitInterface::class);
   }
 
+  /**
+   * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
+   *
+   * @param mixed $class
+   * @param string $message
+   * @param int $exception_code
+   */
+  public function setExpectedException($class, $message = '', $exception_code = NULL) {
+    if (method_exists($this, 'expectException')) {
+      $this->expectException($class);
+      if (!empty($message)) {
+        $this->expectExceptionMessage($message);
+      }
+      if ($exception_code !== NULL) {
+        $this->expectExceptionCode($exception_code);
+      }
+    }
+    else {
+      parent::setExpectedException($class, $message, $exception_code);
+    }
+  }
+
 }
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
index c37a4b5..1a5c36e 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
@@ -69,7 +69,12 @@ public function testDoGetDefinitionException($expected, $definitions, $plugin_id
     $method_ref = new \ReflectionMethod($trait, 'doGetDefinition');
     $method_ref->setAccessible(TRUE);
     // Call doGetDefinition, with $exception_on_invalid always TRUE.
-    $this->setExpectedException(PluginNotFoundException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(PluginNotFoundException::class);
+    }
+    else {
+      $this->setExpectedException(PluginNotFoundException::class);
+    }
     $method_ref->invoke($trait, $definitions, $plugin_id, TRUE);
   }
 
@@ -106,7 +111,12 @@ public function testGetDefinitionException($expected, $definitions, $plugin_id)
       ->method('getDefinitions')
       ->willReturn($definitions);
     // Call getDefinition(), with $exception_on_invalid always TRUE.
-    $this->setExpectedException(PluginNotFoundException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(PluginNotFoundException::class);
+    }
+    else {
+      $this->setExpectedException(PluginNotFoundException::class);
+    }
     $trait->getDefinition($plugin_id, TRUE);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
index a44721b..5b01093 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
@@ -100,7 +100,12 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti
     $ref_decorated->setValue($mock_decorator, $mock_decorated);
 
     if ($exception_on_invalid) {
-      $this->setExpectedException('Drupal\Component\Plugin\Exception\PluginNotFoundException');
+      if (method_exists($this, 'expectException')) {
+        $this->expectException('Drupal\Component\Plugin\Exception\PluginNotFoundException');
+      }
+      else {
+        $this->setExpectedException('Drupal\Component\Plugin\Exception\PluginNotFoundException');
+      }
     }
 
     // Exercise getDefinition(). It calls parent::getDefinition().
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
index 7e8fbef..20d2f76 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
@@ -123,7 +123,12 @@ public function testGetInstanceArguments($expected, $reflector_name, $plugin_id,
     // us to use one data set for this test method as well as
     // testCreateInstance().
     if ($plugin_id == 'arguments_no_constructor') {
-      $this->setExpectedException('\ReflectionException');
+      if (method_exists($this, 'expectException')) {
+        $this->expectException('\ReflectionException');
+      }
+      else {
+        $this->setExpectedException('\ReflectionException');
+      }
     }
 
     // Finally invoke getInstanceArguments() on our mocked factory.
diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php
index c2e0a0d..5a71f48 100644
--- a/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php
+++ b/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php
@@ -87,7 +87,12 @@ public function testGetFileExtension() {
    * @covers ::errorHandler
    */
   public function testError() {
-    $this->setExpectedException(InvalidDataTypeException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(InvalidDataTypeException::class);
+    }
+    else {
+      $this->setExpectedException(InvalidDataTypeException::class);
+    }
     YamlPecl::decode('foo: [ads');
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
index 86c818c..d857d09 100644
--- a/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
+++ b/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
@@ -59,7 +59,12 @@ public function testGetFileExtension() {
    * @covers ::decode
    */
   public function testError() {
-    $this->setExpectedException(InvalidDataTypeException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(InvalidDataTypeException::class);
+    }
+    else {
+      $this->setExpectedException(InvalidDataTypeException::class);
+    }
     YamlSymfony::decode('foo: [ads');
   }
 
@@ -69,7 +74,13 @@ public function testError() {
    * @covers ::encode
    */
   public function testObjectSupportDisabled() {
-    $this->setExpectedException(InvalidDataTypeException::class, 'Object support when dumping a YAML file has been disabled.');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(InvalidDataTypeException::class);
+      $this->expectExceptionMessage('Object support when dumping a YAML file has been disabled.');
+    }
+    else {
+      $this->setExpectedException(InvalidDataTypeException::class, 'Object support when dumping a YAML file has been disabled.');
+    }
     $object = new \stdClass();
     $object->foo = 'bar';
     YamlSymfony::encode([$object]);
diff --git a/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php b/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php
index f15f14b..695edf4 100644
--- a/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php
@@ -96,9 +96,16 @@ public function testGetWildcardArgument() {
    * Tests getArgument() with a Route, Request, and Account object.
    */
   public function testGetArgumentOrder() {
-    $a1 = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
-    $a2 = $this->getMock('\Drupal\Tests\Component\Utility\TestClass');
-    $a3 = $this->getMock('\Drupal\Tests\Component\Utility\Test2Interface');
+    if (method_exists($this, 'createMock')) {
+      $a1 = $this->createMock('\Drupal\Tests\Component\Utility\Test1Interface');
+      $a2 = $this->createMock('\Drupal\Tests\Component\Utility\TestClass');
+      $a3 = $this->createMock('\Drupal\Tests\Component\Utility\Test2Interface');
+    }
+    else {
+      $a1 = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+      $a2 = $this->getMock('\Drupal\Tests\Component\Utility\TestClass');
+      $a3 = $this->getMock('\Drupal\Tests\Component\Utility\Test2Interface');
+    }
 
     $objects = [
       't1' => $a1,
@@ -123,12 +130,23 @@ public function testGetArgumentOrder() {
    * Without the typehint, the wildcard object will not be passed to the callable.
    */
   public function testGetWildcardArgumentNoTypehint() {
-    $a = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+    if (method_exists($this, 'createMock')) {
+      $a = $this->createMock('\Drupal\Tests\Component\Utility\Test1Interface');
+    }
+    else {
+      $a = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+    }
     $wildcards = [$a];
     $resolver = new ArgumentsResolver([], [], $wildcards);
 
     $callable = function ($route) {};
-    $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$route" argument.');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\RuntimeException::class);
+      $this->expectExceptionMessage('requires a value for the "$route" argument.');
+    }
+    else {
+      $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$route" argument.');
+    }
     $resolver->getArguments($callable);
   }
 
@@ -156,7 +174,13 @@ public function testHandleNotUpcastedArgument() {
     $resolver = new ArgumentsResolver($scalars, $objects, []);
 
     $callable = function (\stdClass $foo) {};
-    $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\RuntimeException::class);
+      $this->expectExceptionMessage('requires a value for the "$foo" argument.');
+    }
+    else {
+      $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+    }
     $resolver->getArguments($callable);
   }
 
@@ -167,7 +191,13 @@ public function testHandleNotUpcastedArgument() {
    */
   public function testHandleUnresolvedArgument($callable) {
     $resolver = new ArgumentsResolver([], [], []);
-    $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\RuntimeException::class);
+      $this->expectExceptionMessage('requires a value for the "$foo" argument.');
+    }
+    else {
+      $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+    }
     $resolver->getArguments($callable);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Utility/ColorTest.php b/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
index cbb9d7e..aea1779 100644
--- a/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
@@ -26,7 +26,12 @@ class ColorTest extends TestCase {
    */
   public function testHexToRgb($value, $expected, $invalid = FALSE) {
     if ($invalid) {
-      $this->setExpectedException('InvalidArgumentException');
+      if (method_exists($this, 'expectException')) {
+        $this->expectException('InvalidArgumentException');
+      }
+      else {
+        $this->setExpectedException('InvalidArgumentException');
+      }
     }
     $this->assertSame($expected, Color::hexToRgb($value));
   }
diff --git a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
index c87628f..80208ef 100644
--- a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
@@ -77,7 +77,12 @@ public function testHmacBase64($data, $key, $expected_hmac) {
    *   Key to use in hashing process.
    */
   public function testHmacBase64Invalid($data, $key) {
-    $this->setExpectedException(\InvalidArgumentException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException('InvalidArgumentException');
+    }
+    else {
+      $this->setExpectedException('InvalidArgumentException');
+    }
     Crypt::hmacBase64($data, $key);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
index 1860e04..a8a8af0 100644
--- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
@@ -343,7 +343,12 @@ public function testTransformRootRelativeUrlsToAbsolute($html, $scheme_and_host,
    * @dataProvider providerTestTransformRootRelativeUrlsToAbsoluteAssertion
    */
   public function testTransformRootRelativeUrlsToAbsoluteAssertion($scheme_and_host) {
-    $this->setExpectedException(\AssertionError::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\AssertionError::class);
+    }
+    else {
+      $this->setExpectedException(\AssertionError::class);
+    }
     Html::transformRootRelativeUrlsToAbsolute('', $scheme_and_host);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
index 64f0eaa..7523c8b 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
@@ -62,7 +62,12 @@ public function testRandomNameException() {
     // There are fewer than 100 possibilities so an exception should occur to
     // prevent infinite loops.
     $random = new Random();
-    $this->setExpectedException(\RuntimeException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\RuntimeException::class);
+    }
+    else {
+      $this->setExpectedException(\RuntimeException::class);
+    }
     for ($i = 0; $i <= 100; $i++) {
       $str = $random->name(1, TRUE);
       $names[$str] = TRUE;
@@ -78,7 +83,12 @@ public function testRandomStringException() {
     // There are fewer than 100 possibilities so an exception should occur to
     // prevent infinite loops.
     $random = new Random();
-    $this->setExpectedException(\RuntimeException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\RuntimeException::class);
+    }
+    else {
+      $this->setExpectedException(\RuntimeException::class);
+    }
     for ($i = 0; $i <= 100; $i++) {
       $str = $random->string(1, TRUE);
       $names[$str] = TRUE;
diff --git a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
index 49d0833..ef46b79 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
@@ -17,7 +17,12 @@ class RectangleTest extends TestCase {
    * @covers ::rotate
    */
   public function testWrongWidth() {
-    $this->setExpectedException(\InvalidArgumentException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\InvalidArgumentException::class);
+    }
+    else {
+      $this->setExpectedException(\InvalidArgumentException::class);
+    }
     $rect = new Rectangle(-40, 20);
   }
 
@@ -27,7 +32,12 @@ public function testWrongWidth() {
    * @covers ::rotate
    */
   public function testWrongHeight() {
-    $this->setExpectedException(\InvalidArgumentException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\InvalidArgumentException::class);
+    }
+    else {
+      $this->setExpectedException(\InvalidArgumentException::class);
+    }
     $rect = new Rectangle(40, 0);
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
index 7f249d9..f811c16 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
@@ -37,7 +37,7 @@ protected function tearDown() {
    * @covers ::isSafe
    */
   public function testIsSafe() {
-    $safe_string = $this->getMock('\Drupal\Component\Render\MarkupInterface');
+    $safe_string = $this->getMockBuilder('\Drupal\Component\Render\MarkupInterface')->getMock();
     $this->assertTrue(SafeMarkup::isSafe($safe_string));
     $string_object = new SafeMarkupTestString('test');
     $this->assertFalse(SafeMarkup::isSafe($string_object));
diff --git a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
index 6bfc6cb..ba1757f 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
@@ -33,7 +33,12 @@ protected function setUp() {
    */
   public function testStatus($value, $expected, $invalid = FALSE) {
     if ($invalid) {
-      $this->setExpectedException('InvalidArgumentException');
+      if (method_exists($this, 'expectException')) {
+        $this->expectException('InvalidArgumentException');
+      }
+      else {
+        $this->setExpectedException('InvalidArgumentException');
+      }
     }
     Unicode::setStatus($value);
     $this->assertEquals($expected, Unicode::getStatus());
diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index db78cd9..d185219 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -578,7 +578,12 @@ public function providerTestExternalIsLocal() {
    * @dataProvider providerTestExternalIsLocalInvalid
    */
   public function testExternalIsLocalInvalid($url, $base_url) {
-    $this->setExpectedException(\InvalidArgumentException::class);
+    if (method_exists($this, 'expectException')) {
+      $this->expectException(\InvalidArgumentException::class);
+    }
+    else {
+      $this->setExpectedException(\InvalidArgumentException::class);
+    }
     UrlHelper::externalIsLocal($url, $base_url);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
index 1ee804d..a92d76a 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
@@ -166,10 +166,6 @@ protected function setUp() {
       ]);
     $entity_type_manager
       ->expects($this->any())
-      ->method('getFieldDefinitions')
-      ->willReturn([]);
-    $entity_type_manager
-      ->expects($this->any())
       ->method('getDefinition')
       ->will($this->returnValue($entity_form_display_entity_type));
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
index ad68e2d..55928b9 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
@@ -123,9 +123,6 @@ public function testGetOperations() {
     $url = $this->getMockBuilder('\Drupal\Core\Url')
       ->disableOriginalConstructor()
       ->getMock();
-    $url->expects($this->any())
-      ->method('toArray')
-      ->will($this->returnValue([]));
     $url->expects($this->atLeastOnce())
       ->method('mergeOptions')
       ->with(['query' => ['destination' => '/foo/bar']]);
diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
index 4a2dac5..846ce0a 100644
--- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@@ -361,7 +361,7 @@ public function testSaveConfigEntity() {
     $this->assertSame('foo', $entity->getOriginalId());
 
     $expected = ['id' => 'foo'];
-    $entity->expects($this->once())
+    $entity->expects($this->atLeastOnce())
       ->method('toArray')
       ->will($this->returnValue($expected));
 
diff --git a/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php b/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php
index 61b6211..ad39304 100644
--- a/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php
+++ b/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php
@@ -21,6 +21,7 @@
  * would trigger another deprecation error.
  *
  * @group Listeners
+ * @group legacy
  *
  * @coversDefaultClass \Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass
  */
@@ -29,6 +30,8 @@ class DrupalStandardsListenerDeprecationTest extends UnitTestCase {
   /**
    * Exercise DrupalStandardsListener's coverage validation.
    *
+   * @expectedDeprecation Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass is deprecated.
+   *
    * @covers ::testFunction
    */
   public function testDeprecation() {
diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
index 2512602..0f934eb 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
@@ -102,12 +102,12 @@ public function testSortLoggers() {
    */
   public function providerTestLog() {
     $account_mock = $this->getMock('Drupal\Core\Session\AccountInterface');
-    $account_mock->expects($this->exactly(2))
+    $account_mock->expects($this->any())
       ->method('id')
       ->will($this->returnValue(1));
 
-    $request_mock = $this->getMock('Symfony\Component\HttpFoundation\Request');
-    $request_mock->expects($this->exactly(2))
+    $request_mock = $this->getMock('Symfony\Component\HttpFoundation\Request', ['getClientIp']);
+    $request_mock->expects($this->any())
       ->method('getClientIp')
       ->will($this->returnValue('127.0.0.1'));
     $request_mock->headers = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
index 929930a..e6215ca 100644
--- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
+++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
@@ -76,12 +76,6 @@ protected function setUp() {
     $language_manager->expects($this->any())
       ->method('getLanguageTypes')
       ->will($this->returnValue([LanguageInterface::TYPE_INTERFACE]));
-    $language_manager->expects($this->any())
-      ->method('getNegotiationMethods')
-      ->will($this->returnValue($method_definitions));
-    $language_manager->expects($this->any())
-      ->method('getNegotiationMethodInstance')
-      ->will($this->returnValue($method_instance));
 
     $method_instance->setLanguageManager($language_manager);
     $this->languageManager = $language_manager;
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
index 2190d53..7dead3d 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@@ -104,6 +104,7 @@ public function testSetContextValueCacheableDependency() {
     $container = new Container();
     $cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
       ->disableOriginalConstructor()
+      ->setMethods(['validateTokens'])
       ->getMock();
     $container->set('cache_contexts_manager', $cache_context_manager);
     $cache_context_manager->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
index 1fca817..a881e7c 100644
--- a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
@@ -38,6 +38,7 @@ public function testMerge(BubbleableMetadata $a, CacheableMetadata $b, Bubbleabl
     if (!$b instanceof BubbleableMetadata) {
       $renderer = $this->getMockBuilder('Drupal\Core\Render\Renderer')
         ->disableOriginalConstructor()
+        ->setMethods(['mergeAttachments'])
         ->getMock();
       $renderer->expects($this->never())
         ->method('mergeAttachments');
diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListener.php b/core/tests/Drupal/Tests/Listeners/DeprecationListener.php
deleted file mode 100644
index 80b3d31..0000000
--- a/core/tests/Drupal/Tests/Listeners/DeprecationListener.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-
-namespace Drupal\Tests\Listeners;
-
-/**
- * Removes deprecations that we are yet to fix.
- *
- * @internal
- *   This class will be removed once all the deprecation notices have been
- *   fixed.
- */
-class DeprecationListener extends \PHPUnit_Framework_BaseTestListener {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function endTest(\PHPUnit_Framework_Test $test, $time) {
-    // Need to edit the file of deprecations.
-    if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
-      $deprecations = file_get_contents($file);
-      $deprecations = $deprecations ? unserialize($deprecations) : [];
-      $resave = FALSE;
-      foreach ($deprecations as $key => $deprecation) {
-        if (in_array($deprecation[1], static::getSkippedDeprecations())) {
-          unset($deprecations[$key]);
-          $resave = TRUE;
-        }
-      }
-      if ($resave) {
-        file_put_contents($file, serialize($deprecations));
-      }
-    }
-  }
-
-  /**
-   * A list of deprecations to ignore whilst fixes are put in place.
-   *
-   * @return string[]
-   *   A list of deprecations to ignore.
-   *
-   * @internal
-   */
-  public static function getSkippedDeprecations() {
-    return [
-      'As of 3.1 an Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface is used to resolve arguments. In 4.0 the $argumentResolver becomes the Symfony\Component\HttpKernel\Controller\ArgumentResolver if no other is provided instead of using the $resolver argument.',
-      'Symfony\Component\HttpKernel\Controller\ControllerResolver::getArguments is deprecated as of 3.1 and will be removed in 4.0. Implement the Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface and inject it in the HttpKernel instead.',
-      'The Twig_Node::getLine method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateLine() instead.',
-      'The Twig_Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.',
-      'Install profile will be a mandatory parameter in Drupal 9.0.',
-      'Setting the strict option of the Choice constraint to false is deprecated since version 3.2 and will be removed in 4.0.',
-      'The revision_user revision metadata key is not set.',
-      'The revision_created revision metadata key is not set.',
-      'The revision_log_message revision metadata key is not set.',
-      'The "entity.query" service relies on the deprecated "Drupal\Core\Entity\Query\QueryFactory" class. It should either be deprecated or its implementation upgraded.',
-      'MigrateCckField is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.',
-      'MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager instead.',
-      'MigrateCckFieldPluginManagerInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManagerInterface instead.',
-      'The "plugin.manager.migrate.cckfield" service is deprecated. You should use the \'plugin.manager.migrate.field\' service instead. See https://www.drupal.org/node/2751897',
-      'The Drupal\migrate\Plugin\migrate\process\Iterator is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\SubProcess',
-      'Drupal\system\Tests\Update\DbUpdatesTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\DbUpdatesTrait instead. See https://www.drupal.org/node/2896640.',
-      'Using "null" for the value of node "count" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
-      'Using "null" for the value of node "options" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
-      'Using "null" for the value of node "plural" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
-      'The Behat\Mink\Selector\SelectorsHandler::xpathLiteral method is deprecated as of 1.7 and will be removed in 2.0. Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral instead when building Xpath or pass the unescaped value when using the named selector.',
-      'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0. Pass the raw value instead.',
-      'Providing settings under \'handler_settings\' is deprecated and will be removed before 9.0.0. Move the settings in the root of the configuration array. See https://www.drupal.org/node/2870971.',
-      'AssertLegacyTrait::getRawContent() is scheduled for removal in Drupal 9.0.0. Use $this->getSession()->getPage()->getContent() instead.',
-      'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.',
-      'assertNoCacheTag() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseHeaderNotContains() instead. See https://www.drupal.org/node/2864029.',
-      'assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.',
-      'The $published parameter is deprecated since version 8.3.x and will be removed in 9.0.0.',
-      'The Drupal\config\Tests\AssertConfigEntityImportTrait is deprecated in Drupal 8.4.1 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait. See https://www.drupal.org/node/2916197.',
-      'Drupal\system\Tests\Menu\AssertBreadcrumbTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait',
-      '\Drupal\Tests\node\Functional\AssertButtonsTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\AssertButtonsTrait',
-      'Drupal\system\Tests\Menu\AssertMenuActiveTrailTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertMenuActiveTrailTrait',
-      'Drupal\taxonomy\Tests\TaxonomyTranslationTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTranslationTestTrait',
-      'Drupal\basic_auth\Tests\BasicAuthTestTrait is deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. Use \Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait instead. See https://www.drupal.org/node/2862800.',
-      'Drupal\taxonomy\Tests\TaxonomyTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait',
-      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/system-test/Ȅchȏ/meφΩ/{text}".',
-      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/somewhere/{item}/over/the/קainbow".',
-      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/place/meφω".',
-      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/PLACE/meφω".',
-      'Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.',
-      'The Drupal\editor\Plugin\EditorBase::settingsFormValidate method is deprecated since version 8.3.x and will be removed in 9.0.0.',
-      'CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.',
-      'The Drupal\migrate\Plugin\migrate\process\Migration is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\MigrationLookup',
-      'LinkField is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d7\LinkField instead.',
-      'LinkField is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d6\LinkField instead.',
-      'CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.',
-      'MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.',
-      'Drupal\system\Plugin\views\field\BulkForm is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\views\Plugin\views\field\BulkForm instead. See https://www.drupal.org/node/2916716.',
-      'The numeric plugin for watchdog.wid field is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Must use standard plugin instead. See https://www.drupal.org/node/2876378.',
-      'The numeric plugin for watchdog.uid field is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Must use standard plugin instead. See https://www.drupal.org/node/2876378.',
-      'The in_operator plugin for watchdog.type filter is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Must use dblog_types plugin instead. See https://www.drupal.org/node/2876378.',
-      'Using an instance of "Twig_Filter_Function" for filter "testfilter" is deprecated since version 1.21. Use Twig_SimpleFilter instead.',
-      'The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.',
-      'Using an instance of "Twig_Function_Function" for function "testfunc" is deprecated since version 1.21. Use Twig_SimpleFunction instead.',
-      'The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.',
-      'The Twig_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.',
-      'The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.',
-      'The Twig_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.',
-      'Referencing the "twig_extension_test.test_extension" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.',
-      'Passing in arguments the legacy way is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Provide the right parameter names in the method, similar to controllers. See https://www.drupal.org/node/2894819',
-      'DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead.',
-      'The Drupal\taxonomy\Entity\Term::getVocabularyId method is deprecated since version 8.4.0 and will be removed before 9.0.0. Use Drupal\taxonomy\Entity\Term::bundle() instead to get the vocabulary ID.',
-      'The Drupal\editor\Plugin\EditorBase::settingsFormSubmit method is deprecated since version 8.3.x and will be removed in 9.0.0.',
-      'CommentVariable is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.',
-      'CommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d7\NodeType instead.',
-      'CommentVariablePerCommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.',
-      'The Drupal\config_translation\Plugin\migrate\source\d6\I18nProfileField is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\config_translation\Plugin\migrate\source\d6\ProfileFieldTranslation',
-      'The Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation',
-      'Implicit cacheability metadata bubbling (onto the global render context) in normalizers is deprecated since Drupal 8.5.0 and will be removed in Drupal 9.0.0. Use the "cacheability" serialization context instead, for explicit cacheability metadata bubbling. See https://www.drupal.org/node/2918937',
-      'Automatically creating the first item for computed fields is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\TypedData\ComputedItemListTrait instead.',
-      '"\Drupal\Core\Entity\ContentEntityStorageBase::doLoadRevisionFieldItems()" is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. "\Drupal\Core\Entity\ContentEntityStorageBase::doLoadMultipleRevisionsFieldItems()" should be implemented instead. See https://www.drupal.org/node/2924915.',
-      'Passing a single revision ID to "\Drupal\Core\Entity\Sql\SqlContentEntityStorage::buildQuery()" is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. An array of revision IDs should be given instead. See https://www.drupal.org/node/2924915.',
-    ];
-  }
-
-}
diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
new file mode 100644
index 0000000..8b828e0
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -0,0 +1,125 @@
+<?php
+
+namespace Drupal\Tests\Listeners;
+
+/**
+ * Removes deprecations that we are yet to fix.
+ *
+ * @internal
+ *   This class will be removed once all the deprecation notices have been
+ *   fixed.
+ */
+trait DeprecationListenerTrait {
+
+  /**
+   * Reacts to the end of a test.
+   *
+   * @param $test
+   *   The test object that has ended its test run.
+   * @param float $time
+   *   The time the test took.
+   */
+  protected function deprecationEndTest($test, $time) {
+    /** @var \PHPUnit\Framework\Test $test */
+    // Need to edit the file of deprecations.
+    if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
+      $deprecations = file_get_contents($file);
+      $deprecations = $deprecations ? unserialize($deprecations) : [];
+      $resave = FALSE;
+      foreach ($deprecations as $key => $deprecation) {
+        if (in_array($deprecation[1], static::getSkippedDeprecations())) {
+          unset($deprecations[$key]);
+          $resave = TRUE;
+        }
+      }
+      if ($resave) {
+        file_put_contents($file, serialize($deprecations));
+      }
+    }
+  }
+
+  /**
+   * A list of deprecations to ignore whilst fixes are put in place.
+   *
+   * @return string[]
+   *   A list of deprecations to ignore.
+   *
+   * @internal
+   */
+  public static function getSkippedDeprecations() {
+    return [
+      'As of 3.1 an Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface is used to resolve arguments. In 4.0 the $argumentResolver becomes the Symfony\Component\HttpKernel\Controller\ArgumentResolver if no other is provided instead of using the $resolver argument.',
+      'Symfony\Component\HttpKernel\Controller\ControllerResolver::getArguments is deprecated as of 3.1 and will be removed in 4.0. Implement the Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface and inject it in the HttpKernel instead.',
+      'The Twig_Node::getLine method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateLine() instead.',
+      'The Twig_Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.',
+      'Install profile will be a mandatory parameter in Drupal 9.0.',
+      'Setting the strict option of the Choice constraint to false is deprecated since version 3.2 and will be removed in 4.0.',
+      'The revision_user revision metadata key is not set.',
+      'The revision_created revision metadata key is not set.',
+      'The revision_log_message revision metadata key is not set.',
+      'The "entity.query" service relies on the deprecated "Drupal\Core\Entity\Query\QueryFactory" class. It should either be deprecated or its implementation upgraded.',
+      'MigrateCckField is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.',
+      'MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager instead.',
+      'MigrateCckFieldPluginManagerInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManagerInterface instead.',
+      'The "plugin.manager.migrate.cckfield" service is deprecated. You should use the \'plugin.manager.migrate.field\' service instead. See https://www.drupal.org/node/2751897',
+      'The Drupal\migrate\Plugin\migrate\process\Iterator is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\SubProcess',
+      'Drupal\system\Tests\Update\DbUpdatesTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\DbUpdatesTrait instead. See https://www.drupal.org/node/2896640.',
+      'Using "null" for the value of node "count" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
+      'Using "null" for the value of node "options" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
+      'Using "null" for the value of node "plural" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
+      'The Behat\Mink\Selector\SelectorsHandler::xpathLiteral method is deprecated as of 1.7 and will be removed in 2.0. Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral instead when building Xpath or pass the unescaped value when using the named selector.',
+      'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0. Pass the raw value instead.',
+      'Providing settings under \'handler_settings\' is deprecated and will be removed before 9.0.0. Move the settings in the root of the configuration array. See https://www.drupal.org/node/2870971.',
+      'AssertLegacyTrait::getRawContent() is scheduled for removal in Drupal 9.0.0. Use $this->getSession()->getPage()->getContent() instead.',
+      'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.',
+      'assertNoCacheTag() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseHeaderNotContains() instead. See https://www.drupal.org/node/2864029.',
+      'assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.',
+      'The $published parameter is deprecated since version 8.3.x and will be removed in 9.0.0.',
+      'The Drupal\config\Tests\AssertConfigEntityImportTrait is deprecated in Drupal 8.4.1 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait. See https://www.drupal.org/node/2916197.',
+      'Drupal\system\Tests\Menu\AssertBreadcrumbTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait',
+      '\Drupal\Tests\node\Functional\AssertButtonsTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\AssertButtonsTrait',
+      'Drupal\system\Tests\Menu\AssertMenuActiveTrailTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertMenuActiveTrailTrait',
+      'Drupal\taxonomy\Tests\TaxonomyTranslationTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTranslationTestTrait',
+      'Drupal\basic_auth\Tests\BasicAuthTestTrait is deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. Use \Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait instead. See https://www.drupal.org/node/2862800.',
+      'Drupal\taxonomy\Tests\TaxonomyTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait',
+      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/system-test/Ȅchȏ/meφΩ/{text}".',
+      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/somewhere/{item}/over/the/קainbow".',
+      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/place/meφω".',
+      'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/PLACE/meφω".',
+      'Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.',
+      'The Drupal\editor\Plugin\EditorBase::settingsFormValidate method is deprecated since version 8.3.x and will be removed in 9.0.0.',
+      'CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.',
+      'The Drupal\migrate\Plugin\migrate\process\Migration is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\MigrationLookup',
+      'LinkField is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d7\LinkField instead.',
+      'LinkField is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d6\LinkField instead.',
+      'CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.',
+      'MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.',
+      'Drupal\system\Plugin\views\field\BulkForm is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\views\Plugin\views\field\BulkForm instead. See https://www.drupal.org/node/2916716.',
+      'The numeric plugin for watchdog.wid field is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Must use standard plugin instead. See https://www.drupal.org/node/2876378.',
+      'The numeric plugin for watchdog.uid field is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Must use standard plugin instead. See https://www.drupal.org/node/2876378.',
+      'The in_operator plugin for watchdog.type filter is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Must use dblog_types plugin instead. See https://www.drupal.org/node/2876378.',
+      'Using an instance of "Twig_Filter_Function" for filter "testfilter" is deprecated since version 1.21. Use Twig_SimpleFilter instead.',
+      'The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.',
+      'Using an instance of "Twig_Function_Function" for function "testfunc" is deprecated since version 1.21. Use Twig_SimpleFunction instead.',
+      'The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.',
+      'The Twig_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.',
+      'The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.',
+      'The Twig_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.',
+      'Referencing the "twig_extension_test.test_extension" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.',
+      'Passing in arguments the legacy way is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Provide the right parameter names in the method, similar to controllers. See https://www.drupal.org/node/2894819',
+      'DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead.',
+      'The Drupal\taxonomy\Entity\Term::getVocabularyId method is deprecated since version 8.4.0 and will be removed before 9.0.0. Use Drupal\taxonomy\Entity\Term::bundle() instead to get the vocabulary ID.',
+      'The Drupal\editor\Plugin\EditorBase::settingsFormSubmit method is deprecated since version 8.3.x and will be removed in 9.0.0.',
+      'CommentVariable is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.',
+      'CommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d7\NodeType instead.',
+      'CommentVariablePerCommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.',
+      'The Drupal\config_translation\Plugin\migrate\source\d6\I18nProfileField is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\config_translation\Plugin\migrate\source\d6\ProfileFieldTranslation',
+      'The Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation',
+      'Implicit cacheability metadata bubbling (onto the global render context) in normalizers is deprecated since Drupal 8.5.0 and will be removed in Drupal 9.0.0. Use the "cacheability" serialization context instead, for explicit cacheability metadata bubbling. See https://www.drupal.org/node/2918937',
+      'Automatically creating the first item for computed fields is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\TypedData\ComputedItemListTrait instead.',
+      '"\Drupal\Core\Entity\ContentEntityStorageBase::doLoadRevisionFieldItems()" is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. "\Drupal\Core\Entity\ContentEntityStorageBase::doLoadMultipleRevisionsFieldItems()" should be implemented instead. See https://www.drupal.org/node/2924915.',
+      'Passing a single revision ID to "\Drupal\Core\Entity\Sql\SqlContentEntityStorage::buildQuery()" is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. An array of revision IDs should be given instead. See https://www.drupal.org/node/2924915.',
+    ];
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListener.php b/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListener.php
deleted file mode 100644
index c349677..0000000
--- a/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListener.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-namespace Drupal\Tests\Listeners;
-
-use Drupal\KernelTests\KernelTestBase;;
-use Drupal\Tests\BrowserTestBase;;
-use Drupal\Tests\UnitTestCase;
-use PHPUnit\Framework\BaseTestListener;
-
-/**
- * Ensures that no component tests are extending a core test base class.
- */
-class DrupalComponentTestListener extends BaseTestListener {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function endTest(\PHPUnit_Framework_Test $test, $time) {
-    if (substr($test->toString(), 0, 22) == 'Drupal\Tests\Component') {
-      if ($test instanceof BrowserTestBase || $test instanceof KernelTestBase || $test instanceof UnitTestCase) {
-        $error = new \PHPUnit_Framework_AssertionFailedError('Component tests should not extend a core test base class.');
-        $test->getTestResultObject()->addFailure($test, $error, $time);
-      }
-    }
-  }
-
-}
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php
new file mode 100644
index 0000000..0284f6d
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\Tests\Listeners;
+
+use Drupal\KernelTests\KernelTestBase;;
+use Drupal\Tests\BrowserTestBase;;
+use Drupal\Tests\UnitTestCase;
+use PHPUnit\Framework\AssertionFailedError;
+
+/**
+ * Ensures that no component tests are extending a core test base class.
+ *
+ * @internal
+ */
+trait DrupalComponentTestListenerTrait {
+
+  /**
+   * Reacts to the end of a test.
+   *
+   * @param $test
+   *   The test object that has ended its test run.
+   * @param float $time
+   *   The time the test took.
+   */
+  protected function componentEndTest($test, $time) {
+    /** @var \PHPUnit\Framework\Test $test */
+    if (substr($test->toString(), 0, 22) == 'Drupal\Tests\Component') {
+      if ($test instanceof BrowserTestBase || $test instanceof KernelTestBase || $test instanceof UnitTestCase) {
+        $error = new AssertionFailedError('Component tests should not extend a core test base class.');
+        $test->getTestResultObject()->addFailure($test, $error, $time);
+      }
+    }
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalListener.php b/core/tests/Drupal/Tests/Listeners/DrupalListener.php
new file mode 100644
index 0000000..db0c822
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/DrupalListener.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\Tests\Listeners;
+
+use PHPUnit\Framework\BaseTestListener;
+use PHPUnit\Framework\Test;
+
+if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
+  class_alias('Drupal\Tests\Listeners\Legacy\DrupalListener', 'Drupal\Tests\Listeners\DrupalListener');
+  // Using an early return instead of a else does not work when using the
+  // PHPUnit phar due to some weird PHP behavior (the class gets defined without
+  // executing the code before it and so the definition is not properly
+  // conditional).
+}
+else {
+  /**
+   * Removes deprecations that we are yet to fix.
+   *
+   * @internal
+   */
+  class DrupalListener extends BaseTestListener {
+    use DeprecationListenerTrait;
+    use DrupalComponentTestListenerTrait;
+    use DrupalStandardsListenerTrait;
+
+    /**
+     * {@inheritdoc}
+     */
+    public function endTest(Test $test, $time) {
+      $this->deprecationEndTest($test, $time);
+      $this->componentEndTest($test, $time);
+      $this->standardsEndTest($test, $time);
+    }
+
+  }
+}
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php b/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php
deleted file mode 100644
index fd15f82..0000000
--- a/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-
-namespace Drupal\Tests\Listeners;
-
-use PHPUnit\Framework\BaseTestListener;
-use PHPUnit\Framework\TestCase;
-
-/**
- * Listens for PHPUnit tests and fails those with invalid coverage annotations.
- *
- * Enforces various coding standards within test runs.
- */
-class DrupalStandardsListener extends BaseTestListener {
-
-  /**
-   * Signals a coding standards failure to the user.
-   *
-   * @param \PHPUnit\Framework\TestCase $test
-   *   The test where we should insert our test failure.
-   * @param string $message
-   *   The message to add to the failure notice. The test class name and test
-   *   name will be appended to this message automatically.
-   */
-  protected function fail(TestCase $test, $message) {
-    // Add the report to the test's results.
-    $message .= ': ' . get_class($test) . '::' . $test->getName();
-    $fail = new \PHPUnit_Framework_AssertionFailedError($message);
-    $result = $test->getTestResultObject();
-    $result->addFailure($test, $fail, 0);
-  }
-
-  /**
-   * Helper method to check if a string names a valid class or trait.
-   *
-   * @param string $class
-   *   Name of the class to check.
-   *
-   * @return bool
-   *   TRUE if the class exists, FALSE otherwise.
-   */
-  protected function classExists($class) {
-    return class_exists($class, TRUE) || trait_exists($class, TRUE) || interface_exists($class, TRUE);
-  }
-
-  /**
-   * Check an individual test run for valid @covers annotation.
-   *
-   * This method is called from $this::endTest().
-   *
-   * @param \PHPUnit\Framework\TestCase $test
-   *   The test to examine.
-   */
-  public function checkValidCoversForTest(TestCase $test) {
-    // If we're generating a coverage report already, don't do anything here.
-    if ($test->getTestResultObject() && $test->getTestResultObject()->getCollectCodeCoverageInformation()) {
-      return;
-    }
-    // Gather our annotations.
-    $annotations = $test->getAnnotations();
-    // Glean the @coversDefaultClass annotation.
-    $default_class = '';
-    $valid_default_class = FALSE;
-    if (isset($annotations['class']['coversDefaultClass'])) {
-      if (count($annotations['class']['coversDefaultClass']) > 1) {
-        $this->fail($test, '@coversDefaultClass has too many values');
-      }
-      // Grab the first one.
-      $default_class = reset($annotations['class']['coversDefaultClass']);
-      // Check whether the default class exists.
-      $valid_default_class = $this->classExists($default_class);
-      if (!$valid_default_class) {
-        $this->fail($test, "@coversDefaultClass does not exist '$default_class'");
-      }
-    }
-    // Glean @covers annotation.
-    if (isset($annotations['method']['covers'])) {
-      // Drupal allows multiple @covers per test method, so we have to check
-      // them all.
-      foreach ($annotations['method']['covers'] as $covers) {
-        // Ensure the annotation isn't empty.
-        if (trim($covers) === '') {
-          $this->fail($test, '@covers should not be empty');
-          // If @covers is empty, we can't proceed.
-          return;
-        }
-        // Ensure we don't have ().
-        if (strpos($covers, '()') !== FALSE) {
-          $this->fail($test, "@covers invalid syntax: Do not use '()'");
-        }
-        // Glean the class and method from @covers.
-        $class = $covers;
-        $method = '';
-        if (strpos($covers, '::') !== FALSE) {
-          list($class, $method) = explode('::', $covers);
-        }
-        // Check for the existence of the class if it's specified by @covers.
-        if (!empty($class)) {
-          // If the class doesn't exist we have either a bad classname or
-          // are missing the :: for a method. Either way we can't proceed.
-          if (!$this->classExists($class)) {
-            if (empty($method)) {
-              $this->fail($test, "@covers invalid syntax: Needs '::' or class does not exist in $covers");
-              return;
-            }
-            else {
-              $this->fail($test, '@covers class does not exist ' . $class);
-              return;
-            }
-          }
-        }
-        else {
-          // The class isn't specified and we have the ::, so therefore this
-          // test either covers a function, or relies on a default class.
-          if (empty($default_class)) {
-            // If there's no default class, then we need to check if the global
-            // function exists. Since this listener should always be listening
-            // for endTest(), the function should have already been loaded from
-            // its .module or .inc file.
-            if (!function_exists($method)) {
-              $this->fail($test, '@covers global method does not exist ' . $method);
-            }
-          }
-          else {
-            // We have a default class and this annotation doesn't act like a
-            // global function, so we should use the default class if it's
-            // valid.
-            if ($valid_default_class) {
-              $class = $default_class;
-            }
-          }
-        }
-        // Finally, after all that, let's see if the method exists.
-        if (!empty($class) && !empty($method)) {
-          $ref_class = new \ReflectionClass($class);
-          if (!$ref_class->hasMethod($method)) {
-            $this->fail($test, '@covers method does not exist ' . $class . '::' . $method);
-          }
-        }
-      }
-    }
-  }
-
-  /**
-   * {@inheritdoc}
-   *
-   * We must mark this method as belonging to the special legacy group because
-   * it might trigger an E_USER_DEPRECATED error during coverage annotation
-   * validation. The legacy group allows symfony/phpunit-bridge to keep the
-   * deprecation notice as a warning instead of an error, which would fail the
-   * test.
-   *
-   * @group legacy
-   *
-   * @see http://symfony.com/doc/current/components/phpunit_bridge.html#mark-tests-as-legacy
-   */
-  public function endTest(\PHPUnit_Framework_Test $test, $time) {
-    // \PHPUnit_Framework_Test does not have any useful methods of its own for
-    // our purpose, so we have to distinguish between the different known
-    // subclasses.
-    if ($test instanceof TestCase) {
-      $this->checkValidCoversForTest($test);
-    }
-    elseif ($test instanceof \PHPUnit_Framework_TestSuite) {
-      foreach ($test->getGroupDetails() as $tests) {
-        foreach ($tests as $test) {
-          $this->endTest($test, $time);
-        }
-      }
-    }
-  }
-
-}
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php
new file mode 100644
index 0000000..d94299c
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php
@@ -0,0 +1,211 @@
+<?php
+
+namespace Drupal\Tests\Listeners;
+
+use PHPUnit\Framework\AssertionFailedError;
+use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\TestSuite;
+
+/**
+ * Listens for PHPUnit tests and fails those with invalid coverage annotations.
+ *
+ * Enforces various coding standards within test runs.
+ *
+ * @internal
+ */
+trait DrupalStandardsListenerTrait {
+
+  /**
+   * Signals a coding standards failure to the user.
+   *
+   * @param \PHPUnit\Framework\TestCase $test
+   *   The test where we should insert our test failure.
+   * @param string $message
+   *   The message to add to the failure notice. The test class name and test
+   *   name will be appended to this message automatically.
+   */
+  private function fail(TestCase $test, $message) {
+    // Add the report to the test's results.
+    $message .= ': ' . get_class($test) . '::' . $test->getName();
+    $fail = new AssertionFailedError($message);
+    $result = $test->getTestResultObject();
+    $result->addFailure($test, $fail, 0);
+  }
+
+  /**
+   * Helper method to check if a string names a valid class or trait.
+   *
+   * @param string $class
+   *   Name of the class to check.
+   *
+   * @return bool
+   *   TRUE if the class exists, FALSE otherwise.
+   */
+  private function classExists($class) {
+    return class_exists($class, TRUE) || trait_exists($class, TRUE) || interface_exists($class, TRUE);
+  }
+
+  /**
+   * Check an individual test run for valid @covers annotation.
+   *
+   * This method is called from $this::endTest().
+   *
+   * @param \PHPUnit\Framework\TestCase $test
+   *   The test to examine.
+   */
+  private function checkValidCoversForTest(TestCase $test) {
+    // If we're generating a coverage report already, don't do anything here.
+    if ($test->getTestResultObject() && $test->getTestResultObject()->getCollectCodeCoverageInformation()) {
+      return;
+    }
+    // Gather our annotations.
+    $annotations = $test->getAnnotations();
+    // Glean the @coversDefaultClass annotation.
+    $default_class = '';
+    $valid_default_class = FALSE;
+    if (isset($annotations['class']['coversDefaultClass'])) {
+      if (count($annotations['class']['coversDefaultClass']) > 1) {
+        $this->fail($test, '@coversDefaultClass has too many values');
+      }
+      // Grab the first one.
+      $default_class = reset($annotations['class']['coversDefaultClass']);
+      // Check whether the default class exists.
+      $valid_default_class = $this->classExists($default_class);
+      if (!$valid_default_class) {
+        $this->fail($test, "@coversDefaultClass does not exist '$default_class'");
+      }
+    }
+    // Glean @covers annotation.
+    if (isset($annotations['method']['covers'])) {
+      // Drupal allows multiple @covers per test method, so we have to check
+      // them all.
+      foreach ($annotations['method']['covers'] as $covers) {
+        // Ensure the annotation isn't empty.
+        if (trim($covers) === '') {
+          $this->fail($test, '@covers should not be empty');
+          // If @covers is empty, we can't proceed.
+          return;
+        }
+        // Ensure we don't have ().
+        if (strpos($covers, '()') !== FALSE) {
+          $this->fail($test, "@covers invalid syntax: Do not use '()'");
+        }
+        // Glean the class and method from @covers.
+        $class = $covers;
+        $method = '';
+        if (strpos($covers, '::') !== FALSE) {
+          list($class, $method) = explode('::', $covers);
+        }
+        // Check for the existence of the class if it's specified by @covers.
+        if (!empty($class)) {
+          // If the class doesn't exist we have either a bad classname or
+          // are missing the :: for a method. Either way we can't proceed.
+          if (!$this->classExists($class)) {
+            if (empty($method)) {
+              $this->fail($test, "@covers invalid syntax: Needs '::' or class does not exist in $covers");
+              return;
+            }
+            else {
+              $this->fail($test, '@covers class does not exist ' . $class);
+              return;
+            }
+          }
+        }
+        else {
+          // The class isn't specified and we have the ::, so therefore this
+          // test either covers a function, or relies on a default class.
+          if (empty($default_class)) {
+            // If there's no default class, then we need to check if the global
+            // function exists. Since this listener should always be listening
+            // for endTest(), the function should have already been loaded from
+            // its .module or .inc file.
+            if (!function_exists($method)) {
+              $this->fail($test, '@covers global method does not exist ' . $method);
+            }
+          }
+          else {
+            // We have a default class and this annotation doesn't act like a
+            // global function, so we should use the default class if it's
+            // valid.
+            if ($valid_default_class) {
+              $class = $default_class;
+            }
+          }
+        }
+        // Finally, after all that, let's see if the method exists.
+        if (!empty($class) && !empty($method)) {
+          $ref_class = new \ReflectionClass($class);
+          if (!$ref_class->hasMethod($method)) {
+            $this->fail($test, '@covers method does not exist ' . $class . '::' . $method);
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * Reacts to the end of a test.
+   *
+   * We must mark this method as belonging to the special legacy group because
+   * it might trigger an E_USER_DEPRECATED error during coverage annotation
+   * validation. The legacy group allows symfony/phpunit-bridge to keep the
+   * deprecation notice as a warning instead of an error, which would fail the
+   * test.
+   *
+   * @group legacy
+   *
+   * @param $test
+   *   The test object that has ended its test run.
+   * @param float $time
+   *   The time the test took.
+   *
+   * @see http://symfony.com/doc/current/components/phpunit_bridge.html#mark-tests-as-legacy
+   */
+  private function doEndTest($test, $time) {
+    // \PHPUnit_Framework_Test does not have any useful methods of its own for
+    // our purpose, so we have to distinguish between the different known
+    // subclasses.
+    if ($test instanceof TestCase) {
+      $this->checkValidCoversForTest($test);
+    }
+    elseif ($this->isTestSuite($test)) {
+      foreach ($test->getGroupDetails() as $tests) {
+        foreach ($tests as $test) {
+          $this->doEndTest($test, $time);
+        }
+      }
+    }
+  }
+
+  /**
+   * Determine if a test object is a test suite regardless of PHPUnit version.
+   *
+   * @param $test
+   *   The test object to test if it is a test suite.
+   *
+   * @return bool
+   *   TRUE if it is a test suite, FALSE if not.
+   */
+  private function isTestSuite($test) {
+    if (class_exists('\PHPUnit_Framework_TestSuite') && $test instanceof \PHPUnit_Framework_TestSuite) {
+      return TRUE;
+    }
+    if (class_exists('PHPUnit\Framework\TestSuite') && $test instanceof TestSuite) {
+      return TRUE;
+    }
+    return FALSE;
+  }
+
+  /**
+   * Reacts to the end of a test.
+   *
+   * @param $test
+   *   The test object that has ended its test run.
+   * @param float $time
+   *   The time the test took.
+   */
+  protected function standardsEndTest($test, $time) {
+    $this->doEndTest($test, $time);
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php b/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php
index ac22072..8021989 100644
--- a/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php
+++ b/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php
@@ -2,70 +2,41 @@
 
 namespace Drupal\Tests\Listeners;
 
-/**
- * Defines a class for providing html output results for functional tests.
- */
-class HtmlOutputPrinter extends \PHPUnit_TextUI_ResultPrinter {
-
+use PHPUnit\Framework\TestResult;
+use PHPUnit\TextUI\ResultPrinter;
+
+if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
+  class_alias('Drupal\Tests\Listeners\Legacy\HtmlOutputPrinter', 'Drupal\Tests\Listeners\HtmlOutputPrinter');
+  // Using an early return instead of a else does not work when using the
+  // PHPUnit phar due to some weird PHP behavior (the class gets defined without
+  // executing the code before it and so the definition is not properly
+  // conditional).
+}
+else {
   /**
-   * File to write html links to.
+   * Defines a class for providing html output results for functional tests.
    *
-   * @var string
+   * @internal
    */
-  protected $browserOutputFile;
-
-  /**
-   * {@inheritdoc}
-   */
-  public function __construct($out, $verbose, $colors, $debug, $numberOfColumns) {
-    parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns);
-    if ($html_output_directory = getenv('BROWSERTEST_OUTPUT_DIRECTORY')) {
-      // Initialize html output debugging.
-      $html_output_directory = rtrim($html_output_directory, '/');
-
-      // Check if directory exists.
-      if (!is_dir($html_output_directory) || !is_writable($html_output_directory)) {
-        $this->writeWithColor('bg-red, fg-black', "HTML output directory $html_output_directory is not a writable directory.");
-      }
-      else {
-        // Convert to a canonicalized absolute pathname just in case the current
-        // working directory is changed.
-        $html_output_directory = realpath($html_output_directory);
-        $this->browserOutputFile = tempnam($html_output_directory, 'browser_output_');
-        if ($this->browserOutputFile) {
-          touch($this->browserOutputFile);
-        }
-        else {
-          $this->writeWithColor('bg-red, fg-black', "Unable to create a temporary file in $html_output_directory.");
-        }
-      }
-    }
-
-    if ($this->browserOutputFile) {
-      putenv('BROWSERTEST_OUTPUT_FILE=' . $this->browserOutputFile);
-    }
-    else {
-      // Remove any environment variable.
-      putenv('BROWSERTEST_OUTPUT_FILE');
+  class HtmlOutputPrinter extends ResultPrinter {
+    use HtmlOutputPrinterTrait;
+    /**
+     * {@inheritdoc}
+     */
+    public function __construct($out = NULL, $verbose = FALSE, $colors = self::COLOR_DEFAULT, $debug = FALSE, $numberOfColumns = 80, $reverse = FALSE) {
+      parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns, $reverse);
+
+      $this->setUpHtmlOutput();
     }
-  }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function printResult(\PHPUnit_Framework_TestResult $result) {
-    parent::printResult($result);
+    /**
+     * {@inheritdoc}
+     */
+    public function printResult(TestResult $result) {
+      parent::printResult($result);
 
-    if ($this->browserOutputFile) {
-      $contents = file_get_contents($this->browserOutputFile);
-      if ($contents) {
-        $this->writeNewLine();
-        $this->writeWithColor('bg-yellow, fg-black', 'HTML output was generated');
-        $this->write($contents);
-      }
-      // No need to keep the file around any more.
-      unlink($this->browserOutputFile);
+      $this->printHtmlOutput();
     }
-  }
 
+  }
 }
diff --git a/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinterTrait.php b/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinterTrait.php
new file mode 100644
index 0000000..9900685
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinterTrait.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace Drupal\Tests\Listeners;
+
+/**
+ * Defines a class for providing html output results for functional tests.
+ *
+ * @internal
+ */
+trait HtmlOutputPrinterTrait {
+
+  /**
+   * File to write html links to.
+   *
+   * @var string
+   */
+  protected $browserOutputFile;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUpHtmlOutput() {
+    if ($html_output_directory = getenv('BROWSERTEST_OUTPUT_DIRECTORY')) {
+      // Initialize html output debugging.
+      $html_output_directory = rtrim($html_output_directory, '/');
+
+      // Check if directory exists.
+      if (!is_dir($html_output_directory) || !is_writable($html_output_directory)) {
+        $this->writeWithColor('bg-red, fg-black', "HTML output directory $html_output_directory is not a writable directory.");
+      }
+      else {
+        // Convert to a canonicalized absolute pathname just in case the current
+        // working directory is changed.
+        $html_output_directory = realpath($html_output_directory);
+        $this->browserOutputFile = tempnam($html_output_directory, 'browser_output_');
+        if ($this->browserOutputFile) {
+          touch($this->browserOutputFile);
+        }
+        else {
+          $this->writeWithColor('bg-red, fg-black', "Unable to create a temporary file in $html_output_directory.");
+        }
+      }
+    }
+
+    if ($this->browserOutputFile) {
+      putenv('BROWSERTEST_OUTPUT_FILE=' . $this->browserOutputFile);
+    }
+    else {
+      // Remove any environment variable.
+      putenv('BROWSERTEST_OUTPUT_FILE');
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function printHtmlOutput() {
+    if ($this->browserOutputFile) {
+      $contents = file_get_contents($this->browserOutputFile);
+      if ($contents) {
+        $this->writeNewLine();
+        $this->writeWithColor('bg-yellow, fg-black', 'HTML output was generated');
+        $this->write($contents);
+      }
+      // No need to keep the file around any more.
+      unlink($this->browserOutputFile);
+    }
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Listeners/Legacy/DrupalListener.php b/core/tests/Drupal/Tests/Listeners/Legacy/DrupalListener.php
new file mode 100644
index 0000000..f7c2c76
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/Legacy/DrupalListener.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\Tests\Listeners\Legacy;
+
+use Drupal\Tests\Listeners\DeprecationListenerTrait;
+use Drupal\Tests\Listeners\DrupalComponentTestListenerTrait;
+use Drupal\Tests\Listeners\DrupalStandardsListenerTrait;
+
+/**
+ * Listens to PHPUnit test runs.
+ *
+ * @internal
+ *   This class is not public Drupal API.
+ */
+class DrupalListener extends \PHPUnit_Framework_BaseTestListener {
+  use DeprecationListenerTrait;
+  use DrupalComponentTestListenerTrait;
+  use DrupalStandardsListenerTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function endTest(\PHPUnit_Framework_Test $test, $time) {
+    $this->deprecationEndTest($test, $time);
+    $this->componentEndTest($test, $time);
+    $this->standardsEndTest($test, $time);
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php b/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php
new file mode 100644
index 0000000..7c1f45e
--- /dev/null
+++ b/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\Tests\Listeners\Legacy;
+
+use Drupal\Tests\Listeners\HtmlOutputPrinterTrait;
+
+/**
+ * Defines a class for providing html output results for functional tests.
+ *
+ * @internal
+ */
+class HtmlOutputPrinter extends \PHPUnit_TextUI_ResultPrinter {
+  use HtmlOutputPrinterTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct($out, $verbose, $colors, $debug, $numberOfColumns) {
+    parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns);
+
+    $this->setUpHtmlOutput();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function printResult(\PHPUnit_Framework_TestResult $result) {
+    parent::printResult($result);
+
+    $this->printHtmlOutput();
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Phpunit5FCTrait.php b/core/tests/Drupal/Tests/Phpunit5FCTrait.php
new file mode 100644
index 0000000..7ace0bf
--- /dev/null
+++ b/core/tests/Drupal/Tests/Phpunit5FCTrait.php
@@ -0,0 +1,169 @@
+<?php
+
+namespace Drupal\Tests;
+
+/**
+ * This trait makes tests forward compatible with PHPUnit 5 and above.
+ */
+trait Phpunit5FCTrait {
+
+  /**
+   * Returns a mock object for the specified class using the available method.
+   *
+   * The getMock method is deprecated in PHPUnit 5 but the createMock method is
+   * not available in PHPUnit 4. To provide backward compatibility this trait
+   * provides the getMock method and uses createMock if this method is
+   * available on the parent class.
+   *
+   * @param string $originalClassName
+   *   Name of the class to mock.
+   * @param array|null $methods
+   *   When provided, only methods whose names are in the array are replaced
+   *   with a configurable test double. The behavior of the other methods is not
+   *   changed. Providing null means that no methods will be replaced.
+   * @param array $arguments
+   *   Parameters to pass to the original class' constructor.
+   * @param string $mockClassName
+   *   Class name for the generated test double class.
+   * @param bool $callOriginalConstructor
+   *   Can be used to disable the call to the original class' constructor.
+   * @param bool $callOriginalClone
+   *   Can be used to disable the call to the original class' clone constructor.
+   * @param bool $callAutoload
+   *   Can be used to disable __autoload() during the generation of the test
+   *   double class.
+   * @param bool $cloneArguments
+   * @param bool $callOriginalMethods
+   * @param object $proxyTarget
+   *
+   * @see \PHPUnit_Framework_TestCase::getMock
+   * @see https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0
+   *
+   * @return \PHPUnit_Framework_MockObject_MockObject
+   *
+   * @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
+   *   Use \Drupal\Tests\Phpunit5FCTrait::createMock() instead.
+   *
+   * @see https://www.drupal.org/node/2907725
+   */
+  public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE, $callOriginalMethods = FALSE, $proxyTarget = NULL) {
+    return $this->createMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget);
+  }
+
+  /**
+   * Returns a mock object for the specified class using the available method.
+   *
+   * The getMock method is deprecated in PHPUnit 5 but the createMock method is
+   * not available in PHPUnit 4. To provide forward compatibility this trait
+   * provides the createMock method and uses createMock if this method is
+   * available on the parent class or falls back to getMock if it isn't.
+   *
+   * @param string $originalClassName
+   *   Name of the class to mock.
+   * @param array|null $methods
+   *   When provided, only methods whose names are in the array are replaced
+   *   with a configurable test double. The behavior of the other methods is not
+   *   changed. Providing null means that no methods will be replaced.
+   * @param array $arguments
+   *   Parameters to pass to the original class' constructor.
+   * @param string $mockClassName
+   *   Class name for the generated test double class.
+   * @param bool $callOriginalConstructor
+   *   Can be used to disable the call to the original class' constructor.
+   * @param bool $callOriginalClone
+   *   Can be used to disable the call to the original class' clone constructor.
+   * @param bool $callAutoload
+   *   Can be used to disable __autoload() during the generation of the test
+   *   double class.
+   * @param bool $cloneArguments
+   * @param bool $callOriginalMethods
+   * @param object $proxyTarget
+   *
+   * @see \PHPUnit_Framework_TestCase::getMock
+   *
+   * @return \PHPUnit_Framework_MockObject_MockObject
+   */
+  public function createMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE, $callOriginalMethods = FALSE, $proxyTarget = NULL) {
+    if ($this->isPhpunit5()) {
+      $mock = $this->getMockBuilder($originalClassName)
+        ->setMethods($methods)
+        ->setConstructorArgs($arguments)
+        ->setMockClassName($mockClassName)
+        ->setProxyTarget($proxyTarget);
+      if ($callOriginalConstructor) {
+        $mock->enableOriginalConstructor();
+      }
+      else {
+        $mock->disableOriginalConstructor();
+      }
+      if ($callOriginalClone) {
+        $mock->enableOriginalClone();
+      }
+      else {
+        $mock->disableOriginalClone();
+      }
+      if ($callAutoload) {
+        $mock->enableAutoload();
+      }
+      else {
+        $mock->disableAutoload();
+      }
+      if ($cloneArguments) {
+        $mock->enableArgumentCloning();
+      }
+      else {
+        $mock->disableArgumentCloning();
+      }
+      if ($callOriginalMethods) {
+        $mock->enableProxyingToOriginalMethods();
+      }
+      else {
+        $mock->disableProxyingToOriginalMethods();
+      }
+      return $mock->getMock();
+    }
+    return parent::getMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget);
+  }
+
+  /**
+   * Checks if the trait is used in a class extending the PHPUnit 5 TestCase.
+   *
+   * @return bool
+   */
+  private function isPhpunit5() {
+    // Get the parent class of the currently running test class.
+    $parent = get_parent_class($this);
+    // Ensure that the method_exists() check on PHPUnit 5's createMock method is
+    // carried out on the first parent of $this that does not have access to
+    // this trait's methods. This is because the trait also has a method called
+    // createMock(). Most often the check will be made on
+    // \PHPUnit\Framework\TestCase.
+    while (method_exists($parent, 'isPhpunit5')) {
+      $parent = get_parent_class($parent);
+    }
+    return method_exists($parent, 'createMock');
+  }
+
+  /**
+   * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
+   *
+   * @param mixed $class
+   * @param string $message
+   * @param int $exception_code
+   */
+  public function setExpectedException($class, $message = '', $exception_code = NULL) {
+    if (method_exists($this, 'expectException')) {
+      $this->expectException($class);
+      if (!empty($message)) {
+        $this->expectExceptionMessage($message);
+      }
+      if ($exception_code !== NULL) {
+        $this->expectExceptionCode($exception_code);
+      }
+    }
+    else {
+      parent::setExpectedException($class, $message, $exception_code);
+    }
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Phpunit5FCTraitTest.php b/core/tests/Drupal/Tests/Phpunit5FCTraitTest.php
new file mode 100644
index 0000000..7871d69
--- /dev/null
+++ b/core/tests/Drupal/Tests/Phpunit5FCTraitTest.php
@@ -0,0 +1,113 @@
+<?php
+
+namespace Drupal\Tests;
+
+/**
+ * Test the PHPUnit 5 forward compatibility trait.
+ *
+ * @coversDefaultClass \Drupal\Tests\Phpunit5FCTrait
+ * @group simpletest
+ * @group Tests
+ */
+class Phpunit5FCTraitTest extends UnitTestCase {
+
+  /**
+   * Test that getMock is available and calls the correct parent method.
+   *
+   * @covers ::getMock
+   * @dataProvider providerMockVersions
+   */
+  public function testGetMock($className, $expected) {
+    $class = new $className();
+    $this->assertSame($expected, $class->getMock($this->randomMachineName()));
+  }
+
+  /**
+   * Test that createMock is available and calls the correct parent method.
+   *
+   * @covers ::createMock
+   * @dataProvider providerMockVersions
+   */
+  public function testCreateMock($className, $expected) {
+    $class = new $className();
+    $this->assertSame($expected, $class->createMock($this->randomMachineName()));
+  }
+
+  /**
+   * Return the class names and the string they return.
+   *
+   * @return array
+   */
+  public function providerMockVersions() {
+    return [
+      [UnitTestCasePhpunit4TestClass::class, 'PHPUnit 4'],
+      [UnitTestCasePhpunit4TestClassExtends::class, 'PHPUnit 4'],
+      [UnitTestCasePhpunit5TestClass::class, 'PHPUnit 5'],
+      [UnitTestCasePhpunit5TestClassExtends::class, 'PHPUnit 5'],
+    ];
+  }
+
+}
+
+/**
+ * Test class for \PHPUnit\Framework\TestCase in PHPUnit 4.
+ */
+class Phpunit4TestClass {
+  public function getMock($originalClassName) {
+    return 'PHPUnit 4';
+  }
+
+}
+
+/**
+ * Test class for \PHPUnit\Framework\TestCase in PHPUnit 5.
+ */
+class Phpunit5TestClass {
+  public function createMock($originalClassName) {
+    throw new \Exception('This method should never be called');
+  }
+
+  public function getMockbuilder() {
+    return new Mockbuilder();
+  }
+
+}
+
+class Mockbuilder {
+  public function __call($name, $arguments) {
+    return $this;
+  }
+
+  public function getMock() {
+    return 'PHPUnit 5';
+  }
+
+}
+
+/**
+ * Test class for \Drupal\Tests\UnitTestCase with PHPUnit 4.
+ */
+class UnitTestCasePhpunit4TestClass extends Phpunit4TestClass {
+  use Phpunit5FCTrait;
+
+}
+
+/**
+ * Test class for \Drupal\Tests\UnitTestCase with PHPUnit 4.
+ */
+class UnitTestCasePhpunit4TestClassExtends extends UnitTestCasePhpunit4TestClass {
+}
+
+/**
+ * Test class for \Drupal\Tests\UnitTestCase with PHPUnit 5.
+ */
+class UnitTestCasePhpunit5TestClass extends Phpunit5TestClass {
+  use Phpunit5FCTrait;
+
+}
+
+/**
+ * Test class for \Drupal\Tests\UnitTestCase with PHPUnit 5.
+ */
+class UnitTestCasePhpunit5TestClassExtends extends UnitTestCasePhpunit5TestClass {
+}
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index 24ad680..b4ac0c3 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -17,6 +17,8 @@
  */
 abstract class UnitTestCase extends TestCase {
 
+  use Phpunit5FCTrait;
+
   /**
    * The random generator.
    *
@@ -135,7 +137,7 @@ public function getConfigFactoryStub(array $configs = []) {
     }
     // Construct a config factory with the array of configuration object stubs
     // as its return map.
-    $config_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
+    $config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
     $config_factory->expects($this->any())
       ->method('get')
       ->will($this->returnValueMap($config_get_map));
@@ -157,7 +159,7 @@ public function getConfigFactoryStub(array $configs = []) {
    *   A mocked config storage.
    */
   public function getConfigStorageStub(array $configs) {
-    $config_storage = $this->getMock('Drupal\Core\Config\NullStorage');
+    $config_storage = $this->createMock('Drupal\Core\Config\NullStorage');
     $config_storage->expects($this->any())
       ->method('listAll')
       ->will($this->returnValue(array_keys($configs)));
@@ -211,7 +213,7 @@ protected function getBlockMockWithMachineName($machine_name) {
    *   A mock translation object.
    */
   public function getStringTranslationStub() {
-    $translation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
+    $translation = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
     $translation->expects($this->any())
       ->method('translate')
       ->willReturnCallback(function ($string, array $args = [], array $options = []) use ($translation) {
@@ -241,7 +243,7 @@ public function getStringTranslationStub() {
    *   The container with the cache tags invalidator service.
    */
   protected function getContainerWithCacheTagsInvalidator(CacheTagsInvalidatorInterface $cache_tags_validator) {
-    $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+    $container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
     $container->expects($this->any())
       ->method('get')
       ->with('cache_tags.invalidator')
@@ -258,7 +260,7 @@ protected function getContainerWithCacheTagsInvalidator(CacheTagsInvalidatorInte
    *   The class resolver stub.
    */
   protected function getClassResolverStub() {
-    $class_resolver = $this->getMock('Drupal\Core\DependencyInjection\ClassResolverInterface');
+    $class_resolver = $this->createMock('Drupal\Core\DependencyInjection\ClassResolverInterface');
     $class_resolver->expects($this->any())
       ->method('getInstanceFromDefinition')
       ->will($this->returnCallback(function ($class) {
diff --git a/core/tests/TestSuites/TestSuiteBase.php b/core/tests/TestSuites/TestSuiteBase.php
index 82a13ba..3f4dc32 100644
--- a/core/tests/TestSuites/TestSuiteBase.php
+++ b/core/tests/TestSuites/TestSuiteBase.php
@@ -3,11 +3,12 @@
 namespace Drupal\Tests\TestSuites;
 
 use Drupal\simpletest\TestDiscovery;
+use PHPUnit\Framework\TestSuite;
 
 /**
  * Base class for Drupal test suites.
  */
-abstract class TestSuiteBase extends \PHPUnit_Framework_TestSuite {
+abstract class TestSuiteBase extends TestSuite {
 
   /**
    * Finds extensions in a Drupal installation.
@@ -40,7 +41,12 @@ protected function addTestsBySuiteNamespace($root, $suite_namespace) {
     // always inside of core/tests/Drupal/${suite_namespace}Tests. The exception
     // to this is Unit tests for historical reasons.
     if ($suite_namespace == 'Unit') {
-      $this->addTestFiles(TestDiscovery::scanDirectory("Drupal\\Tests\\", "$root/core/tests/Drupal/Tests"));
+      $tests = TestDiscovery::scanDirectory("Drupal\\Tests\\", "$root/core/tests/Drupal/Tests");
+      $tests = array_filter($tests, function ($test) use ($root) {
+        // The Listeners directory does not contain tests.
+        return !preg_match("@^$root/core/tests/Drupal/Tests/Listeners/@", dirname($test));
+      });
+      $this->addTestFiles($tests);
     }
     else {
       $this->addTestFiles(TestDiscovery::scanDirectory("Drupal\\${suite_namespace}Tests\\", "$root/core/tests/Drupal/${suite_namespace}Tests"));
diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php
index f78b69f..f2edbd2 100644
--- a/core/tests/bootstrap.php
+++ b/core/tests/bootstrap.php
@@ -166,3 +166,38 @@ function drupal_phpunit_populate_class_loader() {
 // make PHP 5 and 7 handle assertion failures the same way, but this call does
 // not turn runtime assertions on if they weren't on already.
 Handle::register();
+
+// @todo Decide if we need put in some code for WebTestBase too since there are
+//   tests using PHPUnit_Util_XML for example.
+// PHPUnit 4 to PHPUnit 6 bridge. Tests written for PHPUnit 4 need to work on
+// PHPUnit 6 with a minimum of fuss.
+if (!class_exists('\PHPUnit_Framework_AssertionFailedError') && class_exists('\PHPUnit\Framework\AssertionFailedError')) {
+  class_alias('\PHPUnit\Framework\AssertionFailedError', '\PHPUnit_Framework_AssertionFailedError');
+}
+if (!class_exists('\PHPUnit_Framework_Error_Warning') && class_exists('\PHPUnit\Framework\Error\Warning')) {
+  class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning');
+}
+if (!class_exists('\PHPUnit_Framework_Error') && class_exists('\PHPUnit\Framework\Error\Error')) {
+  class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error');
+}
+if (!class_exists('\PHPUnit_Util_Test') && class_exists('\PHPUnit\Util\Test')) {
+  class_alias('\PHPUnit\Util\Test', '\PHPUnit_Util_Test');
+}
+if (!class_exists('\PHPUnit_Util_XML') && class_exists('\PHPUnit\Util\XML')) {
+  class_alias('\PHPUnit\Util\XML', '\PHPUnit_Util_XML');
+}
+if (!class_exists('\PHPUnit_Framework_SkippedTestError') && class_exists('\PHPUnit\Framework\SkippedTestError')) {
+  class_alias('\PHPUnit\Framework\SkippedTestError', '\PHPUnit_Framework_SkippedTestError');
+}
+if (!class_exists('\PHPUnit_Framework_Exception') && class_exists('\PHPUnit\Framework\Exception')) {
+  class_alias('\PHPUnit\Framework\Exception', '\PHPUnit_Framework_Exception');
+}
+if (!class_exists('\PHPUnit_Framework_ExpectationFailedException') && class_exists('\PHPUnit\Framework\ExpectationFailedException')) {
+  class_alias('\PHPUnit\Framework\ExpectationFailedException', '\PHPUnit_Framework_ExpectationFailedException');
+}
+if (!class_exists('\PHPUnit_Framework_Constraint_Count') && class_exists('\PHPUnit\Framework\Constraint\Count')) {
+  class_alias('\PHPUnit\Framework\Constraint\Count', '\PHPUnit_Framework_Constraint_Count');
+}
+if (!class_exists('\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder') && class_exists('\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder')) {
+  class_alias('\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder', '\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder');
+}
