Expanding unit test coverage, as per #2052109: [meta] Expand phpunit tests for \Drupal\Component\Plugin classes

Here we cover Drupal\Component\Plugin\Discovery\DiscoveryTrait and Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait.

I wanted to learn to test a trait.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Unfrozen changes Unfrozen because it only improves automated testing.
CommentFileSizeAuthor
#4 2370183_4.patch8.68 KBmile23
#4 interdiff.txt2.4 KBmile23
#1 2370183_1.patch8.22 KBmile23

Comments

mile23’s picture

Status: Active » Needs review
StatusFileSize
new8.22 KB

Covering the whole thing.

mile23’s picture

Issue summary: View changes
duaelfr’s picture

92/92 tests PASS
Coverage :

  • Drupal\Component\Plugin\Discovery\DiscoveryTrait 100%
  • Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait 100%

There are a few comments to make it perfect :

  1. +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php
    @@ -0,0 +1,90 @@
    +use Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait;
    

    Unused.

  2. +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
    @@ -0,0 +1,139 @@
    +use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
    +use Drupal\Component\Plugin\Exception\PluginNotFoundException;
    

    Unused.

  3. +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
    @@ -0,0 +1,139 @@
    +  public function providerDoGetDefinition() {
    

    Needs a doc block.

  4. +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
    @@ -0,0 +1,139 @@
    +  public function providerDoGetDefinitionException() {
    

    Needs a doc block.

  5. +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
    @@ -0,0 +1,139 @@
    +  public function providerHasDefinition() {
    

    Needs a doc block.

mile23’s picture

StatusFileSize
new2.4 KB
new8.68 KB

Incorporating all the changes from #3...

duaelfr’s picture

Perfect, thank you :)
That's RTBC for me.

mile23’s picture

Issue summary: View changes

@DuaelFr could you change the status if you want to RTBC? Thanks. :-)

Added beta status.

duaelfr’s picture

Status: Needs review » Reviewed & tested by the community

I thought we needed more than one reviewer.
Let's RTBC it :)

yesct’s picture

We just need one reviewer.

But sometimes we get more than one reviewer.
You will see sometimes a person who has worked on a patch earlier, or a small part of a bigger patch, they will review it, and comment: rtbc from me. They may not set the status to rtbc because, strictly speaking, the person to set it to do the final review and set it to rtbc is supposed to be someone who did not work on the patch.

alansaviolobo queued 4: 2370183_4.patch for re-testing.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Not really the most qualified to give these sign-off, but they've been sitting here long enough for someone to raise objections, and moar test coverage is never a bad thing.

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 84e2b6d on 8.0.x
    Issue #2370183 by Mile23, DuaelFr: Expand unit testing for Drupal\...

Status: Fixed » Closed (fixed)

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