public function TranslatorsContentIntegrationTest::testTranslatorsOperationLinks in Translation Views 8
Test Content Translators integration for target language filter.
File
- tests/
src/ Functional/ TranslatorsContentIntegrationTest.php, line 135
Class
- TranslatorsContentIntegrationTest
- Class TranslatorsContentIntegrationTest.
Namespace
Drupal\Tests\translation_views\FunctionalCode
public function testTranslatorsOperationLinks() {
$userTranslatorsLimited = $this
->createUser([
'translators_content create content translations',
'translators_content update content translations',
'translators_content delete content translations',
'translate any entity',
]);
Node::create([
'type' => 'article',
'title' => "English node",
'langcode' => 'en',
])
->save();
$this
->drupalLogin($userTranslatorsLimited);
$this
->addSkill([
'en',
'fr',
]);
// Check Add translation.
$this
->drupalGet('/test-translators-content-filter', [
'query' => [
'langcode' => 'en',
'translation_target_language' => 'fr',
],
]);
$this
->assertResponse(200);
$this
->assertSession()
->elementTextContains('css', "table > tbody > tr:nth-child(1) .views-field-translation-operations ul li a", 'Add');
$this
->drupalGet('/test-translators-content-filter', [
'query' => [
'langcode' => 'en',
'translation_target_language' => 'de',
],
]);
$this
->assertResponse(200);
$this
->assertSession()
->elementTextNotContains('css', "table > tbody > tr:nth-child(1) .views-field-translation-operations", 'Add');
// Check Edit translation for registered language.
Node::load(1)
->addTranslation('fr', [
'title' => 'French translation ',
])
->save();
$this
->drupalGet('/test-translators-content-filter', [
'query' => [
'langcode' => 'en',
'translation_target_language' => 'fr',
],
]);
$this
->assertResponse(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1) .views-field-translation-operations ul .edit a', 'Edit');
$this
->click('table > tbody > tr:nth-child(1) .views-field-translation-operations ul .edit a');
// @todo: Fix when translators permission handeling is fixed.
$this
->assertUrl('fr/node/1/edit');
// Check Delete translation for registered language.
$this
->drupalGet('/test-translators-content-filter', [
'query' => [
'langcode' => 'en',
'translation_target_language' => 'fr',
],
]);
$this
->assertResponse(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1) .views-field-translation-operations ul .delete a', 'Delete');
$this
->click('table > tbody > tr:nth-child(1) .views-field-translation-operations ul .delete a');
// @todo: Fix when translators permission handeling is fixed.
$this
->assertUrl('fr/node/1/delete');
// Check translation operations for not registered languages.
$this
->drupalGet('/test-translators-content-filter', [
'query' => [
'langcode' => 'en',
'translation_target_language' => 'de',
],
]);
$this
->assertResponse(200);
$this
->assertSession()
->elementTextNotContains('css', "table > tbody > tr:nth-child(1) .views-field-translation-operations", 'Edit');
$this
->assertSession()
->elementTextNotContains('css', "table > tbody > tr:nth-child(1) .views-field-translation-operations", 'Delete');
}