Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / simpletest / src / WebTestBase.php
index fd0222fabccb65d5762ea32d6931f2ce7de9a195..441b2398f4b967a3b78c2c0b6c213fb417e9fd2c 100644 (file)
@@ -18,6 +18,7 @@ use Drupal\Core\Url;
 use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
 use Drupal\Tests\EntityViewTrait;
 use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
+use Drupal\Tests\Listeners\DeprecationListenerTrait;
 use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
 use Drupal\Tests\node\Traits\NodeCreationTrait;
 use Drupal\Tests\Traits\Core\CronRunTrait;
@@ -692,9 +693,21 @@ abstract class WebTestBase extends TestBase {
     // generated by _drupal_log_error() in the exact form required
     // by \Drupal\simpletest\WebTestBase::error().
     if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) {
-      // Call \Drupal\simpletest\WebTestBase::error() with the parameters from
-      // the header.
-      call_user_func_array([&$this, 'error'], unserialize(urldecode($matches[1])));
+      $parameters = unserialize(urldecode($matches[1]));
+      // Handle deprecation notices triggered by system under test.
+      if ($parameters[1] === 'User deprecated function') {
+        if (getenv('SYMFONY_DEPRECATIONS_HELPER') !== 'disabled') {
+          $message = (string) $parameters[0];
+          if (!in_array($message, DeprecationListenerTrait::getSkippedDeprecations())) {
+            call_user_func_array([&$this, 'error'], $parameters);
+          }
+        }
+      }
+      else {
+        // Call \Drupal\simpletest\WebTestBase::error() with the parameters from
+        // the header.
+        call_user_func_array([&$this, 'error'], $parameters);
+      }
     }
 
     // Save cookies.
@@ -819,7 +832,7 @@ abstract class WebTestBase extends TestBase {
    *   The result of the request.
    */
   protected function drupalGetWithFormat($path, $format, array $options = [], array $headers = []) {
-    $options += ['query' => ['_format' => $format]];
+    $options = array_merge_recursive(['query' => ['_format' => $format]], $options);
     return $this->drupalGet($path, $options, $headers);
   }