Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drush en incorrectly reports that it enabled new dependency modules #5057

Open
wants to merge 3 commits into
base: 11.x
Choose a base branch
from

Conversation

rajeshreeputra
Copy link
Contributor

No description provided.

@weitzman
Copy link
Member

weitzman commented Jan 31, 2022

Would be good to add a test for this, or add to an existing test

@rajeshreeputra rajeshreeputra marked this pull request as ready for review February 1, 2022 05:18
@rajeshreeputra
Copy link
Contributor Author

can this be tested using test
drush/tests/functional/PmEnDisUnListInfoTest.php

@weitzman
Copy link
Member

weitzman commented Feb 1, 2022

Yes, that is a good place to add testing for this.

@rajeshreeputra
Copy link
Contributor Author

is this not already covered in drush/tests/functional/PmEnDisUnListInfoTest.php at line number 40

        // Test pm-enable enables a module, and pm-list verifies that.
        $this->drush('pm-enable', ['drush_empty_module']);
        $this->drush('pm-list', [], ['status' => 'enabled']);
        $out = $this->getOutput();
        $this->assertStringContainsString('drush_empty_module', $out);

@weitzman
Copy link
Member

weitzman commented Feb 2, 2022

Not covered enough. If bug were already covered, the test would have been failing for years.

@rajeshreeputra
Copy link
Contributor Author

I'm sorry @weitzman, I have not written any tests before, trying to write one first time here. adding code snippet I tried to write for this please let me know if this is good. wee need to add this at line number 47 in drush/tests/functional/PmEnDisUnListInfoTest.php. This will get all dependency for the already enabled module, then it will check if each dependent module is enabled or not using pm-list command.

// Test pm-enable enables a dependent module for already enabled module , and pm-list verifies that.
       $list_of_dependent_modules = $this->addInstallDependencies('drush_empty_module');
       $dependent_modules = ['!list' => implode(', ', $list_of_dependent_modules)];
       foreach($dependent_modules as $dependent_module){
         $this->drush('pm-enable', [$dependent_module]);
         $this->drush('pm-list', [], ['status' => 'enabled']);
         $out = $this->getOutput();
         $this->assertStringContainsString($module_dependency, $out);
       }

We need to use below class as well to use addInstallDependencies() function.
use Drush\Drupal\Commands\pm;

@rajeshreeputra
Copy link
Contributor Author

Test added to verify that dependent module gets enabled.

Copy link
Member

@weitzman weitzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test seems not to cover the scenario thats added here

@@ -85,6 +85,12 @@ public function install(array $modules): void
$this->output()->writeln(dt('The following module(s) will be enabled: !list', $todo_str));
return;
} elseif (array_values($todo) !== $modules) {
if(!in_array($modules, $todo_str)) {
$this->output()->writeln(dt('Requested module is already enabled: !list', ['!list' => implode(', ', $modules)]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be. a logger msg of severity=notice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants