public function WorkflowsFieldTest::testOptionsProviderFilteredByUser in Workflows Field 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/WorkflowsFieldTest.php \Drupal\Tests\workflows_field\Kernel\WorkflowsFieldTest::testOptionsProviderFilteredByUser()
Settable options are filtered by the users permissions.
File
- tests/
src/ Kernel/ WorkflowsFieldTest.php, line 57
Class
- WorkflowsFieldTest
- Test the workflows field.
Namespace
Drupal\Tests\workflows_field\KernelCode
public function testOptionsProviderFilteredByUser() {
$node = Node::create([
'title' => 'Foo',
'type' => 'project',
'field_status' => 'in_discussion',
]);
$node
->save();
// If a user has no permissions then the only available state is the current
// state.
$this
->assertEquals([
'in_discussion' => 'In Discussion',
], $node->field_status[0]
->getSettableOptions($this
->createUser()));
// Grant the ability to use the approved_project transition and the user
// should now be able to set the Approved state.
$this
->assertEquals([
'in_discussion' => 'In Discussion',
'approved' => 'Approved',
], $node->field_status[0]
->getSettableOptions($this
->createUser([
'use bureaucracy_workflow transition approved_project',
])));
}