function ContentTranslationWorkflowsTest::testWorkflows
Same name in other branches
- 9 core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationWorkflowsTest::testWorkflows()
- 10 core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationWorkflowsTest::testWorkflows()
- 11.x core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationWorkflowsTest::testWorkflows()
Test simple and editorial translation workflows.
File
-
core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationWorkflowsTest.php, line 90
Class
- ContentTranslationWorkflowsTest
- Tests the content translation workflows for the test entity.
Namespace
Drupal\Tests\content_translation\FunctionalCode
public function testWorkflows() {
// Test workflows for the editor.
$expected_status = [
'edit' => 200,
'delete' => 200,
'overview' => 403,
'add_translation' => 403,
'edit_translation' => 403,
'delete_translation' => 403,
];
$this->doTestWorkflows($this->editor, $expected_status);
// Test workflows for the translator.
$expected_status = [
'edit' => 403,
'delete' => 403,
'overview' => 200,
'add_translation' => 200,
'edit_translation' => 200,
'delete_translation' => 200,
];
$this->doTestWorkflows($this->translator, $expected_status);
// Test workflows for the admin.
$expected_status = [
'edit' => 200,
'delete' => 200,
'overview' => 200,
'add_translation' => 200,
'edit_translation' => 403,
'delete_translation' => 403,
];
$this->doTestWorkflows($this->administrator, $expected_status);
// Check that translation permissions allow the associated operations.
$ops = [
'create' => t('Add'),
'update' => t('Edit'),
'delete' => t('Delete'),
];
$translations_url = $this->entity
->toUrl('drupal:content-translation-overview');
foreach ($ops as $current_op => $item) {
$user = $this->drupalCreateUser([
$this->getTranslatePermission(),
"{$current_op} content translations",
'view test entity',
]);
$this->drupalLogin($user);
$this->drupalGet($translations_url);
// Make sure that the user.permissions cache context and the cache tags
// for the entity are present.
$this->assertCacheContext('user.permissions');
foreach ($this->entity
->getCacheTags() as $cache_tag) {
$this->assertCacheTag($cache_tag);
}
foreach ($ops as $op => $label) {
if ($op != $current_op) {
$this->assertSession()
->linkNotExists($label, new FormattableMarkup('No %op link found.', [
'%op' => $label,
]));
}
else {
$this->assertSession()
->linkExists($label, 0, new FormattableMarkup('%op link found.', [
'%op' => $label,
]));
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.