This patch refactors \Drupal\Tests\rest\Functional\EntityResource\Block\BlockResourceTestBase::getExpectedCacheTags to use array_diff instead of array_filter callback. See related: https://www.drupal.org/node/2843772#comment-12012346.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arshadcn created an issue. See original summary.

shadcn’s picture

Assigned: shadcn » Unassigned
Status: Active » Needs review
FileSize
1.99 KB
Wim Leers’s picture

Priority: Normal » Minor
Status: Needs review » Needs work

I'm concerned about the scope of changes here. Let's focus on only the one truly relevant change.

  1. +++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
    @@ -5,6 +5,9 @@
    +/**
    + * ResourceTestBase for Block entity.
    + */
    

    This is just such a pointless docblock. We don't have it on any of the other base test classes. Let's not add it here either.

  2. +++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
    @@ -18,6 +21,8 @@
    +   * The Block entity.
    

    Same for this. Needless verbosity.

  3. +++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
    @@ -30,9 +35,11 @@ protected function setUpAuthorization($method) {
    +
    ...
    +
    
    @@ -138,6 +143,7 @@ protected function getExpectedUnauthorizedAccessMessage($method) {
    +
    

    And these are just whitespace changes. The same absence of whitespace exists in the other base classes.

  4. +++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
    @@ -122,9 +129,7 @@ protected function getExpectedCacheContexts() {
    -    return array_values(array_filter(parent::getExpectedCacheTags(), function ($tag) {
    -      return $tag !== 'config:user.role.anonymous';
    -    }));
    +    return array_values(array_diff(parent::getExpectedCacheTags(), ['config:user.role.anonymous']));
    

    This is a solid change however! :)

shadcn’s picture

Status: Needs work » Needs review
FileSize
928 bytes
1.33 KB

Thanks for the review Wim.

1,2 and 3 were fixes from the phpcs codesniffer. I reverted them.
4 is in. New patch attached.

shadcn’s picture

Title: Refactor and fix code standards for \Drupal\Tests\rest\Functional\EntityResource\Block\BlockResourceTestBase » Refactor \Drupal\Tests\rest\Functional\EntityResource\Block\BlockResourceTestBase::getExpectedCacheTags
Issue summary: View changes
Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Trivial patch of the month, +clean-up

Thanks :)

rakesh.gectcr’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
934 bytes

According to above comment, Only added the refactor patch. :)

rakesh.gectcr’s picture

Oops Sorry. It was a coincidence. Apologise.

Status: Needs review » Needs work

The last submitted patch, 7: 2866252-5.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

The last submitted patch, 4: refactor_and_fix_code-2866252-4.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2866252-5.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

Retested both #4 and #7. They're both failing, because Drupal CI is crashing, hard.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2866252-5.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

  • catch committed c0933a1 on 8.4.x
    Issue #2866252 by arshadcn, rakesh.gectcr: Refactor \Drupal\Tests\rest\...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x, thanks!

Status: Fixed » Closed (fixed)

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