Some of the code in core does not follow the phpunit standards described here
The Task is to change the @covers documentation to fix this. The @covers documentation is used by phpunit test coverage to see how much the test function covers the tested function.

d8/core$ grep -nriI "\* @covers " --exclude-dir=vendor | grep -v " ::*"
modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php:35:   * @covers \Drupal\Core\Field\BaseFieldDefinition::getColumns
modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php:36:   * @covers \Drupal\path\Plugin\Field\FieldType\PathItem::schema
modules/migrate/tests/src/Unit/RowTest.php:182:   * @covers \Drupal\migrate\Row::setIdMap
modules/migrate/tests/src/Unit/RowTest.php:183:   * @covers \Drupal\migrate\Row::getIdMap
modules/migrate/tests/src/Unit/RowTest.php:207:   * @covers \Drupal\migrate\Row::getSourceProperty
tests/Drupal/Tests/Core/Mail/MailManagerTest.php:107:   * @covers \Drupal\Core\Mail\MailManager::getInstance
tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php:46:   * @covers \Drupal\Core\Render\MainContent\AjaxRenderer::renderResponse
tests/Drupal/Tests/Core/Routing/RouteMatchTest.php:33:   * @covers \Drupal\Core\Routing\NullRouteMatch
tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php:103:   * @covers \Drupal\Core\Routing\AccessAwareRouter::__call
tests/Drupal/Tests/Core/Routing/RouteMatchBaseTest.php:105:   * @covers \Drupal\Core\Routing\RouteMatch::getParameterNames
tests/Drupal/Tests/Core/Routing/RouteMatchBaseTest.php:119:   * @covers \Drupal\Core\Routing\RouteMatch::getParameterNames
tests/Drupal/Tests/Core/Routing/RouteMatchBaseTest.php:128:   * @covers \Drupal\Core\Routing\RouteMatch::getParameterNames
tests/Drupal/Tests/Core/Routing/RouteMatchBaseTest.php:142:   * @covers \Drupal\Core\Routing\RouteMatch::getParameterNames
tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php:125:   * @covers \Drupal\Core\Menu\LocalActionManager::getTitle
tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php:142:   * @covers \Drupal\Core\Menu\LocalActionManager::getActionsForRoute
tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php:122:   * @covers \Drupal\Core\Menu\ContextualLinkDefault::getRouteName
tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php:134:   * @covers \Drupal\Core\Menu\ContextualLinkDefault::getGroup
tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php:146:   * @covers \Drupal\Core\Menu\ContextualLinkDefault::getOptions
tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php:158:   * @covers \Drupal\Core\Menu\ContextualLinkDefault::getWeight
tests/Drupal/Tests/Core/Annotation/TranslationTest.php:34:   * @covers \Drupal\Core\Annotation\Translation::get
tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php:89:   * @covers \Drupal\Core\Entity\EntityListBuilder::getOperations
tests/Drupal/Tests/Core/Access/AccessManagerTest.php:501:   * @covers \Drupal\Core\Access\AccessManager::checkNamedRoute

In short change @covers \Drupal\Core\Field\BaseFieldDefinition::getColumns to @covers ::getColumns

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cogax’s picture

Assigned: Unassigned » Cogax
Cogax’s picture

Assigned: Cogax » Unassigned
Status: Active » Needs review
FileSize
9.41 KB

I've updated some @covers docs.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Good work @Cogax!

It all looks good to me.
All the @covers are now in order with one exception. That is in "tests/Drupal/Tests/Core/Routing/RouteMatchTest.php" on line 33: "* @covers \Drupal\Core\Routing\NullRouteMatch" which is pointing to another class. Lets fix that in a followup that also removes some dependencies and adds some mocks to the test class.
It gets a RTBC from me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: updated-@covers-documentations-2409587-2.patch, failed testing.

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

Mile23’s picture

Just want to bring folks' attention to this: #2415441: Automate finding @covers errors

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 22a1fd6 and pushed to 8.0.x. Thanks!

  • alexpott committed 22a1fd6 on 8.0.x
    Issue #2409587 by Cogax: Incorrect documentation for @covers
    

Status: Fixed » Closed (fixed)

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