You are here

public function ContentTranslationOperationsTest::testContentTranslationOverviewAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationOperationsTest::testContentTranslationOverviewAccess()

Tests the access to the overview page for translations.

See also

content_translation_translate_access()

File

core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php, line 143

Class

ContentTranslationOperationsTest
Tests the content translation operations available in the content listing.

Namespace

Drupal\Tests\content_translation\Functional

Code

public function testContentTranslationOverviewAccess() {
  $access_control_handler = \Drupal::entityTypeManager()
    ->getAccessControlHandler('node');
  $user = $this
    ->createUser([
    'create content translations',
    'access content',
  ]);
  $this
    ->drupalLogin($user);
  $node = $this
    ->drupalCreateNode([
    'status' => FALSE,
    'type' => 'article',
  ]);
  $this
    ->assertFalse(content_translation_translate_access($node)
    ->isAllowed());
  $access_control_handler
    ->resetCache();
  $node
    ->setPublished();
  $node
    ->save();
  $this
    ->assertTrue(content_translation_translate_access($node)
    ->isAllowed());
  $access_control_handler
    ->resetCache();
  user_role_change_permissions(Role::AUTHENTICATED_ID, [
    'access content' => FALSE,
  ]);
  $user = $this
    ->createUser([
    'create content translations',
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->assertFalse(content_translation_translate_access($node)
    ->isAllowed());
  $access_control_handler
    ->resetCache();
}