I have a contributed module that executes some operations in a batch during the module installation. It works fine when I enable the module with Drush or from Drupal UI (/admin/modules). The problem appears when I want to enable the module when running tests. In this case we have already a running batch and the batch from my module will be executed just after the batch from Simpletest, therefore after all tests will run.

This can be fixed restoring Simpletest's batch after modules installation in WebTestBase::setUp(), not before this. Attached a patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dixon_’s picture

Status: Needs review » Needs work

@jeqq Would it be possible to include a simple test for this fix? Perhaps a test in core/modules/simpletest/src/Tests?

jeqq’s picture

Status: Needs work » Needs review
FileSize
3.86 KB

Thanks @dixon_! Added a test for this.

dixon_’s picture

Category: Task » Bug report
Status: Needs review » Reviewed & tested by the community

Considering that this feature (i.e. running batch jobs during module install) works in the Drupal UI as well as in Drush, I think it's safe to say that this is a bug in our testing framework that should be fixed.

Marking as bug.

Patch looks good, so also marking as RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: 2464283-2-restore-batch-fix.patch, failed testing.

Status: Needs work » Needs review
asgorobets’s picture

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

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php
    @@ -0,0 +1,40 @@
    +/**
    + * @file
    +   * Contains \Drupal\simpletest\Tests\SimpleTestInstallBatchTest.
    + */
    

    Weird formatting

  2. +++ b/core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php
    @@ -0,0 +1,40 @@
    +namespace Drupal\simpletest\Tests;
    +
    +
    +use Drupal\simpletest\WebTestBase;
    

    Too many new lines

  3. +++ b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.module
    
    +++ b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.module
    +++ b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.module
    @@ -0,0 +1 @@
    
    @@ -0,0 +1 @@
    +<?php
    

    I don't think we need empty module files anymore.

jeqq’s picture

Status: Needs work » Needs review
FileSize
3.53 KB

Thanks @alexpott. Fixed.

dixon_’s picture

Status: Needs review » Reviewed & tested by the community

Issues are addressed, back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 2464283-8-restore-batch-fix.patch, failed testing.

jeqq’s picture

Status: Needs work » Needs review

dixon_’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 2464283-8-restore-batch-fix.patch, failed testing.

Status: Needs work » Needs review
dixon_’s picture

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

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed e2aaf40 and pushed to 8.0.x. Thanks!

  • alexpott committed e2aaf40 on 8.0.x
    Issue #2464283 by jeqq: Restore Simpletest's batch after modules...

Status: Fixed » Closed (fixed)

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