diff core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php	Mon Apr 23 09:46:53 2018 +0100
@@ -96,9 +96,9 @@
    * 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');
+    $a1 = $this->getMockBuilder('\Drupal\Tests\Component\Utility\Test1Interface')->getMock();
+    $a2 = $this->getMockBuilder('\Drupal\Tests\Component\Utility\TestClass')->getMock();
+    $a3 = $this->getMockBuilder('\Drupal\Tests\Component\Utility\Test2Interface')->getMock();
 
     $objects = [
       't1' => $a1,
@@ -123,12 +123,18 @@
    * Without the typehint, the wildcard object will not be passed to the callable.
    */
   public function testGetWildcardArgumentNoTypehint() {
-    $a = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+    $a = $this->getMockBuilder('\Drupal\Tests\Component\Utility\Test1Interface')->getMock();
     $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 +162,13 @@
     $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 +179,13 @@
    */
   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);
   }