diff -u b/composer.lock b/composer.lock --- b/composer.lock +++ b/composer.lock @@ -4198,12 +4198,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/phpunit-bridge.git", - "reference": "884e6aac4e6a07d427187a35194821cbc2a0c82c" + "reference": "923c15c5a7dacb7f4289da9efb8013a1a246c562" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/884e6aac4e6a07d427187a35194821cbc2a0c82c", - "reference": "884e6aac4e6a07d427187a35194821cbc2a0c82c", + "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/923c15c5a7dacb7f4289da9efb8013a1a246c562", + "reference": "923c15c5a7dacb7f4289da9efb8013a1a246c562", "shasum": "" }, "require": { @@ -4252,7 +4252,7 @@ ], "description": "Symfony PHPUnit Bridge", "homepage": "https://symfony.com", - "time": "2017-10-13T14:15:21+00:00" + "time": "2017-10-25T09:57:11+00:00" } ], "aliases": [], diff -u b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php --- b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php +++ b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Test\HttpClientMiddleware; +use Drupal\Core\Test\TestSetupTrait; use Drupal\Core\Utility\Error; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -11,12 +12,6 @@ */ class TestHttpClientMiddleware { - protected $skippedDeprecations = [ - '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.', - ]; - /** * {@inheritdoc} * @@ -49,7 +44,7 @@ if (count($parameters) === 3) { if ($parameters[1] === 'User deprecated function') { $message = (string) $parameters[0]; - if (!in_array($message, $this->skippedDeprecations)) { + if (!in_array($message, TestSetupTrait::_getSkippedDeprecations())) { // Fire the same deprecation message to allow it to be // caught. @trigger_error($message, E_USER_DEPRECATED); diff -u b/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php --- b/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -14,6 +14,7 @@ use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Test\AssertMailTrait; use Drupal\Core\Test\FunctionalTestSetupTrait; +use Drupal\Core\Test\TestSetupTrait; use Drupal\Core\Url; use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait; use Drupal\Tests\EntityViewTrait; @@ -693,7 +694,13 @@ $parameters = unserialize(urldecode($matches[1])); // Swallow deprecation notices. WebTestBase will not be updated to handle // them. - if ($parameters[1] !== 'User deprecated function') { + if ($parameters[1] === 'User deprecated function') { + $message = (string) $parameters[0]; + if (!in_array($message, TestSetupTrait::_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); only in patch2: unchanged: --- a/core/lib/Drupal/Core/Test/TestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/TestSetupTrait.php @@ -199,4 +199,22 @@ protected function getConfigSchemaExclusions() { return array_unique($exceptions); } + /** + * 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.', + '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.', + ]; + } + } only in patch2: unchanged: --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -45,7 +45,7 @@ - + only in patch2: unchanged: --- /dev/null +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListener.php @@ -0,0 +1,87 @@ +trait = new SymfonyTestsListenerTrait($mockedNamespaces); + } + + /** + * {@inheritdoc} + */ + public function globalListenerDisabled() { + $this->trait->globalListenerDisabled(); + } + + /** + * {@inheritdoc} + */ + public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) { + return $this->trait->startTestSuite($suite); + } + + /** + * {@inheritdoc} + */ + public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) { + return $this->trait->addSkippedTest($test, $e, $time); + } + + /** + * {@inheritdoc} + */ + public function startTest(\PHPUnit_Framework_Test $test) { + return $this->trait->startTest($test); + } + + /** + * {@inheritdoc} + */ + public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) { + return $this->trait->addWarning($test, $e, $time); + } + + /** + * {@inheritdoc} + */ + public function endTest(\PHPUnit_Framework_Test $test, $time) { + // It might seem simpler to override + // Need to edit the file of deprecations. + $r = new \ReflectionProperty($this->trait, 'runsInSeparateProcess'); + $r->setAccessible(TRUE); + + $file = $r->getValue($this->trait); + if ($file) { + $deprecations = file_get_contents($file); + $deprecations = $deprecations ? unserialize($deprecations) : []; + $resave = FALSE; + foreach ($deprecations as $key => $deprecation) { + if (in_array($deprecation[1], TestSetupTrait::_getSkippedDeprecations())) { + unset($deprecations[$key]); + $resave = TRUE; + } + } + if ($resave) { + file_put_contents($file, serialize($deprecations)); + } + } + return $this->trait->endTest($test, $time); + } + +}