You are here

public function ContentTranslationOperationsTest::testContentTranslationOverviewAccess in Zircon Profile 8

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

See also

content_translation_translate_access()

File

core/modules/content_translation/src/Tests/ContentTranslationOperationsTest.php, line 111
Contains \Drupal\content_translation\Tests\ContentTranslationOperationsTest.

Class

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

Namespace

Drupal\content_translation\Tests

Code

public function testContentTranslationOverviewAccess() {
  $access_control_handler = \Drupal::entityManager()
    ->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(TRUE);
  $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();
}