X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FListeners%2FDrupalStandardsListener.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FListeners%2FDrupalStandardsListener.php;h=fd15f8218bc1763e3035df9bcfa860ebcd06a194;hp=7f8396fe07f312ee742086b788aae9eac6c6ae35;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php b/web/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php index 7f8396fe0..fd15f8218 100644 --- a/web/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php +++ b/web/core/tests/Drupal/Tests/Listeners/DrupalStandardsListener.php @@ -2,23 +2,26 @@ 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 \PHPUnit_Framework_BaseTestListener { +class DrupalStandardsListener extends BaseTestListener { /** * Signals a coding standards failure to the user. * - * @param \PHPUnit_Framework_TestCase $test + * @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(\PHPUnit_Framework_TestCase $test, $message) { + 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); @@ -44,10 +47,10 @@ class DrupalStandardsListener extends \PHPUnit_Framework_BaseTestListener { * * This method is called from $this::endTest(). * - * @param \PHPUnit_Framework_TestCase $test + * @param \PHPUnit\Framework\TestCase $test * The test to examine. */ - public function checkValidCoversForTest(\PHPUnit_Framework_TestCase $test) { + 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; @@ -139,12 +142,22 @@ class DrupalStandardsListener extends \PHPUnit_Framework_BaseTestListener { /** * {@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 \PHPUnit_Framework_TestCase) { + if ($test instanceof TestCase) { $this->checkValidCoversForTest($test); } elseif ($test instanceof \PHPUnit_Framework_TestSuite) {