Problem/Motivation

I'm testing PhpStorm IDE to see how code coverage test works and found some out-of-date @covers statements in:

  • core/tests/Drupal/Tests/Core/Cache/CacheTest.php
  • core/tests/Drupal/Tests/Core/DrupalTest.php
  • core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
  • core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
  • core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
  • core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php

Proposed resolution

Update the @covers statement to relate to the correct method under test.

Remaining tasks

User interface changes

API changes

Suggested commit message: Issue #2358657 by zaporylie, geerlingguy: Fixed Wrong @covers definitions in Drupal project.

Comments

zaporylie’s picture

StatusFileSize
new6.1 KB

That's initial patch to solve it.

dawehner’s picture

Status: Active » Reviewed & tested by the community

@zaporylie
Can you find those instances automatically?

zaporylie’s picture

By running PHPUnit test with Coverage option.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php
    @@ -136,7 +136,7 @@ public function testQueue() {
    -   * @covers ::requestStack
    +   * @covers \Drupal::requestStack
    

    It'd be better to add the @coversDefaultClass \Drupal here.

  2. +++ 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()
    

    What have these become? Just we be added stuff from #2330121: Replace ContentEntityDatabaseStorage::getSchema() with a new EntityTypeListenerInterface implemented by SqlContentEntityStorageSchema

  3. +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
    @@ -213,7 +213,6 @@ public function testCacheClearWithTags() {
    -   * @covers ::enforcePluginInterface
    
    @@ -227,7 +226,6 @@ public function testCreateInstanceWithJustValidInterfaces() {
    -   * @covers ::enforcePluginInterface
    
    @@ -258,7 +256,6 @@ public function testCreateInstanceWithInvalidInterfaces() {
    -   * @covers ::enforcePluginInterface
    

    This method never seems to have existed - related #2359005: LocalTaskManagerTest only works because we mock a non existing method

  4. +++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
    @@ -99,8 +99,6 @@ public function testMatchRequestDenied() {
    -   * @covers ::__call
    

    This should be Drupal\Core\Routing\AccessAwareRouter::__call

zaporylie’s picture

I fixed points 1 and 4 from #4. 2 and 3 still needs to be fixed.

alexpott’s picture

Point 3 from #4 does not need fixing - what you've done is correct - I was just pointing out why what you've done is correct and that there is no replacement.

alexpott’s picture

Issue summary: View changes

This is a dupe of #2359007: PHPUnit CLI test runs fail when used with --coverage-text or vica versa. This one was rtbc first and has a smaller nid so I'm going to leave this open.

Suggested commit message: Issue #2358657 by zaporylie, geerlingguy: Fixed Wrong @covers definitions in Drupal project.

I think there might be 1 or 2 changes on that issue that are not in this issue.

geerlingguy’s picture

Ah, didn't notice this issue (thanks to @alexpott for pointing me here); I was trying to get coverage reporting through Travis CI when I ran into this. See, as an example, https://travis-ci.org/geerlingguy/drupal-travis-ci/builds/38821121 (that's with head as of today).

The patch over in #2359007: PHPUnit CLI test runs fail when used with --coverage-text seems to have cleared up all the errors I was getting, but I'll run this patch as well and see if it solves all the issues.

Also, to reproduce locally:

  1. Install XDebug + PHPUnit.
  2. In CLI, within d8 core directory, run $ ./vendor/phpunit/phpunit/phpunit --coverage-text
geerlingguy’s picture

Status: Needs work » Needs review

Let's at least let the testbot have a go. I'm running tests locally to confirm.

geerlingguy’s picture

StatusFileSize
new7.76 KB
new1.7 KB

Updated patch; was missing a few corrections.

geerlingguy’s picture

@alexpott had mentioned in IRC:

geerlingguy: so the changes to SqlContentEntityStorageSchemaTest - we still need to confirm that there are no replacement methods that should be covered

From my quick look-through, it seems there isn't any replacement that needs to be covered. I'm guessing the getSchema() function was either removed, or never existed, inside SqlContentEntityStorageSchema... but I didn't spend more than a few minutes trying to figure this out.

zaporylie’s picture

mile23’s picture

mile23’s picture

Status: Needs review » Reviewed & tested by the community

As of Nov 9, the patch in #10 applies.

RTBC because it makes the coverage report work.

Marking my issue as postponed because I found other stuff that isn't here. I'll re-roll after this has dropped. #2364555: Add @covers annotation, fix some --strict for PHPUnit

FYI: At the command line you can type:

cd core
./vendor/bin/phpunit --coverage-text

Or if you want a full HTML report:

./vendor/bin/phpunit --coverage-html /path/to/report/html

No need to do the phpunit/phpunit/phpunit/phpunit/phpunit thing. :-)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 433b435 and pushed to 8.0.x. Thanks!

  • alexpott committed 433b435 on 8.0.x
    Issue #2358657 by zaporylie, geerlingguy: Fixed Wrong @covers...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.