public function StateTransitionValidationTest::testUserSensitiveValidTransitions in Workbench Moderation 8.2
Same name and namespace in other branches
- 8 tests/src/Unit/StateTransitionValidationTest.php \Drupal\Tests\workbench_moderation\Unit\StateTransitionValidationTest::testUserSensitiveValidTransitions()
Verifies user-aware transition validation.
@dataProvider userTransitionsProvider
Parameters
string $from: The state to transition from.
string $to: The state to transition to.
string $permission: The permission to give the user, or not.
bool $allowed: Whether or not to grant a user this permission.
bool $result: Whether userMayTransition() is expected to return TRUE or FALSE.
File
- tests/
src/ Unit/ StateTransitionValidationTest.php, line 201
Class
- StateTransitionValidationTest
- @coversDefaultClass \Drupal\workbench_moderation\StateTransitionValidation @group workbench_moderation
Namespace
Drupal\Tests\workbench_moderation\UnitCode
public function testUserSensitiveValidTransitions($from, $to, $permission, $allowed, $result) {
$user = $this
->prophesize(AccountInterface::class);
// The one listed permission will be returned as instructed; Any others are
// always denied.
$user
->hasPermission($permission)
->willReturn($allowed);
$user
->hasPermission(Argument::type('string'))
->willReturn(FALSE);
$validator = new Validator($this
->setupEntityTypeManager(), $this
->setupQueryFactory());
$this
->assertEquals($result, $validator
->userMayTransition($from, $to, $user
->reveal()));
}