drush icon indicating copy to clipboard operation
drush copied to clipboard

drush en incorrectly reports that it enabled new dependency modules

Open rajeshreeputra opened this issue 3 years ago • 7 comments

rajeshreeputra avatar Jan 31 '22 12:01 rajeshreeputra

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

weitzman avatar Jan 31 '22 15:01 weitzman

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

rajeshreeputra avatar Feb 01 '22 05:02 rajeshreeputra

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

weitzman avatar Feb 01 '22 12:02 weitzman

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);

rajeshreeputra avatar Feb 02 '22 07:02 rajeshreeputra

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

weitzman avatar Feb 02 '22 12:02 weitzman

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 avatar Feb 03 '22 11:02 rajeshreeputra

Test added to verify that dependent module gets enabled.

rajeshreeputra avatar Jun 07 '22 05:06 rajeshreeputra