diff --git a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
index c3e447d1fc..61c767deda 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/tests/Drupal/Tests/Phpunit5FCTrait.php b/core/tests/Drupal/Tests/Phpunit5FCTrait.php
new file mode 100644
index 0000000000..4a571e1117
--- /dev/null
+++ b/core/tests/Drupal/Tests/Phpunit5FCTrait.php
@@ -0,0 +1,93 @@
+<?php
+
+namespace Drupal\Tests;
+
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject;
+
+/**
+ * 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
+   *
+   * @return PHPUnit_Framework_MockObject_MockObject
+   */
+  public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false, $proxyTarget = null) {
+    if (method_exists('PHPUnit\Framework\TestCase', 'createMock')) {
+      return TestCase::createMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget);
+    }
+    return parent::getMock($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 (method_exists('PHPUnit\Framework\TestCase', 'createMock')) {
+      return TestCase::createMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget);
+    }
+    return parent::getMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget);
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index 8aaeb85743..972b544dee 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -18,6 +18,8 @@
  */
 abstract class UnitTestCase extends TestCase {
 
+  use Phpunit5FCTrait;
+
   /**
    * The random generator.
    *
