Problem/Motivation

Doing some follow-through on #2728579: Explicitly skip @requires module in PHPUnit Kernel and Browser tests I discovered that ToolkitGdTest has a checkRequirements() method, which overrides \PHPUnit_Framework_TestCase::checkRequirements().

This is probably left over from the Simpletest days. It was converted from Simpletest with all system module tests in #2687897: Convert system module's kernel tests to NG

The problem is that it tries to signal its requirements by returning a value, even though PHPUnit ignores the returned value and expects an exception if the requirement isn't met.

Here's what it looks like:

  protected function checkRequirements() {
    // GD2 support is available.
    if (!function_exists('imagegd2')) {
      return [
        'Image manipulations for the GD toolkit cannot run because the GD toolkit is not available.',
      ];
    }
    return parent::checkRequirements();
  }

Proposed resolution

  • Move the requirement for the imagegd2() function to a @requires annotation.
  • Remove the checkRequirements() method.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Issue tags: +Novice
chiranjeeb2410’s picture

Assigned: Unassigned » chiranjeeb2410

Would be working on this one.

chiranjeeb2410’s picture

Status: Active » Needs review
FileSize
889 bytes

@Mile23,

Uploading patch with required changes mentioned above.
Please review.

dawehner’s picture

+++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
@@ -54,17 +54,11 @@ protected function setUp() {
+   * @requires function imagegd2()

At last the official documentation don't use () on here: https://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#i...

Mile23’s picture

Status: Needs review » Needs work
chiranjeeb2410’s picture

Status: Needs work » Needs review
FileSize
887 bytes
380 bytes

@Mile23,

Did the required changes. Please review.

Mile23’s picture

Status: Needs review » Needs work

checkRequirements() imposes a requirement on the test class.

So the annotation should be part of the class docblock.

Check out the docs @dawehner linked to: https://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#i...

chiranjeeb2410’s picture

Status: Needs work » Needs review
FileSize
1017 bytes
648 bytes

@Mile23,

Fixed according to previous suggestion. Uploading fresh patch with interdiff.
Please review.

Mile23’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Needs review » Reviewed & tested by the community

Since this is a testing bug it should be filed against 8.3.x.

The patch applies to both 8.3.x and 8.4.x.

LGTM, re-running the tests for both branches.

mondrake’s picture

Status: Reviewed & tested by the community » Needs review

Shouldn't the @requires be in the class docblock? It's on a property right now AFAICS.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

You're right. I missed that it was on the property and not the class docblock before.

Mile23’s picture

Status: Needs review » Needs work

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

vacho’s picture

Version: 8.6.x-dev » 8.8.x-dev
vacho’s picture

Patch updated.

mr.baileys’s picture

Status: Needs work » Needs review

Setting to Needs Review since there is a patch available for review.

+   * @requires function imagegd2

I think we should check for the presence of the GD extension, rather than one function exposed by that extension, similar to ImageTest and ImageFormatterTest. So:

+   * @requires extension gd

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tvb’s picture

FileSize
1001 bytes
433 bytes

2861376-18.patch applies cleanly to 8.9.x-dev.

Rerolled the patch with the change proposed in #19.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mr.baileys’s picture

Status: Needs review » Needs work

#11:

Shouldn't the @requires be in the class docblock? It's on a property right now AFAICS.

The @requires-directive still needs to move to the class docblock.

tvb’s picture

Status: Needs work » Needs review
FileSize
951 bytes
593 bytes
quietone’s picture

Assigned: chiranjeeb2410 » Unassigned

This has chiranjeeb2410 assigned and that person hasn't worked on this issue for 3 years. I think it is safe to un-assign.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

neclimdul’s picture

Status: Needs review » Reviewed & tested by the community

Applied cleanly to both 10.0 and 9.4 and worked as expected.

alexpott’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Backported to 9.3.x as this is a test-only change.

  • alexpott committed cb858a9 on 10.0.x
    Issue #2861376 by chiranjeeb2410, tvb, vacho, Mile23, mr.baileys,...

  • alexpott committed 1793a94 on 9.4.x
    Issue #2861376 by chiranjeeb2410, tvb, vacho, Mile23, mr.baileys,...

  • alexpott committed c0ae5a3 on 9.3.x
    Issue #2861376 by chiranjeeb2410, tvb, vacho, Mile23, mr.baileys,...

Status: Fixed » Closed (fixed)

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