public function LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.1.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.2.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.3.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.4.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.5.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.6.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.7.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
- 3.8.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings()
Tests that the workbench moderation settings are stored correctly.
File
- tests/
src/ Functional/ LingotekWorkbenchModerationSettingsTest.php, line 70
Class
- LingotekWorkbenchModerationSettingsTest
- Tests setting up the integration with workbench moderation.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testWorkbenchModerationSettings() {
$assert_session = $this
->assertSession();
$vocabulary_id = $this->vocabulary
->id();
$this
->drupalGet('admin/lingotek/settings');
// We don't have any fields for configuring workbench moderation until it's
// enabled.
$this
->assertNoField('node[article][moderation][upload_status]', 'The field for setting the state when a content should be uploaded does not exist as workbench moderation is not enabled for this bundle.');
$this
->assertNoField('node[article][moderation][download_transition]', 'The field for setting the transition that must happen after download does not exist as workbench moderation is not enabled for this bundle.');
$this
->assertNoField('node[page][moderation][upload_status]', 'The field for setting the state when a content should be uploaded does not exist as workbench moderation is not enabled for this bundle.');
$this
->assertNoField('node[page][moderation][download_transition]', 'The field for setting the transition that must happen after download does not exist as workbench moderation is not enabled for this bundle.');
// We show a message and link for enabling it.
$this
->assertText('This entity bundle is not enabled for moderation with workbench_moderation. You can change its settings here.');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/article/moderation');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/page/moderation');
// Let's enable it for articles.
$this
->enableModerationThroughUI('article', [
'draft',
'needs_review',
'published',
], 'draft');
$this
->drupalGet('admin/lingotek/settings');
// Assert the fields for setting up the integration exist and they have
// sensible defaults.
$this
->assertField('node[article][moderation][upload_status]', 'The field for setting the state when a content should be uploaded exists.');
$this
->assertField('node[article][moderation][download_transition]', 'The field for setting the transition that must happen after download exists.');
$assert_session
->optionExists('edit-node-article-moderation-upload-status', 'published');
$assert_session
->optionExists('edit-node-article-moderation-download-transition', 'published_published');
// The content types without moderation enabled should show a link instead
// for configuring them.
$this
->assertNoField('node[page][moderation][upload_status]', 'The field for setting the state when a content should be uploaded does not exist as workbench moderation is not enabled for this bundle.');
$this
->assertNoField('node[page][moderation][download_transition]', 'The field for setting the transition that must happen after download does not exist as workbench moderation is not enabled for this bundle.');
$this
->assertText('This entity bundle is not enabled for moderation with workbench_moderation. You can change its settings here.');
$assert_session
->linkByHrefNotExists('/admin/structure/types/manage/article/moderation');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/page/moderation');
// Let's save the settings for articles.
$this
->saveLingotekContentTranslationSettings([
'node' => [
'article' => [
'profiles' => 'automatic',
'fields' => [
'title' => 1,
],
'moderation' => [
'upload_status' => 'draft',
'download_transition' => 'draft_needs_review',
],
],
],
]);
// Assert the values are saved.
$assert_session
->optionExists('edit-node-article-moderation-upload-status', 'draft');
$assert_session
->optionExists('edit-node-article-moderation-download-transition', 'draft_needs_review');
$this
->assertNoField("taxonomy_term[{$vocabulary_id}][moderation][upload_status]", 'The field for setting the state when a content should be uploaded does not exist as workbench moderation is not available for this entity type.');
$this
->assertNoField("taxonomy_term[{$vocabulary_id}][moderation][download_transition]", 'The field for setting the transition that must happen after download does not exist as workbench moderation is not available for this entity type.');
$assert_session
->linkByHrefExists("/admin/structure/taxonomy/manage/{$vocabulary_id}/moderation");
// Users cannot be moderated.
$this
->assertNoField("user[user][moderation][upload_status]", 'The field for setting the state when a content should be uploaded does not exist as workbench moderation is not available for this entity type.');
$this
->assertNoField("user[user][moderation][download_transition]", 'The field for setting the transition that must happen after download does not exist as workbench moderation is not available for this entity type.');
$assert_session
->linkByHrefNotExists("/admin/structure/user/manage/user/moderation");
$header = $this
->xpath("//details[@id='edit-entity-node']//th[text()='Workbench Moderation']");
$this
->assertEqual(count($header), 1, 'There is a Workbench Moderation column for content.');
$header = $this
->xpath("//details[@id='edit-entity-taxonomy-term']//th[text()='Workbench Moderation']");
$this
->assertEqual(count($header), 1, 'There is a Workbench Moderation column for terms.');
$header = $this
->xpath("//details[@id='edit-entity-user']//th[text()='Workbench Moderation']");
$this
->assertEqual(count($header), 0, 'There is no Workbench Moderation column for users.');
}