WorkflowUiNoTypeTest.php in Drupal 9
File
core/modules/workflows/tests/src/Functional/WorkflowUiNoTypeTest.php
View source
<?php
namespace Drupal\Tests\workflows\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class WorkflowUiNoTypeTest extends BrowserTestBase {
protected static $modules = [
'workflows',
'block',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('local_actions_block');
}
public function testWorkflowUiWithNoType() {
$this
->drupalLogin($this
->createUser([
'access administration pages',
'administer workflows',
]));
$this
->drupalGet('admin/config/workflow/workflows/add');
$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.');
$this
->assertSession()
->linkExists('Content Moderation');
$this
->assertSession()
->pageTextNotContains('Add workflow');
$this
->clickLink('Content Moderation');
$modules_list_url_absolute = Url::fromRoute('system.modules_list', [], [
'fragment' => 'module-content-moderation',
'absolute' => TRUE,
])
->toString();
$this
->assertSame($this
->getSession()
->getCurrentUrl(), $modules_list_url_absolute);
$this
->assertSession()
->statusCodeEquals(403);
$this->container
->get('module_installer')
->install([
'workflow_type_test',
]);
\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');
$this
->assertSession()
->pageTextContains('There are no workflows yet.');
}
}