c0c7de6f527189e2ee5974500229382f10aa3b85
[yaffs-website] / web / core / modules / workflows / tests / src / Functional / WorkflowUiNoTypeTest.php
1 <?php
2
3 namespace Drupal\Tests\workflows\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests workflow UI when there are no types.
9  *
10  * @group workflows
11  */
12 class WorkflowUiNoTypeTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['workflows', 'block'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     // We're testing local actions.
27     $this->drupalPlaceBlock('local_actions_block');
28   }
29
30   /**
31    * Tests the creation of a workflow through the UI.
32    */
33   public function testWorkflowUiWithNoType() {
34     $this->drupalLogin($this->createUser(['access administration pages', 'administer workflows']));
35     $this->drupalGet('admin/config/workflow/workflows/add');
36     // There are no workflow types so this should be a 403.
37     $this->assertSession()->statusCodeEquals(403);
38
39     $this->drupalGet('admin/config/workflow/workflows');
40     $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()->pageTextNotContains('Add workflow');
42
43     $this->container->get('module_installer')->install(['workflow_type_test']);
44     // The render cache needs to be cleared because although the cache tags are
45     // correctly set the render cache does not pick it up.
46     \Drupal::cache('render')->deleteAll();
47
48     $this->drupalGet('admin/config/workflow/workflows');
49     $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.');
50     $this->assertSession()->linkExists('Add workflow');
51     $this->assertSession()->pageTextContains('There is no Workflow yet.');
52   }
53
54 }