Updated: Comment #0

Committers: amateescu should get credit on this issue.

Problem/Motivation

In #2125633: PHPUnit tests cannot be rerun from Simpletest UI the simpletest re-run submit handler was changed to use the API, and not just call other form's submit handlers directly.
But FormBuilder::submitForm() sets $form_state['programmed'] to TRUE, and that value is checked when deciding whether to show a progressive batch or not.

Proposed resolution

We have two options:

  1. Revert the fix, and document why it is a special case.
  2. Introduce a new $form_state flag to force the batch to work despite being programmed.

Remaining tasks

Pick an approach (I'm going to try #2 first)

User interface changes

Re-running a test in the UI will show a progress bar and display the duration of the test like it used to.

API changes

Possible API addition

CommentFileSizeAuthor
#1 simpletest-2140505-1.patch2.62 KBtim.plunkett
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
2.62 KB

Well this is option #1, for now.

amateescu’s picture

Heey, you stole my patch :D

tim.plunkett’s picture

Issue summary: View changes
Berdir’s picture

A different problem, but has anyone seen the problem where it always displays a test execution of 0 seconds? I have that on some systems, no idea why.

amateescu’s picture

This patch fixes it.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php
@@ -269,13 +257,19 @@ public function submitForm(array &$form, array &$form_state) {
-    $this->formBuilder->submitForm('Drupal\simpletest\Form\SimpletestTestForm', $form_state_execute);
...
+    // However, it sets $form_state['programmed'], which disables the Batch API.
+    $simpletest_test_form = new SimpletestTestForm();

I was so sure that this was a trick of tim to force people to write proper unit tests instead.

tim.plunkett’s picture

Issue #2140505 by amateescu, tim.plunkett: Re-running a simpletest no longer displays the batch progress or duration.

chx’s picture

*blink* what has happened to form API here? How, if at all, does whatever happened here affect other modules?

chx’s picture

To elaborate: drupal_form_submit() did a$form_state['programmed'] = TRUE; in D7, that's for sure. But I am not entirely sure how simpletest got to the point where it calls the equivalent of drupal_form_submit or why.

Edit: and whether that reason applies to other scenarios too.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

I had much the same questions as chx. Basically, what's happening here is SimpleTest is programmatically submitting forms behind the scenes and this was never compatible with Batch API (and is documented as such). However, Tim hadn't read this documentation when doing the conversion in #2125633: PHPUnit tests cannot be rerun from Simpletest UI and so accidentally introduced this bug. This is a partial revert of that patch to restore the UI elements of batch API in this part.

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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