You are here

public function AccessStorageTest::testSaveMultipleLanguageCodes in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/AccessStorageTest.php \Drupal\Tests\permissions_by_term\Kernel\AccessStorageTest::testSaveMultipleLanguageCodes()

File

tests/src/Kernel/AccessStorageTest.php, line 45

Class

AccessStorageTest
@group permissions_by_term

Namespace

Drupal\Tests\permissions_by_term\Kernel

Code

public function testSaveMultipleLanguageCodes() {
  $_REQUEST = array(
    'access' => array(
      'user' => 'admin (1), editor (45)',
      'role' => array(
        'authenticated' => 'authenticated',
      ),
    ),
  );
  $formStateStub = $this
    ->mockFormState('en', [
    'role' => [
      'authenticated' => 'authenticated',
      'anonymous' => 0,
      'administrator' => 0,
    ],
  ]);
  $this
    ->assertEquals(array(
    'UserIdPermissionsToRemove' => array(),
    'UserIdPermissionsToAdd' => array(
      '0' => '1',
      '1' => '45',
    ),
    'UserRolePermissionsToRemove' => array(),
    'aRoleIdPermissionsToAdd' => array(
      0 => 'authenticated',
    ),
  ), $this->accessStorage
    ->saveTermPermissions($formStateStub, 1));
  $formStateStub = $this
    ->mockFormState('de', [
    'role' => [
      'authenticated' => 'authenticated',
      'anonymous' => 0,
      'administrator' => 0,
    ],
  ]);
  $this
    ->assertEquals(array(
    'UserIdPermissionsToRemove' => array(),
    'UserIdPermissionsToAdd' => array(
      '0' => '1',
      '1' => '45',
    ),
    'UserRolePermissionsToRemove' => array(),
    'aRoleIdPermissionsToAdd' => array(
      0 => 'authenticated',
    ),
  ), $this->accessStorage
    ->saveTermPermissions($formStateStub, 1));
}