You are here

public function RoleGrantedLockingTest::testUserFormHasLock in Commerce License 8.2

Tests a role granted by a license is locked on a user's account form.

File

tests/src/Functional/RoleGrantedLockingTest.php, line 71

Class

RoleGrantedLockingTest
Tests that a role granted by a license can't be removed in the user form.

Namespace

Drupal\Tests\commerce_license\Functional

Code

public function testUserFormHasLock() {

  // Get the account for for the license owner user.
  $this
    ->drupalGet("user/" . $this->license
    ->getOwnerId() . "/edit");
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->fieldDisabled("roles[licensed_role]");
  $this
    ->assertSession()
    ->pageTextContains("This role is granted by a license. It cannot be removed manually.");

  // Ensure that saving the form doesn't remove the granted role.
  $this
    ->submitForm([], 'Save');
  $this
    ->assertTrue($this->license
    ->getOwner()
    ->hasRole('licensed_role'));
}