Problem/Motivation

Drupal\Tests\taxonomy\Functional\EfqTest doesn't make any HTTP request.

Proposed resolution

  • Convert it to a kernel test.
  • Move TaxonomyTestTrait from tests/src/Functional to tests/src/Traits as is used by all kind of tests.
  • Rename it to a more meaningful name.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Status: Active » Needs review
Issue tags: +Testing system, +Test suite performance, +Performance, +functional2kernel
FileSize
11.38 KB

Patch.

jibran’s picture

+++ b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php
similarity index 69%
rename from core/modules/taxonomy/tests/src/Functional/TaxonomyTestTrait.php

rename from core/modules/taxonomy/tests/src/Functional/TaxonomyTestTrait.php
rename to core/modules/taxonomy/tests/src/Traits/TaxonomyTestTrait.php

I'm pretty sure we can't do that without a BC layer.

claudiu.cristea’s picture

claudiu.cristea’s picture

FileSize
1 KB
14 KB

@jibran, you're right. Here's the BC layer.

claudiu.cristea’s picture

FileSize
830 bytes
13.99 KB

Fixed coding standards.

Lendude’s picture

Status: Needs review » Needs work

Just some notes, nothing blocking I think.

  1. +++ b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php
    index eb9e5e983b..7a980bd148 100644
    --- a/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
    
    --- a/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
    +++ b/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
    
    +++ b/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
    @@ -6,7 +6,7 @@
    -use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait;
    +use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
    

    Not strictly necessary since it's updating a class that is deprecated itself.

  2. +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTestTrait.php
    @@ -2,58 +2,20 @@
    +@trigger_error('The ' . __NAMESPACE__ . '\TaxonomyTestTrait is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait. See https://www.drupal.org/node/3041703.', E_USER_DEPRECATED);
    

    See #3024461: Adopt consistent deprecation format for core and contrib deprecation messages for the new way of writing these, since this has not been officially approved, not setting it back now (but might have to update this is that lands first)

Went through the conversion and everything checks out.

The only part I'm missing that is mentioned in the IS is: "Rename it to a more meaningful name", which I think is worth doing.

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -tests convert, -Testing system, -Performance, -functional2kernel
FileSize
1.91 KB
13.44 KB

#71, 2: Fixed.

The only part I'm missing that is mentioned in the IS is: "Rename it to a more meaningful name", which I think is worth doing.

The test class has been renamed from EfqTest to TaxonomyTermEfqTest:

+++ b/core/modules/taxonomy/tests/src/Kernel/TaxonomyTermEfqTest.php
@@ -1,47 +1,53 @@
-class EfqTest extends TaxonomyTestBase {
+class TaxonomyTermEfqTest extends KernelTestBase {
Lendude’s picture

The test class has been renamed from EfqTest to TaxonomyTermEfqTest

Ah ok, I was looking for hopefully getting rid of 'Efq', why not just say TaxonomyTermEntityFieldQueryTest. No need to wrack my brain thinking what 'Efq' would stand for.

claudiu.cristea’s picture

FileSize
697 bytes
13.47 KB

Got it. In fact the "entity field query" is an antiquity from D7. It's simply "entity query" now.

Krzysztof Domański’s picture

Can we also change the name of the method testTaxonomyEfq() to testTaxonomyEntityQuery()?

core/modules/taxonomy/tests/src/Kernel/TaxonomyTermEntityQueryTest.php:31:

/**
 * Tests that a basic taxonomy entity query works.
 */
 public function testTaxonomyEfq() {
Berdir’s picture

I'd suggest testTermEntityQuery then, possibly for the class name also leave out the Taxonomy.

Krzysztof Domański’s picture

1. I changed trigger_error() message. Drupal core deprecation policy.

The PHPdoc text and the trigger_error() message should follow the same format

According to #12:

2. I changed the class name from TaxonomyTermEntityQueryTest to TermEntityQueryTest.

3. I changed the name of the method testTaxonomyEfq() to testTermEntityQuery()

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for all the feedback, this reads much better now.

Nice conversion, no loss of coverage that I can see.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 3041030-13.patch, failed testing. View results

Lendude’s picture

Title: Convert functional EfqTest to kernel test » Convert functional EfqTest to a kernel test and move TaxonomyTestTrait from tests/src/Functional to tests/src/Traits
Krzysztof Domański’s picture

Status: Needs work » Needs review
FileSize
648 bytes
13.65 KB
claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

The patch has been RTBCed in #14. I'm doing it only for the change from #17.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6874218 and pushed to 8.8.x. Thanks!

  • catch committed 6874218 on 8.8.x
    Issue #3041030 by claudiu.cristea, Krzysztof Domański, Lendude, Berdir,...

Status: Fixed » Closed (fixed)

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

dww’s picture

FYI: The change record for this was never published. I just did so.

I also figured out how to get my contrib tests that were trying to use this trait to work on 8.7.x and 8.8.x and above, so I added that wisdom to the CR:

https://www.drupal.org/node/3041703/revisions/view/11349728/11635421

Enjoy,
-Derek