You are here

public function WebformTranslationPermissionsTest::testWebformTranslationPermissionsAccess in Webform Translation Permissions 8

Test access to the webform translate page.

File

tests/src/Functional/WebformTranslationPermissionsTest.php, line 95

Class

WebformTranslationPermissionsTest
Contains tests for the Webform Translation Permissions module.

Namespace

Drupal\Tests\webform_translation_permissions\Functional

Code

public function testWebformTranslationPermissionsAccess() {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform1
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform2
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalLogin($this->translateConfigUser);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform1
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform2
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalLogin($this->translateAnyWebformUser);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform1
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform2
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalLogin($this->translateOwnWebformUser);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform1
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform2
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform1
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalGet(sprintf('/admin/structure/webform/manage/%s/translate', $this->webform2
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(403);
}