Problem/Motivation

ApcuBackendTest has both @requires and odd \Drupal\KernelTests\Core\Cache\ApcuBackendTest::getRequirements / \Drupal\KernelTests\Core\Cache\ApcuBackendTest::requirementsFail code.

I think now we have @requires extension apcu we can remove the requirements code because it'll never fail.

Proposed resolution

  1. Remove \Drupal\KernelTests\Core\Cache\ApcuBackendTest::getRequirements() and \Drupal\KernelTests\Core\Cache\ApcuBackendTest::requirementsFail()
  2. Remove all calls to those methods and remove overrides of tests where possible - for example testDelete no longer needs an override.

Remaining tasks

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

alexpott created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Active » Needs review
FileSize
4.03 KB
  1. Removed \Drupal\KernelTests\Core\Cache\ApcuBackendTest::getRequirements() and \Drupal\KernelTests\Core\Cache\ApcuBackendTest::requirementsFail()
  2. Removed all calls to those methods and removed overrides of tests where possible - for example testDelete no longer needs an override.
alexpott’s picture

Status: Needs review » Needs work

Thanks for working on this @yogeshmpawar.

+++ b/core/tests/Drupal/KernelTests/Core/Cache/ApcuBackendTest.php
@@ -198,9 +126,6 @@ public function testInvalidateAll() {
   public function testRemoveBin() {
-    if ($this->requirementsFail()) {
-      return;
-    }
     parent::testRemoveBin();
   }

Where we are just calling the parent and doing nothing else we can remove the entire method.

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
3.65 KB
1.49 KB

Thanks @alexpott, Updated the patch as per comment #5 & also added an interdiff.

alexpott’s picture

1 files changed, 0 insertions, 145 deletions. love it!

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

This looks great and it passes tests. I don't see anything else that we can improve on this.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Was so about to commit this and then realised there's one more thing.

    if (class_exists('\APCUIterator')) {
      $iterator = new \APCUIterator('/^' . $key . '/');
    }
    else {
      $iterator = new \APCIterator('user', '/^' . $key . '/');
    }

This test does

 * @requires extension apcu

So this check is moot and can be:

$iterator = new \APCUIterator('/^' . $key . '/');

No need to think about apc (without the u) and no need to check if classes exist.

alexpott’s picture

Also we should open a follow-up to remove Apcu4Backend from the codebase - I'm pretty sure the apcu4 is a PHP5 only thing and therefore no longer supported by Drupal.

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
4.09 KB
811 bytes

Removing check as per comment #9 & adding interdiff as well.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed ef6a11d84a to 8.8.x and e91c5eca76 to 8.7.x. Thanks!

Backported to 8.7.x to keep the tests aligned.

  • alexpott committed ef6a11d on 8.8.x
    Issue #3054315 by yogeshmpawar, alexpott: Sort out ApcuBackendTest
    

  • alexpott committed e91c5ec on 8.7.x
    Issue #3054315 by yogeshmpawar, alexpott: Sort out ApcuBackendTest
    
    (...
alexpott’s picture

This change broke PHP5 on 8.7.x - reverting. There's no need to backport the change.

  • alexpott committed 87f9f00 on 8.7.x
    Revert "Issue #3054315 by yogeshmpawar, alexpott: Sort out...

Status: Fixed » Closed (fixed)

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