Problem/Motivation

Module dependency tests for the module installation process should include a test for modules that specify an incompatible PHP version.

Proposed resolution

Create the test.

Remaining tasks

Write and review.

User interface changes

N/A

API changes

N/A

Data model changes

N/A
rc eval: it's a test.

Comments

Antti J. Salminen created an issue. See original summary.

Antti J. Salminen’s picture

Status: Active » Needs review
StatusFileSize
new3.54 KB

Here's a start based on chx giving good pointers on what's needed.

chx’s picture

Status: Needs review » Reviewed & tested by the community

This is sheer wonderful, thanks so much. I recognize and appreciate the nod towards the 6502 :) did you have an Apple ][ or a Commodore 64?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: add_test_for_enabling_modules-2567861-1.patch, failed testing.

The last submitted patch, 2: add_test_for_enabling_modules-2567861-1.patch, failed testing.

Antti J. Salminen’s picture

@chx: yeah I've got a C64, thought you might get the reference. :)

Stupid mistakes, should be better now.

Antti J. Salminen’s picture

Status: Needs work » Needs review
chx’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Yay, it's passing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: add_test_for_enabling_modules-2567861-6.patch, failed testing.

madhavvyas’s picture

+++ b/core/modules/system/src/Tests/Module/DependencyTest.php
@@ -96,6 +96,21 @@ function testIncompatibleCoreVersionDependency() {
+   * Tests enabling a module that depends on a module with an incompatible PHP version.

Exceedec 80 characters.
https://www.drupal.org/coding-standards#linelength

madhavvyas’s picture

Fixed line length issue

madhavvyas’s picture

Status: Needs work » Needs review
madhavvyas’s picture

Found one comment was modified due to my last patch updated as per earlier.

chx’s picture

Thanks for the comment fixes. "Checks functionality of project name spaces for dependencies." this one was correct in the original: it's one word, "namespace" both in PHP and programming in general

madhavvyas’s picture

Oh! yes, I agree
I have updated my patch accordingly.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Looks great.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: add_test_for_enabling_modules-2567861-15.patch, failed testing.

Status: Needs work » Needs review

Antti J. Salminen’s picture

Status: Needs review » Reviewed & tested by the community

Still passing and since this got bumped out of RTBC only because of a random test failure I'm setting it back to that.

madhavvyas’s picture

Great!

Antti J. Salminen’s picture

Issue summary: View changes
Issue tags: +rc eligible
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/src/Tests/Module/DependencyTest.php
    @@ -58,8 +58,8 @@ function testEnableWithoutDependency() {
    -    // Test that the system_dependencies_test module is marked
    -    // as missing a dependency.
    +    // Test that the system_dependencies_test module is marked as missing a
    +    // dependency.
    
    @@ -67,7 +67,8 @@ function testMissingModules() {
    -   * Tests enabling a module that depends on an incompatible version of a module.
    +   * Tests enabling a module that depends on an incompatible version of a
    +   * module.
    
    @@ -82,7 +83,8 @@ function testIncompatibleModuleVersionDependency() {
    -   * Tests enabling a module that depends on a module with an incompatible core version.
    +   * Tests enabling a module that depends on a module with an incompatible core
    +   * version.
    
    @@ -96,7 +98,24 @@ function testIncompatibleCoreVersionDependency() {
    +  /**
    +   * Tests enabling a module that depends on a module which fails
    +   * hook_requirements().
    

    These are out-of-scope changes that are not part of adding the test.

  2. +++ b/core/modules/system/src/Tests/Module/DependencyTest.php
    @@ -96,7 +98,24 @@ function testIncompatibleCoreVersionDependency() {
       /**
    -   * Tests enabling a module that depends on a module which fails hook_requirements().
    +   * Tests enabling a module that depends on a module which fails
    +   * hook_requirements().
    

    I think this test description should be different from the one below.

  3. +++ b/core/modules/system/src/Tests/Module/DependencyTest.php
    @@ -96,7 +98,24 @@ function testIncompatibleCoreVersionDependency() {
    +    $this->assertRaw(t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', array(
    +      '@php_required' => '6502.*',
    +      '@php_version' => phpversion(),
    +    )), 'A module that depends on a module with an incompatible PHP version is marked as such.');
    

    I don't think that the assertion message 'A module that depends on a module with an incompatible PHP version is marked as such.' adds much. Also looking at the test is it even necessary to have the module depending on a module with an impossible PHP version. I think even if that module was not there this test would pass - no?

The last submitted patch, 15: add_test_for_enabling_modules-2567861-15.patch, failed testing.

johnennew’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB
new4.42 KB

I've made the changes suggested in #23.

1. Removed out of scope comment changes
2. Changed doc block comment
3. Changed test message and removed the additional dependent module

johnennew’s picture

StatusFileSize
new2.67 KB
new4.41 KB

Sorry, patch with a better test message attached.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

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

kekkis’s picture

Version: 8.1.x-dev » 8.2.x-dev
Assigned: Unassigned » kekkis

Updated Version. Trying to work on this as part of Finnish monthly Drupal sprint.

kekkis’s picture

Added new patch removing one more out-of-scope comment change. See interdiff.

kekkis’s picture

And of course the patch file I attached was the wrong one. Sorry about that. Redoing...

kekkis’s picture

Here is the correct patch and the correct interdiff.

kekkis’s picture

Assigned: kekkis » Unassigned
Status: Needs review » Active
Issue tags: -rc eligible
kekkis’s picture

Status: Active » Needs review

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.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.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Antti J. Salminen’s picture

StatusFileSize
new2.49 KB
new947 bytes

Fixed the checkbox test to use the correct module name as that error got exposed by it failing with newer core.

Status: Needs review » Needs work

The last submitted patch, 36: add_test_for_enabling-2567861-34.patch, failed testing.

Antti J. Salminen’s picture

StatusFileSize
new2.48 KB

Last one didn't do it. Removing [Testing] from the same exact line should.

Antti J. Salminen’s picture

Status: Needs work » Needs review
Munavijayalakshmi’s picture

StatusFileSize
new2.52 KB

Rerolled the patch.

Status: Needs review » Needs work

The last submitted patch, 40: add_test_for_enabling-2567861-40.patch, failed testing.

boaloysius’s picture

@Munavijayalakshmi I also got the same patch as #40.

pfructuoso’s picture

Status: Needs work » Reviewed & tested by the community

Code review is ok to me and all tests are passing (on my local and CI), should we finally close the issue? :)

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/src/Tests/Module/DependencyTest.php
    @@ -91,6 +91,20 @@ public function testIncompatibleCoreVersionDependency() {
    +   * Tests users are informed if the PHP dependency requirements of
    +   * a module are not met.
    

    This should be a single line (but still less than 80 characters).

  2. +++ b/core/modules/system/tests/modules/system_incompatible_php_version_test/system_incompatible_php_version_test.info.yml
    @@ -0,0 +1,7 @@
    +php: 6502
    \ No newline at end of file
    

    Let's add a newline.

boaloysius’s picture

StatusFileSize
new1.1 KB
new2.49 KB

Made changes stated in #44

boaloysius’s picture

Status: Needs work » Needs review
tstoeckler’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/src/Tests/Module/DependencyTest.php
@@ -91,6 +91,19 @@ public function testIncompatibleCoreVersionDependency() {
+   * Tests users are informed if the PHP dependency requirements of a module are not met.

Sorry to be annoying but this is now longer than 80 characters. Maybe something like: "Tests that modules with unmet PHP version dependencies cannot be installed." ?

zeip’s picture

Status: Needs work » Needs review
StatusFileSize
new1.83 KB

New patch with shorter comment.

Status: Needs review » Needs work

The last submitted patch, 48: add_test_for_enabling-2567861-48.patch, failed testing.

zeip’s picture

Status: Needs work » Needs review
StatusFileSize
new2.44 KB

My latest patch was missing the info file, sorry for that. Re-rolling with the info file onboard.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Ran automated test in local and #50 passes all test.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Tests/Module/DependencyTest.php
@@ -91,6 +91,19 @@ public function testIncompatibleCoreVersionDependency() {
+    $this->assertRaw(t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', [
+      '@php_required' => '6502.*',
+      '@php_version' => phpversion(),
+    ]), 'User is informed when the PHP dependency requirement of a module is not met.');

This would be better to not use t() and just assert on the text rather then the actual html. See #2875148: BrowserTestBase: Steer new test development away from translation

+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -71,6 +71,7 @@ function system_test_system_info_alter(&$info, Extension $file, $type) {
+    'system_incompatible_php_version_test',

Is this actually necessary? I don't think it is.

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.83 KB
new1.82 KB

Changes as per comment #52 & also added interdiff.

+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -71,6 +71,7 @@ function system_test_system_info_alter(&$info, Extension $file, $type) {
+    'system_incompatible_php_version_test',

I am also think this is not necessary so removed it from current patch.

Status: Needs review » Needs work

The last submitted patch, 54: add_test_for_enabling-2567861-54.patch, failed testing.

zeip’s picture

Status: Needs work » Needs review
StatusFileSize
new1.82 KB

Added the format_string() function to allow using the placeholders that broke when removing t().

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

tested locally, the test passes with flying colors ;-)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Tests/Module/DependencyTest.php
@@ -91,6 +91,19 @@ public function testIncompatibleCoreVersionDependency() {
+    $this->assertRaw(format_string('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', [
+      '@php_required' => '6502.*',
+      '@php_version' => phpversion(),
+    ]), 'User is informed when the PHP dependency requirement of a module is not met.');

format_string() is deprecated and we shouldn't be adding new usages of it. You can use the FormattableMarkup class instead. Or you could do something like this:

$this->assertText('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion());
zeip’s picture

StatusFileSize
new1.72 KB

Good catch, attached is a patch for this.

zeip’s picture

Status: Needs work » Needs review
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Assuming the bot comes back green, this looks good. Thanks!

cilefen’s picture

I checked some boxes to update credit.

  • cilefen committed 05ffa70 on 8.4.x
    Issue #2567861 by Antti J. Salminen, ZeiP, madhavvyas, kekkis, johnennew...
cilefen’s picture

Status: Reviewed & tested by the community » Fixed

Committed 05ffa70 and pushed to 8.4.x. Please create interdiffs when changing patches. Thank you!

Status: Fixed » Closed (fixed)

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