WorkflowUiNoTypeTest.php 2.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<?php

namespace Drupal\Tests\workflows\Functional;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests workflow UI when there are no types.
 *
 * @group workflows
 */
class WorkflowUiNoTypeTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = ['workflows', 'block'];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    // We're testing local actions.
    $this->drupalPlaceBlock('local_actions_block');
  }

  /**
   * Tests the creation of a workflow through the UI.
   */
  public function testWorkflowUiWithNoType() {
    $this->drupalLogin($this->createUser(['access administration pages', 'administer workflows']));
    $this->drupalGet('admin/config/workflow/workflows/add');
    // There are no workflow types so this should be a 403.
    $this->assertSession()->statusCodeEquals(403);

    $this->drupalGet('admin/config/workflow/workflows');
    $this->assertSession()->pageTextContains('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the Content Moderation module provides a workflow type that enables workflows for content entities.');
41
    $this->assertSession()->linkExists('Content Moderation');
42 43 44 45 46 47 48 49 50 51
    $this->assertSession()->pageTextNotContains('Add workflow');

    $this->container->get('module_installer')->install(['workflow_type_test']);
    // The render cache needs to be cleared because although the cache tags are
    // correctly set the render cache does not pick it up.
    \Drupal::cache('render')->deleteAll();

    $this->drupalGet('admin/config/workflow/workflows');
    $this->assertSession()->pageTextNotContains('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the Content Moderation module provides a workflow type that enables workflows for content entities.');
    $this->assertSession()->linkExists('Add workflow');
52
    $this->assertSession()->pageTextContains('There are no workflows yet.');
53 54 55
  }

}