ModerationSidebarTest.php in Lightning Workflow 8.2
File
tests/src/ExistingSite/ModerationSidebarTest.php
View source
<?php
namespace Drupal\Tests\lightning_workflow\ExistingSite;
use Drupal\Tests\WebAssert;
use Drupal\user\Entity\Role;
use weitzman\DrupalTestTraits\ExistingSiteBase;
class ModerationSidebarTest extends ExistingSiteBase {
public function test($role) {
$module_handler = $this->container
->get('module_handler');
$this
->assertTrue($module_handler
->moduleExists('toolbar'));
$this
->assertTrue($module_handler
->moduleExists('moderation_sidebar'));
$role = Role::load($role);
$this
->assertTrue($role
->hasPermission('access toolbar'));
$this
->assertTrue($role
->hasPermission('use moderation sidebar'));
$user = $this
->createUser();
$user
->addRole($role
->id());
$user
->save();
$this
->assertNotEmpty($user->passRaw);
$assert = new WebAssert($this
->getSession());
$this
->visit('/user/login');
$assert
->statusCodeEquals(200);
$assert
->fieldExists('Name')
->setValue($user
->getAccountName());
$assert
->fieldExists('Password')
->setValue($user->passRaw);
$assert
->buttonExists('Log in')
->press();
$node = $this
->createNode([
'title' => 'Foo Bar',
'type' => 'page',
]);
$path = $node
->toUrl()
->toString();
$this
->visit($path);
$assert
->statusCodeEquals(200);
$assert
->linkExists('Tasks');
}
public function provider() {
return [
[
'page_creator',
],
[
'page_reviewer',
],
];
}
}