function ContentTranslationOperationsTest::testOperationTranslateLink in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/content_translation/src/Tests/ContentTranslationOperationsTest.php \Drupal\content_translation\Tests\ContentTranslationOperationsTest::testOperationTranslateLink()
Test that the operation "Translate" is displayed in the content listing.
File
- core/
modules/ content_translation/ src/ Tests/ ContentTranslationOperationsTest.php, line 66 - Contains \Drupal\content_translation\Tests\ContentTranslationOperationsTest.
Class
- ContentTranslationOperationsTest
- Tests the content translation operations available in the content listing.
Namespace
Drupal\content_translation\TestsCode
function testOperationTranslateLink() {
$node = $this
->drupalCreateNode([
'type' => 'article',
'langcode' => 'es',
]);
// Verify no translation operation links are displayed for users without
// permission.
$this
->drupalLogin($this->baseUser1);
$this
->drupalGet('admin/content');
$this
->assertNoLinkByHref('node/' . $node
->id() . '/translations');
$this
->drupalLogout();
// Verify there's a translation operation link for users with enough
// permissions.
$this
->drupalLogin($this->baseUser2);
$this
->drupalGet('admin/content');
$this
->assertLinkByHref('node/' . $node
->id() . '/translations');
// Ensure that an unintended misconfiguration of permissions does not open
// access to the translation form, see https://www.drupal.org/node/2558905.
$this
->drupalLogout();
user_role_change_permissions(Role::AUTHENTICATED_ID, [
'create content translations' => TRUE,
'access content' => FALSE,
]);
$this
->drupalLogin($this->baseUser1);
$this
->drupalGet($node
->urlInfo('drupal:content-translation-overview'));
$this
->assertResponse(403);
// Ensure that the translation overview is also not accessible when the user
// has 'access content', but the node is not published.
user_role_change_permissions(Role::AUTHENTICATED_ID, [
'create content translations' => TRUE,
'access content' => TRUE,
]);
$node
->setPublished(FALSE)
->save();
$this
->drupalGet($node
->urlInfo('drupal:content-translation-overview'));
$this
->assertResponse(403);
}