public function LingotekContentModerationSettingsTest::testContentModerationSettings in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.0.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.1.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.2.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.3.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.4.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.5.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.6.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.7.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
- 3.8.x tests/src/Functional/LingotekContentModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationSettingsTest::testContentModerationSettings()
Tests that the content moderation settings are stored correctly.
File
- tests/
src/ Functional/ LingotekContentModerationSettingsTest.php, line 96
Class
- LingotekContentModerationSettingsTest
- Tests setting up the integration with content moderation.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testContentModerationSettings() {
$assert_session = $this
->assertSession();
$this
->drupalGet('admin/lingotek/settings');
// We don't have any fields for configuring content 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 content 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 content 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 content 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 content 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 content_moderation. You can change its settings here.');
$assert_session
->linkByHrefExists('/admin/config/workflow/workflows', 0);
$assert_session
->linkByHrefExists('/admin/config/workflow/workflows', 1);
// 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', 'publish');
// But not for the other content types. There is still a message for configuring.
$this
->assertNoField('node[page][moderation][upload_status]', 'The field for setting the state when a content should be uploaded does not exist as content 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 content moderation is not enabled for this bundle.');
$this
->assertText('This entity bundle is not enabled for moderation with content_moderation. You can change its settings here.');
$assert_session
->linkByHrefExists('/admin/config/workflow/workflows', 0);
// Let's save the settings for articles.
$this
->saveLingotekContentTranslationSettings([
'node' => [
'article' => [
'profiles' => 'automatic',
'fields' => [
'title' => 1,
],
'moderation' => [
'upload_status' => 'draft',
'download_transition' => 'archive',
],
],
],
]);
// Assert the values are saved.
$assert_session
->optionExists('edit-node-article-moderation-upload-status', 'draft');
$assert_session
->optionExists('edit-node-article-moderation-download-transition', 'archive');
// It never existed for taxonomies.
$this
->assertNoField("taxonomy_term[{$this->vocabulary->id()}][moderation][upload_status]", 'The field for setting the state when a content should be uploaded does not exist as content moderation is not available for this entity type.');
$this
->assertNoField("taxonomy_term[{$this->vocabulary->id()}][moderation][download_transition]", 'The field for setting the transition that must happen after download does not exist as content moderation is not available for this entity type.');
$assert_session
->linkByHrefNotExists("/admin/structure/taxonomy/manage/{$this->vocabulary->id()}/moderation", 'There is no link to moderation settings in taxonomies as they cannot be moderated.');
$header = $this
->xpath("//details[@id='edit-entity-node']//th[text()='Content moderation']");
$this
->assertEqual(count($header), 1, 'There is a content moderation column for content.');
$header = $this
->xpath("//details[@id='edit-entity-taxonomy-term']//th[text()='Content moderation']");
$this
->assertEqual(count($header), 0, 'There is no content moderation column for taxonomies.');
}