Problem/Motivation

If I run PHPUnit tests on the command line with the argument --coverage-text and XDebug installed (to generate the coverage report), I get the following error (and more like it, until all instances are fixed:

Trying to @cover or @use not existing class or interface "validateTags".

After the error, PHPUnit dies and the rest of the tests aren't run.

Proposed resolution

Fix all the errant @covers occurrences in D8 core tests.

Remaining tasks

Review patch in #1.

User interface changes

None.

API changes

None.

Comments

geerlingguy’s picture

Status: Active » Needs work
StatusFileSize
new3.97 KB

Attached patch is incomplete; still working my way through all the incorrect @covers around test files...

geerlingguy’s picture

Status: Needs work » Needs review
StatusFileSize
new7.78 KB

Attached patch gets tests working all the way through (with current HEAD).

P.S. current test coverage (PHPUnit only):

  Classes:  6.83% (254/3721)    
  Methods: 12.47% (2118/16982)  
  Lines:    8.38% (17996/214732)
dawehner’s picture

+++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
--- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php

+++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
@@ -99,8 +99,6 @@ public function testMatchRequestDenied() {
 
   /**
    * Ensure that methods are passed to the wrapped router.
-   *
-   * @covers ::__call
    */

This change is confusing, giving that we actually test the __call method, don't we?

geerlingguy’s picture

@dawehner - it looks like for magic methods, the preferred method is to write @covers ClassName::__call; see https://github.com/sebastianbergmann/phpunit/issues/1005#issuecomment-24....

I'll update the patch.

geerlingguy’s picture

Hmm... using the incantation @covers AccessAwareRouter::__call still results in a fatal. Is there something I'm missing?

geerlingguy’s picture

StatusFileSize
new7.84 KB
new625 bytes

Apparently I had to use the fully qualified name before PHPUnit was happy... see updated patch.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Great that you solved it!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

#2358657: Wrong @covers definitions in Drupal project and this are dupes and here is almost the same review.

  1. +++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageMappingConfigEntityUnitTest.php
    @@ -80,7 +80,6 @@ public function testCalculateDependencies() {
    -   * @covers ::hasMapping
    

    How about just adding a "s"?

  2. +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php
    @@ -134,9 +134,7 @@ public function testQueue() {
    -   * Tests the testRequestStack() method.
    -   *
    -   * @covers ::requestStack
    +   * Tests the requestStack() method.
    

    Need to add the default class to the test class annotation.

  3. +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
    @@ -81,12 +81,10 @@ protected function setUp() {
    -   * @covers ::getSchema()
    ...
    -   * @covers ::addFieldSchema()
    
    @@ -389,7 +387,6 @@ public function testGetSchemaBase() {
    -   * @covers ::getSchema()
    
    @@ -489,7 +486,6 @@ public function testGetSchemaRevisionable() {
    -   * @covers ::getSchema()
    
    @@ -579,7 +575,6 @@ public function testGetSchemaTranslatable() {
    -   * @covers ::getSchema()
    

    Are there replacements?

alexpott’s picture

Status: Needs work » Closed (duplicate)

I'm going to mark this one a dupe of #2358657: Wrong @covers definitions in Drupal project since that was at rtbc earlier and has an smaller nid. I'll add a note to the other issue to include changes from this issue that are not there are to credit @geerlingguy.