Problem/Motivation

#2830740: Allow workflow types to lock certain changes to workflows once things are in use introduced a test which asserted the behaviour of state/workflow delete forms after content was creating utilising a particular state/workflow. The intention was to assert users could visit the delete page then inform them why it can't be deleted.

The assertions look something like:

    foreach ($paths as $path) {
      $this->drupalGet($path);
      $this->assertSession()->buttonExists('Delete');
    }
    ...

    // The archived state is not used yet, so can still be deleted.
    $this->drupalGet($paths['archived_state']);
    $this->assertSession()->buttonExists('Delete');

    // The workflow is being used, so can't be deleted.
    $this->drupalGet($paths['editorial_workflow']);
    $this->assertSession()->buttonNotExists('Delete');
    ...
    // Now the archived state is being used so it can not be deleted either.
    foreach ($paths as $path) {
      $this->drupalGet($path);
      $this->assertSession()->buttonNotExists('Delete');
    }

The issue being, if the page is a 403, the button doesn't exist either, so this test passes despite it being a major change in behavior. The latest patch in #2897148: Remove @internal from workflowHasData/workflowStateHasData and use those methods for access control and configuration validation. should have triggered a fail, but it did not.

Proposed resolution

Make the assertions more strict.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 2910715-2.patch1.94 KBSam152
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sam152 created an issue. See original summary.

Sam152’s picture

Status: Active » Needs review
FileSize
1.94 KB
timmillwood’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Workflow Initiative

Nice addition.

Wim Leers’s picture

❤️ the thoroughness. Improves your future sanity as a maintainer!

  • catch committed d122710 on 8.5.x
    Issue #2910715 by Sam152: The assertions in ModerationFormTest::...

  • catch committed be1b907 on 8.4.x
    Issue #2910715 by Sam152: The assertions in ModerationFormTest::...

catch credited catch.

catch’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

Status: Fixed » Closed (fixed)

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