public function ContentModerationIntegration::testTranslationOperations in Translation Views 8
Test view's field "Translation Operation".
File
- tests/
src/ Functional/ ContentModerationIntegration.php, line 142
Class
- ContentModerationIntegration
- Class ContentModerationIntegration.
Namespace
Drupal\Tests\translation_views\FunctionalCode
public function testTranslationOperations() {
// Create node for test.
$node = $this
->createNode([
'type' => 'article',
]);
// Create translations
foreach (self::$langcodes as $langcode) {
$node
->addTranslation($langcode, [
'title' => $this
->randomMachineName(),
'status' => 0,
'moderation_state[0][state]' => 'draft',
])
->save();
}
// Ensure we have moderation state "Draft" by default
// in the newly created node.
$this
->assertTrue($node
->hasField('moderation_state'));
$this
->assertFalse($node
->get('moderation_state')
->isEmpty());
$this
->assertEquals('draft', $node
->get('moderation_state')
->first()
->getString());
// Login as a translator.
$translator = $this
->createUser([
'translate article node',
'update content translations',
]);
$this
->drupalLogin($translator);
// Check that operations are provided for translation "Draft".
$this
->drupalGet('/content-moderation-integration-test', [
'query' => [
'translation_target_language' => 'de',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1) .views-field-translation-operations ul li a', 'Edit');
}