public function TranslationOperationsFieldPermissionsTest::testTranslationOperationsUpdatePermissions in Translation Views 8
Test translation operation update permissions.
Throws
\Behat\Mink\Exception\ElementTextException
\Behat\Mink\Exception\ExpectationException
File
- tests/
src/ Functional/ TranslationOperationsFieldPermissionsTest.php, line 185
Class
- TranslationOperationsFieldPermissionsTest
- Class TranslationOperationsFieldPermissionsTest.
Namespace
Drupal\Tests\translation_views\FunctionalCode
public function testTranslationOperationsUpdatePermissions() {
$this
->translateNode();
$userUpdate = $this
->createUser([
'update content translations',
]);
$this
->drupalLogin($userUpdate);
// Check without translation permission.
$this
->drupalGet('/test_operations_links', [
'query' => [
'translation_target_language' => 'fr',
],
]);
$this
->assertSession()
->elementTextNotContains('css', ".view-content > div:nth-child(1) .views-field-translation-operations", 'Edit');
// Check with translation permission.
$this
->addPermissionsForAuthUser([
'translate article node',
]);
$this
->assertTrue($userUpdate
->hasPermission('translate article node'));
$this
->drupalGet('/test_operations_links', [
'query' => [
'translation_target_language' => 'fr',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', '.view-content > div:nth-child(1) .views-field-translation-operations ul .edit a', 'Edit');
$this
->click('.view-content > div:nth-child(1) .views-field-translation-operations ul .edit a');
$this
->assertUrl('/fr/node/1/translations/edit/fr');
// Check with edit permission.
$this
->addPermissionsForAuthUser([
'edit any article content',
]);
$this
->assertTrue($userUpdate
->hasPermission('edit any article content'));
$this
->drupalGet('/test_operations_links', [
'query' => [
'translation_target_language' => 'fr',
],
]);
$this
->assertSession()
->elementTextContains('css', ".view-content > div:nth-child(1) .views-field-translation-operations ul .edit a", 'Edit');
$this
->click('.view-content > div:nth-child(1) .views-field-translation-operations ul .edit a');
$this
->assertUrl('/fr/node/1/edit');
}