function ContentTranslationOperationsTest::testContentTranslationOverviewAccess

Same name in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationOperationsTest::testContentTranslationOverviewAccess()
  2. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationOperationsTest::testContentTranslationOverviewAccess()
  3. 11.x 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 144

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.