class ContentTmgmtEntitySourceUiTest in Translation Management Tool 8
Content entity source UI tests.
@group tmgmt
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses FunctionalTestSetupTrait, TestSetupTrait, AssertLegacyTrait, BlockCreationTrait, ConfigTestTrait, ContentTypeCreationTrait, NodeCreationTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\tmgmt\Functional\TMGMTTestBase uses TmgmtTestTrait
- class \Drupal\Tests\tmgmt_content\Functional\ContentTmgmtEntitySourceUiTest uses TmgmtEntityTestTrait
- class \Drupal\Tests\tmgmt\Functional\TMGMTTestBase uses TmgmtTestTrait
Expanded class hierarchy of ContentTmgmtEntitySourceUiTest
File
- sources/
content/ tests/ src/ Functional/ ContentTmgmtEntitySourceUiTest.php, line 23
Namespace
Drupal\Tests\tmgmt_content\FunctionalView source
class ContentTmgmtEntitySourceUiTest extends TMGMTTestBase {
use TmgmtEntityTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array(
'tmgmt_content',
'comment',
'ckeditor',
'block_content',
);
/**
* {@inheritdoc}
*/
function setUp() : void {
parent::setUp();
$this
->addLanguage('de');
$this
->addLanguage('fr');
$this
->addLanguage('es');
$this
->addLanguage('el');
$this
->addLanguage('it');
$this
->createNodeType('page', 'Page', TRUE);
$this
->createNodeType('article', 'Article', TRUE);
$this
->loginAsAdmin(array(
'create translation jobs',
'submit translation jobs',
'accept translation jobs',
'administer blocks',
'administer content translation',
'edit any article content',
));
}
/**
* Test the translate tab for a single checkout.
*/
function testNodeTranslateTabSingleCheckout() {
$this
->loginAsTranslator(array(
'translate any entity',
'create content translations',
));
// Create an english source node.
$node = $this
->createTranslatableNode('page', 'en');
// Create a nodes that will not be translated to test the missing
// translation filter.
$node_not_translated = $this
->createTranslatableNode('page', 'en');
$node_german = $this
->createTranslatableNode('page', 'de');
// Go to the translate tab.
$this
->drupalGet('node/' . $node
->id());
$this
->clickLink('Translate');
// Assert some basic strings on that page.
$this
->assertText(t('Translations of @title', array(
'@title' => $node
->getTitle(),
)));
$this
->assertText(t('Pending Translations'));
// Request a translation for german.
$edit = array(
'languages[de]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
// Verify that we are on the translate tab.
$this
->assertText(t('One job needs to be checked out.'));
$this
->assertText($node
->getTitle());
// Submit.
$this
->drupalPostForm(NULL, array(), t('Submit to provider'));
// Make sure that we're back on the translate tab.
$this
->assertEqual($node
->toUrl('canonical', array(
'absolute' => TRUE,
))
->toString() . '/translations', $this
->getUrl());
$this
->assertText(t('Test translation created.'));
$this
->assertText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $node
->getTitle(),
'@language' => t('German'),
)));
// Verify that the pending translation is shown.
$this
->clickLinkWithImageTitle('Needs review');
$this
->drupalPostForm(NULL, array(), t('Save as completed'));
$node = Node::load($node
->id());
$translation = $node
->getTranslation('de');
$this
->assertText(t('The translation for @title has been accepted as @target.', array(
'@title' => $node
->getTitle(),
'@target' => $translation
->label(),
)));
// German node should now be listed and be clickable.
$this
->clickLink('de(de-ch): ' . $node
->label());
$this
->assertText('de(de-ch): ' . $node
->getTitle());
$this
->assertText('de(de-ch): ' . $node->body->value);
// Test that the destination query argument does not break the redirect
// and we are redirected back to the correct page.
// Go to the translate tab.
$this
->drupalGet('node/' . $node
->id());
$this
->clickLink(t('Translate'));
// Request a translation for french.
$edit = array(
'languages[fr]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
$this
->drupalGet('node/' . $node
->id() . '/translations', array(
'query' => array(
'destination' => 'node/' . $node
->id(),
),
));
// The job item is not yet active.
$this
->clickLink(t('Inactive'));
$this
->assertText($node
->getTitle());
$this
->assertRaw('<div data-drupal-selector="edit-actions" class="form-actions js-form-wrapper form-wrapper" id="edit-actions">');
// Assert that the validation of HTML tags with editor works.
$this
->drupalPostForm(NULL, [], t('Validate HTML tags'));
$this
->assertText($node
->label());
$this
->assertResponse(200);
$this
->drupalGet('node/' . $node
->id() . '/translations', array(
'query' => array(
'destination' => 'node/' . $node
->id(),
),
));
// Request a spanish translation.
$edit = array(
'languages[es]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
// Verify that we are on the checkout page.
$this
->assertText(t('One job needs to be checked out.'));
$this
->assertText($node
->getTitle());
$this
->drupalPostForm(NULL, array(), t('Submit to provider'));
// Make sure that we're back on the originally defined destination URL.
$this
->assertEqual($node
->toUrl('canonical', array(
'absolute' => TRUE,
))
->toString(), $this
->getUrl());
// Test the missing translation filter.
$this
->drupalGet('admin/tmgmt/sources/content/node');
$this
->assertText($node
->getTitle());
$this
->assertText($node_not_translated
->getTitle());
$this
->drupalPostForm(NULL, array(
'search[target_language]' => 'de',
'search[target_status]' => 'untranslated',
), t('Search'));
$this
->assertNoText($node
->getTitle());
$this
->assertNoText($node_german
->getTitle());
$this
->assertText($node_not_translated
->getTitle());
// Update the outdated flag of the translated node and test if it is
// listed among sources with missing translation.
\Drupal::entityTypeManager()
->getStorage('node')
->resetCache();
$node = Node::load($node
->id());
$node
->getTranslation('de')->content_translation_outdated->value = 1;
$node
->save();
$this
->drupalPostForm(NULL, array(
'search[target_language]' => 'de',
'search[target_status]' => 'outdated',
), t('Search'));
$this
->assertText($node
->getTitle());
$this
->assertNoText($node_german
->getTitle());
$this
->assertNoText($node_not_translated
->getTitle());
$this
->drupalPostForm(NULL, array(
'search[target_language]' => 'de',
'search[target_status]' => 'untranslated_or_outdated',
), t('Search'));
$this
->assertText($node
->getTitle());
$this
->assertNoText($node_german
->getTitle());
$this
->assertText($node_not_translated
->getTitle());
// Check that is set to outdated.
$xpath = $this
->xpath('//*[@id="edit-items"]/tbody/tr[2]/td[6]/a/img');
$this
->assertEqual($xpath[0]
->getAttribute('title'), t('Translation Outdated'));
// Check that the icons link to the appropriate translations.
$xpath_source = $this
->xpath('//*[@id="edit-items"]/tbody/tr[2]/td[4]/*[1]');
$xpath_not_translated = $this
->xpath('//*[@id="edit-items"]/tbody/tr[2]/td[5]/*[1]');
$xpath_outdated = $this
->xpath('//*[@id="edit-items"]/tbody/tr[2]/td[6]/*[1]');
$this
->assertTrue(strpos($xpath_source[0]
->getAttribute('href'), '/node/1') !== FALSE);
$this
->assertContains('node/1', $xpath_source[0]
->getAttribute('href'));
$this
->assertNotEquals('a', $xpath_not_translated[0]
->getTagName());
$this
->assertContains('/de/node/1', $xpath_outdated[0]
->getAttribute('href'));
// Test that a job can not be accepted if the entity does not exist.
$deleted_node = $this
->createTranslatableNode('page', 'en');
$second_node = $this
->createTranslatableNode('page', 'en');
$this
->drupalGet('node/' . $deleted_node
->id() . '/translations');
$edit = array(
'languages[de]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
$this
->drupalPostForm(NULL, array(), t('Submit to provider'));
$edit = array(
'languages[fr]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
$this
->drupalPostForm(NULL, [], t('Submit to provider'));
$job = $this
->createJob('en', 'de');
$job
->addItem('content', 'node', $deleted_node
->id());
$job
->addItem('content', 'node', $second_node
->id());
$this
->drupalGet($job
->toUrl());
$this
->drupalPostForm(NULL, [], t('Submit to provider'));
$this
->assertText(t('1 conflicting item has been dropped.'));
$this
->drupalGet('node/' . $deleted_node
->id() . '/translations');
$this
->clickLinkWithImageTitle('Needs review');
// Delete the node and assert that the job can not be accepted.
$deleted_node
->delete();
$this
->drupalPostForm(NULL, array(), t('Save as completed'));
$this
->assertText(t('@id of type @type does not exist, the job can not be completed.', array(
'@id' => $deleted_node
->id(),
'@type' => $deleted_node
->getEntityTypeId(),
)));
}
/**
* Test the translate tab for a multiple checkout.
*/
function testNodeTranslateTabMultipleCheckout() {
// Allow auto-accept.
$default_translator = Translator::load('test_translator');
$default_translator
->setAutoAccept(TRUE)
->save();
$this
->loginAsTranslator(array(
'translate any entity',
'create content translations',
));
// Create an english source node.
$node = $this
->createTranslatableNode('page', 'en');
// Go to the translate tab.
$this
->drupalGet('node/' . $node
->id());
$this
->clickLink('Translate');
// Assert some basic strings on that page.
$this
->assertText(t('Translations of @title', array(
'@title' => $node
->getTitle(),
)));
$this
->assertText(t('Pending Translations'));
// Request a translation for german, spanish and french.
$edit = array(
'languages[de]' => TRUE,
'languages[es]' => TRUE,
'languages[it]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
// Verify that we are on the translate tab.
$this
->assertText(t('3 jobs need to be checked out.'));
// Assert progress bar.
$this
->assertText('3 jobs pending');
$this
->assertText($node
->label() . ', English to German');
$this
->assertText($node
->label() . ', English to Spanish');
$this
->assertText($node
->label() . ', English to Italian');
$this
->assertRaw('progress__track');
$this
->assertRaw('<div class="progress__bar" style="width: 3%"></div>');
// Submit all jobs.
$edit = [
'label[0][value]' => 'Customized label',
'submit_all' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Submit to provider and continue'));
// Assert messages.
$this
->assertText('Test translation created.');
$this
->assertText('The translation job has been finished.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as de(de-ch): ' . $node
->label() . '.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as es: ' . $node
->label() . '.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as it: ' . $node
->label() . '.');
// Make sure that we're back on the translate tab.
$this
->assertEqual($node
->toUrl('canonical', array(
'absolute' => TRUE,
))
->toString() . '/translations', $this
->getUrl());
$this
->assertText(t('Test translation created.'));
$this
->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $node
->getTitle(),
'@language' => t('Spanish'),
)));
$node = Node::load($node
->id());
$translation = $node
->getTranslation('es');
$this
->assertText(t('The translation for @title has been accepted as @target.', array(
'@title' => $node
->getTitle(),
'@target' => $translation
->label(),
)));
//Assert link is clickable.
$this
->clickLink($node
->getTitle());
// Translated nodes should now be listed and be clickable.
// @todo Use links on translate tab.
$this
->drupalGet('de/node/' . $node
->id());
$this
->assertText('de(de-ch): ' . $node
->getTitle());
$this
->assertText('de(de-ch): ' . $node->body->value);
$this
->drupalGet('es/node/' . $node
->id());
$this
->assertText('es: ' . $node
->getTitle());
$this
->assertText('es: ' . $node->body->value);
// Assert that all jobs were updated to use the customized label.
foreach (Job::loadMultiple() as $job) {
$this
->assertEqual($job
->label(), 'Customized label');
}
}
/**
* Test the translate tab for a quick checkout.
*/
function testNodeTranslateTabQuickCheckout() {
// Allow auto-accept and do not expose checkout settings.
$default_translator = Translator::load('test_translator');
$default_translator
->setSetting('expose_settings', FALSE)
->setAutoAccept(TRUE)
->save();
$this
->loginAsTranslator([
'translate any entity',
'create content translations',
]);
// Create an english source node.
$node = $this
->createTranslatableNode('page', 'en');
// Go to the translate tab.
$this
->drupalGet($node
->toUrl());
$this
->clickLink('Translate');
// Request a translation for german, spanish and french.
$edit = [
'languages[de]' => TRUE,
'languages[es]' => TRUE,
'languages[it]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, 'Request translation');
// Assert messages.
$this
->assertText('Test translation created.');
$this
->assertText('The translation job has been finished.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as de(de-ch): ' . $node
->label() . '.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as es: ' . $node
->label() . '.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as it: ' . $node
->label() . '.');
// Make sure that we're back on the translate tab.
$this
->assertEqual($node
->toUrl('drupal:content-translation-overview', [
'absolute' => TRUE,
])
->toString(), $this
->getUrl());
$this
->assertText('Test translation created.');
$this
->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $node
->getTitle(),
'@language' => t('Spanish'),
)));
$node = Node::load($node
->id());
$translation = $node
->getTranslation('es');
$this
->assertText(t('The translation for @title has been accepted as @target.', [
'@title' => $node
->getTitle(),
'@target' => $translation
->label(),
]));
// Assert link is clickable.
$this
->clickLink($node
->getTitle());
// Translated nodes should now be listed and be clickable.
$this
->clickLink('Translate');
$this
->clickLink('de(de-ch): ' . $node
->getTitle());
$this
->assertText('de(de-ch): ' . $node
->getTitle());
$this
->assertText('de(de-ch): ' . $node->body->value);
$this
->drupalGet('es/node/' . $node
->id());
$this
->assertText('es: ' . $node
->getTitle());
$this
->assertText('es: ' . $node->body->value);
}
/**
* Test job submission of multiple jobs with an unsupported language
*/
function testNodeTranslateTabMultipleCheckoutUnsupported() {
// Allow auto-accept.
$default_translator = Translator::load('test_translator');
$default_translator
->setAutoAccept(TRUE)
->save();
$this
->loginAsTranslator([
'translate any entity',
'create content translations',
]);
// Create an english source node.
$node = $this
->createTranslatableNode('page', 'en');
// Go to the translate tab.
$this
->drupalGet('node/' . $node
->id());
$this
->clickLink('Translate');
// Assert some basic strings on that page.
$this
->assertText(t('Translations of @title', [
'@title' => $node
->getTitle(),
]));
$this
->assertText(t('Pending Translations'));
// Request a translation for german, spanish and french.
$edit = [
'languages[de]' => TRUE,
'languages[es]' => TRUE,
'languages[el]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
// Verify that we are on the translate tab.
$this
->assertText(t('3 jobs need to be checked out.'));
// Assert progress bar.
$this
->assertText('3 jobs pending');
$this
->assertText($node
->label() . ', English to German');
$this
->assertText($node
->label() . ', English to Spanish');
$this
->assertText($node
->label() . ', English to Greek');
$this
->assertRaw('progress__track');
$this
->assertRaw('<div class="progress__bar" style="width: 3%"></div>');
// Submit all jobs.
$edit = [
'submit_all' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Submit to provider and continue'));
// Assert messages.
$this
->assertText('Test translation created.');
$this
->assertText('The translation job has been finished.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as de(de-ch): ' . $node
->label() . '.');
$this
->assertText('The translation for ' . $node
->label() . ' has been accepted as es: ' . $node
->label() . '.');
$this
->assertText('Job ' . $node
->label() . ' is not translatable with the chosen settings: Test provider can not translate from English to Greek.');
// Assert progress bar.
$this
->assertText('1 job pending');
$this
->assertNoText($node
->label() . ', English to German');
$this
->assertNoText($node
->label() . ', English to Spanish');
$this
->assertText($node
->label() . ', English to Greek');
$this
->assertRaw('progress__track');
$this
->assertRaw('<div class="progress__bar" style="width: 67%"></div>');
}
/**
* Test translating comments.
*/
function testCommentTranslateTab() {
// Allow auto-accept.
$default_translator = Translator::load('test_translator');
$default_translator
->setAutoAccept(TRUE)
->save();
// Add default comment type.
$this
->addDefaultCommentField('node', 'article');
// Enable comment translation.
/** @var \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager */
$content_translation_manager = \Drupal::service('content_translation.manager');
$content_translation_manager
->setEnabled('comment', 'comment', TRUE);
// Change comment_body field to be translatable.
$comment_body = FieldConfig::loadByName('comment', 'comment', 'comment_body');
$comment_body
->setTranslatable(TRUE)
->save();
// Create a user that is allowed to translate comments.
$permissions = array_merge($this->translator_permissions, array(
'translate comment',
'post comments',
'skip comment approval',
'edit own comments',
'access comments',
'administer comments',
'bypass node access',
));
$this
->loginAsTranslator($permissions, TRUE);
// Create an english source article.
$node = $this
->createTranslatableNode('article', 'en');
// Add a comment.
$this
->drupalGet('node/' . $node
->id());
$edit = array(
'subject[0][value]' => $this
->randomMachineName(),
'comment_body[0][value]' => $this
->randomMachineName(),
);
$this
->drupalPostForm(NULL, $edit, t('Save'));
$this
->assertText(t('Your comment has been posted.'));
// Go to the translate tab.
$this
->clickLink('Edit');
$this
->assertNotEmpty(preg_match('|comment/(\\d+)/edit$|', $this
->getUrl(), $matches), 'Comment found');
$comment = Comment::load($matches[1]);
$this
->clickLink('Translate');
// Assert some basic strings on that page.
$this
->assertText(t('Translations of @title', array(
'@title' => $comment
->getSubject(),
)));
$this
->assertText(t('Pending Translations'));
// Request translations.
$edit = array(
'languages[de]' => TRUE,
'languages[es]' => TRUE,
);
$this
->drupalPostForm(NULL, $edit, t('Request translation'));
// Verify that we are on the translate tab.
$this
->assertText(t('2 jobs need to be checked out.'));
// Submit all jobs.
$this
->assertText($comment
->getSubject());
$this
->drupalPostForm(NULL, array(), t('Submit to provider and continue'));
$this
->assertText($comment
->getSubject());
$this
->drupalPostForm(NULL, array(), t('Submit to provider'));
// Make sure that we're back on the translate tab.
$this
->assertUrl($comment
->toUrl('canonical', array(
'absolute' => TRUE,
))
->toString() . '/translations');
$this
->assertText(t('Test translation created.'));
$this
->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $comment
->getSubject(),
'@language' => t('Spanish'),
)));
$this
->assertText(t('The translation for @title has been accepted as es: @target.', array(
'@title' => $comment
->getSubject(),
'@target' => $comment
->getSubject(),
)));
// The translated content should be in place.
$this
->clickLink('de(de-ch): ' . $comment
->getSubject());
$this
->assertText('de(de-ch): ' . $comment
->get('comment_body')->value);
$this
->drupalGet('comment/1/translations');
$this
->clickLink('es: ' . $comment
->getSubject());
$this
->drupalGet('es/node/' . $comment
->id());
$this
->assertText('es: ' . $comment
->get('comment_body')->value);
// Disable auto-accept.
$default_translator
->setAutoAccept(FALSE)
->save();
// Request translation to Italian.
$edit = [
'languages[it]' => TRUE,
];
$this
->drupalPostForm('comment/' . $comment
->id() . '/translations', $edit, 'Request translation');
$this
->drupalPostForm(NULL, [], 'Submit to provider');
$this
->clickLink('reviewed');
$this
->assertText('Translation publish status');
$this
->assertFieldChecked('edit-status-published', 'Target publish status field is checked.');
// Do not publish the Italian translation.
$edit = [
'status[published]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save as completed');
$this
->drupalGet('it/comment/' . $comment
->id());
$this
->assertText('it: ' . $comment
->getSubject());
// Original entity and other translations are not affected.
$this
->drupalGet('comment/' . $comment
->id());
$this
->assertResponse(200);
$this
->assertText($comment
->getSubject());
$this
->drupalGet('de/comment/' . $comment
->id());
$this
->assertResponse(200);
$this
->drupalLogout();
$this
->drupalGet('it/comment/' . $comment
->id());
$this
->assertResponse(403);
}
/**
* Test the entity source specific cart functionality.
*/
function testCart() {
$this
->loginAsTranslator(array(
'translate any entity',
'create content translations',
));
$nodes = array();
for ($i = 0; $i < 4; $i++) {
$nodes[$i] = $this
->createTranslatableNode('page');
}
// Test the source overview.
$this
->drupalPostForm('admin/tmgmt/sources/content/node', array(
'items[' . $nodes[1]
->id() . ']' => TRUE,
'items[' . $nodes[2]
->id() . ']' => TRUE,
), t('Add to cart'));
$this
->drupalGet('admin/tmgmt/cart');
$this
->assertText($nodes[1]
->getTitle());
$this
->assertText($nodes[2]
->getTitle());
// Test the translate tab.
$this
->drupalGet('node/' . $nodes[3]
->id() . '/translations');
$this
->assertRaw(t('There are @count items in the <a href=":url">translation cart</a>.', array(
'@count' => 2,
':url' => Url::fromRoute('tmgmt.cart')
->toString(),
)));
$this
->drupalPostForm(NULL, array(), t('Add to cart'));
$this
->assertRaw(t('@count content source was added into the <a href=":url">cart</a>.', array(
'@count' => 1,
':url' => Url::fromRoute('tmgmt.cart')
->toString(),
)));
$this
->assertRaw(t('There are @count items in the <a href=":url">translation cart</a> including the current item.', array(
'@count' => 3,
':url' => Url::fromRoute('tmgmt.cart')
->toString(),
)));
// Add nodes and assert that page footer is being shown.
$nodes = array();
for ($i = 0; $i < 50; $i++) {
$nodes[$i] = $this
->createTranslatableNode('page');
}
$this
->drupalGet('admin/tmgmt/sources/content/node');
$this
->assertRaw('<ul class="pager__items js-pager__items">');
$this
->assertEqual(count($this
->xpath('//nav[@class="pager"]/ul[@class="pager__items js-pager__items"]/li/a')), 5);
}
/**
* Tests the embedded references.
*/
function testEmbeddedReferences() {
// Create 4 field storages, 3 for nodes, 1 for users (not translatable
// target).
$field1 = FieldStorageConfig::create(array(
'field_name' => 'field1',
'entity_type' => 'node',
'type' => 'entity_reference',
'cardinality' => -1,
'settings' => array(
'target_type' => 'node',
),
));
$field1
->save();
$field2 = FieldStorageConfig::create(array(
'field_name' => 'field2',
'entity_type' => 'node',
'type' => 'entity_reference',
'cardinality' => -1,
'settings' => array(
'target_type' => 'node',
),
));
$field2
->save();
$field3 = FieldStorageConfig::create(array(
'field_name' => 'field3',
'entity_type' => 'node',
'type' => 'entity_reference',
'cardinality' => -1,
'settings' => array(
'target_type' => 'node',
),
));
$field3
->save();
$field4 = FieldStorageConfig::create(array(
'field_name' => 'field4',
'entity_type' => 'node',
'type' => 'entity_reference',
'cardinality' => -1,
'settings' => array(
'target_type' => 'user',
),
));
$field4
->save();
$this
->createNodeType('untranslatable', 'Untranslatable', FALSE);
// There are two node types, article (translatable) and untranslatable, with
// the following field configuration:
// Untranslatable Field 1 on article and untranslatable: Available
// Untranslatable Field 2 on untranslatable: Not Available
// Translatable Field 3 on article: Available
// Untranslatable Field 4 (user reference) on article: Not available.
FieldConfig::create(array(
'field_storage' => $field1,
'bundle' => 'article',
'label' => 'Field 1',
'translatable' => FALSE,
'settings' => array(),
))
->save();
FieldConfig::create(array(
'field_storage' => $field1,
'bundle' => 'untranslatable',
'label' => 'Field 1',
'translatable' => FALSE,
'settings' => array(),
))
->save();
FieldConfig::create(array(
'field_storage' => $field2,
'bundle' => 'untranslatable',
'label' => 'Field 2',
'translatable' => FALSE,
'settings' => array(),
))
->save();
FieldConfig::create(array(
'field_storage' => $field3,
'bundle' => 'article',
'label' => 'Field 3',
'translatable' => TRUE,
'settings' => array(),
))
->save();
FieldConfig::create(array(
'field_storage' => $field4,
'bundle' => 'article',
'label' => 'Field 4',
'translatable' => FALSE,
'settings' => array(),
))
->save();
EntityViewDisplay::load('node.article.default')
->setComponent('field1', [
'type' => 'entity_reference_entity_view',
'settings' => [
'view_mode' => 'teaser',
],
])
->save();
$this
->drupalGet('admin/tmgmt/settings');
// Field 1 and 3 should be available, enable them.
$checked_reference_fields = array(
'embedded_fields[node][field1]' => TRUE,
'embedded_fields[node][field3]' => TRUE,
);
// The node about translatable fields should be shown exactly once.
$this
->assertUniqueText('Note: This is a translatable field, embedding this will add a translation on the existing reference.');
// String fields, field 2 and 4 as well as the node type und uid reference
// should not show up.
$this
->assertNoField('embedded_fields[node][title]');
$this
->assertNoField('embedded_fields[node][uid]');
$this
->assertNoField('embedded_fields[node][field2]');
$this
->assertNoField('embedded_fields[node][field4]');
$this
->assertNoField('embedded_fields[node][type]');
$this
->drupalPostForm(NULL, $checked_reference_fields, t('Save configuration'));
// Check if the save was successful.
$this
->assertText(t('The configuration options have been saved.'));
$this
->assertFieldChecked('edit-embedded-fields-node-field1');
$this
->assertFieldChecked('edit-embedded-fields-node-field3');
// Create translatable child node.
$edit = [
'title' => 'Child title',
'type' => 'article',
'langcode' => 'en',
];
$child_node = $this
->createNode($edit);
// Create translatable parent node.
$edit = [
'title' => 'Parent title',
'type' => 'article',
'langcode' => 'en',
];
$edit['field1'][]['target_id'] = $child_node
->id();
$parent_node = $this
->createNode($edit);
// Create a translation job.
$job = $this
->createJob('en', 'de');
$job->translator = $this->default_translator
->id();
$job
->save();
$job_item = tmgmt_job_item_create('content', $parent_node
->getEntityTypeId(), $parent_node
->id(), array(
'tjid' => $job
->id(),
));
$job_item
->save();
$job
->requestTranslation();
// Visit preview page.
$this
->drupalGet(URL::fromRoute('entity.tmgmt_job_item.canonical', [
'tmgmt_job_item' => $job_item
->id(),
]));
$this
->clickLink(t('Preview'));
// Check if parent and child nodes are translated.
$this
->assertText('de(de-ch): ' . $parent_node
->getTitle());
$this
->assertText('de(de-ch): ' . $parent_node->body->value);
$this
->assertText('de(de-ch): ' . $child_node
->getTitle());
$this
->assertText('de(de-ch): ' . $child_node->body->value);
}
/**
* Test content entity source preview.
*/
function testEntitySourcePreview() {
// Create the basic block type.
$bundle = BlockContentType::create([
'id' => 'basic',
'label' => 'basic',
]);
$bundle
->save();
// Enable translation for basic blocks.
$edit = [
'entity_types[block_content]' => 'block_content',
'settings[block_content][basic][translatable]' => TRUE,
];
$this
->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$this
->assertText(t('Settings successfully updated.'));
// Create a custom block.
$custom_block = BlockContent::create([
'type' => 'basic',
'info' => 'Custom Block',
'langcode' => 'en',
]);
$custom_block
->save();
// Translate the custom block and assert the preview.
$this
->drupalPostForm('admin/tmgmt/sources/content/block_content', [
'items[1]' => 1,
], t('Request translation'));
$this
->drupalPostForm(NULL, [
'target_language' => 'de',
'translator' => 'test_translator',
], t('Submit to provider'));
$this
->clickLink(t('reviewed'));
$this
->clickLink(t('Preview'));
$this
->assertText(t('Preview of Custom Block for German'));
// Create a node and translation job.
$node = $this
->createTranslatableNode('page', 'en');
$this
->drupalPostForm('admin/tmgmt/sources', [
'items[1]' => 1,
], t('Request translation'));
$this
->drupalPostForm(NULL, [
'target_language' => 'de',
'translator' => 'test_translator',
], t('Submit to provider'));
// Delete the node.
$node
->delete();
// Review the translation.
$this
->clickLink(t('reviewed'));
$review_url = $this
->getSession()
->getCurrentUrl();
// Assert that preview page is not available for non-existing entities.
$this
->clickLink(t('Preview'));
$this
->assertResponse(404);
// Assert translation message for the non-existing translated entity.
$this
->drupalPostForm($review_url, [
'title|0|value[translation]' => 'test_translation',
], t('Save'));
$this
->assertText(t('The translation has been saved successfully.'));
// Create translatable node.
$node = $this
->createTranslatableNode('page', 'en');
$job = $this
->createJob('en', 'de');
$job->translator = $this->default_translator
->id();
$job->settings->action = 'submit';
$job
->save();
$job_item = tmgmt_job_item_create('content', $node
->getEntityTypeId(), $node
->id(), array(
'tjid' => $job
->id(),
));
$job_item
->save();
// At this point job is state 0 (STATE_UNPROCESSED) or "cart job", we don't
// want a preview link available.
$this
->drupalGet(URL::fromRoute('entity.tmgmt_job_item.canonical', [
'tmgmt_job_item' => $job
->id(),
])
->setAbsolute()
->toString());
$this
->assertNoLink(t('Preview'));
// Changing job state to active.
$job
->requestTranslation();
// Visit preview route without key.
$this
->drupalGet(URL::fromRoute('tmgmt_content.job_item_preview', [
'tmgmt_job_item' => $job
->id(),
])
->setAbsolute()
->toString());
$this
->assertResponse(403);
// Visit preview by clicking the preview button.
$this
->drupalGet(URL::fromRoute('entity.tmgmt_job_item.canonical', [
'tmgmt_job_item' => $job
->id(),
])
->setAbsolute()
->toString());
$this
->clickLink(t('Preview'));
$this
->assertResponse(200);
// Translate job.
$job->settings->action = 'translate';
$job
->save();
$job
->requestTranslation();
$this
->assertTitle(t("Preview of @title for @target_language | Drupal", [
'@title' => $node
->getTitle(),
'@target_language' => $job
->getTargetLanguage()
->getName(),
]));
// Test if anonymous user can access preview without key.
$this
->drupalLogout();
$this
->drupalGet(URL::fromRoute('tmgmt_content.job_item_preview', [
'tmgmt_job_item' => $job
->id(),
])
->setAbsolute()
->toString());
$this
->assertResponse(403);
// Test if anonymous user can access preview with key.
$key = \Drupal::service('tmgmt_content.key_access')
->getKey($job_item);
$this
->drupalGet(URL::fromRoute('tmgmt_content.job_item_preview', [
'tmgmt_job_item' => $job_item
->id(),
], [
'query' => [
'key' => $key,
],
]));
$this
->assertResponse(200);
$this
->assertTitle(t("Preview of @title for @target_language | Drupal", [
'@title' => $node
->getTitle(),
'@target_language' => $job
->getTargetLanguage()
->getName(),
]));
$this
->loginAsAdmin([
'accept translation jobs',
]);
// Test preview if we edit translation.
$this
->drupalGet('admin/tmgmt/items/' . $job_item
->id());
$edit = [
'title|0|value[translation]' => 'de(de-ch): Test title for preview translation from en to de.',
];
$this
->drupalPostForm(NULL, $edit, t('Save'));
$this
->drupalGet('admin/tmgmt/items/' . $job_item
->id());
$this
->clickLink(t('Preview'));
$this
->assertText('de(de-ch): Test title for preview translation from en to de.');
// Test if anonymous user can see also the changes.
$this
->drupalLogout();
$key = \Drupal::service('tmgmt_content.key_access')
->getKey($job_item);
$this
->drupalGet(Url::fromRoute('tmgmt_content.job_item_preview', [
'tmgmt_job_item' => $job_item
->id(),
], [
'query' => [
'key' => $key,
],
]));
$this
->assertResponse(200);
$this
->assertText('de(de-ch): Test title for preview translation from en to de.');
$items = $job
->getItems();
$item = reset($items);
$item
->acceptTranslation();
// There should be no link if the job item is accepted.
$this
->drupalGet('admin/tmgmt/items/' . $node
->id(), array(
'query' => array(
'destination' => 'admin/tmgmt/items/' . $node
->id(),
),
));
$this
->assertNoLink(t('Preview'));
}
/**
* Test content entity source anonymous access.
*/
public function testEntitySourceAnonymousAccess() {
// Create translatable node.
$node = $this
->createTranslatableNode('page', 'en');
$job = $this
->createJob('en', 'de');
$job->translator = $this->default_translator
->id();
$job
->save();
$job_item = tmgmt_job_item_create('content', $node
->getEntityTypeId(), $node
->id(), array(
'tjid' => $job
->id(),
));
$job_item
->save();
// Anonymous view of content entities.
$node
->setUnpublished();
$node
->save();
$this
->drupalLogout();
$url = $job_item
->getSourceUrl();
$this
->drupalGet($url);
$this
->assertResponse(200);
\Drupal::configFactory()
->getEditable('tmgmt.settings')
->set('anonymous_access', FALSE)
->save();
$this
->drupalGet($url);
$this
->assertResponse(403);
\Drupal::configFactory()
->getEditable('tmgmt.settings')
->set('anonymous_access', TRUE)
->save();
$this
->drupalGet($url);
$this
->assertResponse(200);
$job
->aborted();
$this
->drupalGet($url);
$this
->assertResponse(403);
}
/**
* Test the handling existing content with continuous jobs.
*/
public function testSourceOverview() {
// Create translatable node.
$node = $this
->createTranslatableNode('article', 'en');
$this
->drupalGet('admin/tmgmt/sources');
$this
->assertText($node
->getTitle());
// Test that there are no "Add to continuous jobs" button and checkbox.
$this
->assertSession()
->elementNotExists('css', '#edit-add-to-continuous-jobs');
$this
->assertSession()
->elementNotExists('css', '#edit-add-all-to-continuous-jobs');
// Create two additional nodes.
$this
->createTranslatableNode('article', 'en');
$this
->createTranslatableNode('article', 'en');
// Continuous settings configuration.
$continuous_settings = [
'content' => [
'node' => [
'enabled' => 1,
'bundles' => [
'article' => 1,
'page' => 0,
],
],
],
];
// Create continuous job.
$continuous_job = $this
->createJob('en', 'de', 0, [
'label' => 'Continuous job',
'job_type' => 'continuous',
'continuous_settings' => $continuous_settings,
'translator' => $this->default_translator
->id(),
]);
// Test that there is now "Add to continuous jobs" button and checkbox.
$this
->drupalGet('admin/tmgmt/sources');
$this
->assertSession()
->elementExists('css', '#edit-add-to-continuous-jobs');
$this
->assertSession()
->elementExists('css', '#edit-add-all-to-continuous-jobs');
// Select node for adding to continuous job.
$edit = [
'items[' . $node
->id() . ']' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Check for continuous jobs'));
$this
->assertUniqueText(t("1 continuous job item has been created."));
$items = $continuous_job
->getItems();
$item = reset($items);
$this
->assertLinkByHref('admin/tmgmt/items/' . $item
->id());
// Test that continuous job item is created for selected node.
$continuous_job_items = $continuous_job
->getItems();
$continuous_job_item = reset($continuous_job_items);
$this
->assertEqual($node
->label(), $continuous_job_item
->label(), 'Continuous job item is created for selected node.');
// Create another translatable node.
$second_node = $this
->createTranslatableNode('page', 'en');
$this
->drupalGet('admin/tmgmt/sources');
$this
->assertText($second_node
->getTitle());
// Select second node for adding to continuous job.
$second_edit = [
'items[' . $second_node
->id() . ']' => TRUE,
];
$this
->drupalPostForm(NULL, $second_edit, t('Check for continuous jobs'));
$this
->assertUniqueText(t("None of the selected sources can be added to continuous jobs."));
// Test that no new job items are created.
$this
->assertEqual(count($continuous_job
->getItems()), 1, 'There are no new job items for selected node.');
$this
->drupalGet('admin/tmgmt/sources');
// Select all nodes for adding to continuous job.
$add_all_edit = [
'add_all_to_continuous_jobs' => TRUE,
];
$this
->drupalPostForm(NULL, $add_all_edit, t('Check for continuous jobs'));
$this
->assertUniqueText(t("2 continuous job items have been created."));
// Test that two new job items are created.
$this
->assertEqual(count($continuous_job
->getItems()), 3, 'There are two new job items for selected nodes.');
$this
->drupalGet('admin/tmgmt/sources');
// Select all nodes for adding to continuous job.
$add_all_edit = [
'add_all_to_continuous_jobs' => TRUE,
];
$this
->drupalPostForm(NULL, $add_all_edit, t('Check for continuous jobs'));
$this
->assertUniqueText(t("None of the selected sources can be added to continuous jobs."));
// Test that no new job items are created.
$this
->assertEqual(count($continuous_job
->getItems()), 3, 'There are no new job items for selected nodes.');
}
/**
* Test content entity source preview.
*/
public function testSourceUpdate() {
// Create translatable node.
$node = $this
->createTranslatableNode('article', 'en');
$job = $this
->createJob('en', 'de');
$job
->save();
$job_item = tmgmt_job_item_create('content', $node
->getEntityTypeId(), $node
->id(), array(
'tjid' => $job
->id(),
));
$job_item
->save();
$updated_body = 'New body';
$edit = [
'body[0][value]' => $updated_body,
];
$this
->drupalPostForm('node/' . $node
->id() . '/edit', $edit, 'Save');
$this
->drupalGet('admin/tmgmt/items/' . $job_item
->id());
$this
->assertText($updated_body, 'Source updated correctly.');
}
/**
* Test consider field sequences.
*/
public function testConsiderFieldSequences() {
$this
->createNodeType('article1', 'Article 1', TRUE, FALSE);
for ($i = 0; $i <= 5; $i++) {
// Create a field.
$field_storage = FieldStorageConfig::create(array(
'field_name' => 'field_' . $i,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => mt_rand(1, 5),
'translatable' => TRUE,
));
$field_storage
->save();
// Create an instance of the previously created field.
$field = FieldConfig::create(array(
'field_name' => 'field_' . $i,
'entity_type' => 'node',
'bundle' => 'article1',
'label' => 'Field' . $i,
'description' => $this
->randomString(30),
'widget' => array(
'type' => 'text',
'label' => $this
->randomString(10),
),
));
$field
->save();
$this->field_names['node']['article1'][] = 'field_' . $i;
}
$node = $this
->createTranslatableNode('article1', 'en');
\Drupal::service('entity_display.repository')
->getFormDisplay('node', 'article1', 'default')
->setComponent('body', array(
'type' => 'text_textarea_with_summary',
'weight' => 0,
))
->setComponent('title', array(
'type' => 'string_textfield',
'weight' => 1,
))
->setComponent('field_1', array(
'type' => 'string_textfield',
'weight' => 2,
))
->setComponent('field_2', array(
'type' => 'string_textfield',
'weight' => 5,
))
->setComponent('field_0', array(
'type' => 'string_textfield',
'weight' => 6,
))
->setComponent('field_4', array(
'type' => 'string_textfield',
'weight' => 7,
))
->save();
$job = $this
->createJob('en', 'de');
$job->translator = $this->default_translator
->id();
$job
->addItem('content', $node
->getEntityTypeId(), $node
->id());
$job
->save();
$job
->requestTranslation();
// Visit job item review page.
$this
->drupalGet(URL::fromRoute('entity.tmgmt_job_item.canonical', [
'tmgmt_job_item' => $node
->id(),
]));
$review_elements = $this
->xpath('//*[@id="edit-review"]/div');
$ids = [];
foreach ($review_elements as $review_element) {
$ids[] = $review_element
->getAttribute('id');
}
// Check are fields showing on page in desired order. Field 3 and 5 have
// no weight set and are expected to be ordered alphabetically, at the end.
$this
->assertEqual($ids[0], 'tmgmt-ui-element-body-wrapper');
$this
->assertEqual($ids[1], 'tmgmt-ui-element-title-wrapper');
$this
->assertEqual($ids[2], 'tmgmt-ui-element-field-1-wrapper');
$this
->assertEqual($ids[3], 'tmgmt-ui-element-field-2-wrapper');
$this
->assertEqual($ids[4], 'tmgmt-ui-element-field-0-wrapper');
$this
->assertEqual($ids[5], 'tmgmt-ui-element-field-4-wrapper');
$this
->assertEqual($ids[6], 'tmgmt-ui-element-field-3-wrapper');
$this
->assertEqual($ids[7], 'tmgmt-ui-element-field-5-wrapper');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was present in the last response. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is not present. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is present. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertLegacyTrait:: |
protected | function | Checks that current response header equals value. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was absent in the last response. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text is not found escaped on the loaded page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does NOT exist with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option does NOT exist in the current page. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is not found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS not found on the loaded page, fail otherwise. | 1 |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | 1 |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | 1 |
AssertLegacyTrait:: |
protected | function | Asserts the page responds with the specified response code. | 1 |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | 1 |
AssertLegacyTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertLegacyTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Passes if the internal browser's URL matches the given path. | |
AssertLegacyTrait:: |
protected | function | Builds an XPath query. | |
AssertLegacyTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertLegacyTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertLegacyTrait:: |
protected | function | Gets the current raw content. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
BlockCreationTrait:: |
protected | function | Creates a block instance based on default settings. Aliased as: drupalPlaceBlock | |
BrowserHtmlDebugTrait:: |
protected | property | The Base URI to use for links to the output files. | |
BrowserHtmlDebugTrait:: |
protected | property | Class name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter storage for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Directory name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output output enabled. | |
BrowserHtmlDebugTrait:: |
protected | property | The file name to write the list of URLs to. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output test ID. | |
BrowserHtmlDebugTrait:: |
protected | function | Formats HTTP headers as string for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | function | Returns headers in HTML output format. | 1 |
BrowserHtmlDebugTrait:: |
protected | function | Logs a HTML output message in a text file. | |
BrowserHtmlDebugTrait:: |
protected | function | Creates the directory to store browser output. | |
BrowserTestBase:: |
protected | property | The base URL. | |
BrowserTestBase:: |
protected | property | The config importer that can be used in a test. | |
BrowserTestBase:: |
protected | property | An array of custom translations suitable for drupal_rewrite_settings(). | |
BrowserTestBase:: |
protected | property | The database prefix of this test run. | |
BrowserTestBase:: |
protected | property | Mink session manager. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | 1 | |
BrowserTestBase:: |
protected | property | The original container. | |
BrowserTestBase:: |
protected | property | The original array of shutdown function callbacks. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | The profile to install as a basis for testing. | 39 |
BrowserTestBase:: |
protected | property | The app root. | |
BrowserTestBase:: |
protected | property | Browser tests are run in separate processes to prevent collisions between code that may be loaded by tests. | |
BrowserTestBase:: |
protected | property | Time limit in seconds for the test. | |
BrowserTestBase:: |
protected | property | The translation file directory for the test environment. | |
BrowserTestBase:: |
protected | function | Clean up the Simpletest environment. | |
BrowserTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
BrowserTestBase:: |
protected | function | Translates a CSS expression to its XPath equivalent. | |
BrowserTestBase:: |
protected | function | Gets the value of an HTTP response header. | |
BrowserTestBase:: |
protected | function | Returns all response headers. | |
BrowserTestBase:: |
public static | function | Ensures test files are deletable. | |
BrowserTestBase:: |
protected | function | Gets an instance of the default Mink driver. | |
BrowserTestBase:: |
protected | function | Gets the JavaScript drupalSettings variable for the currently-loaded page. | 1 |
BrowserTestBase:: |
protected | function | Obtain the HTTP client for the system under test. | |
BrowserTestBase:: |
protected | function | Get the Mink driver args from an environment variable, if it is set. Can be overridden in a derived class so it is possible to use a different value for a subset of tests, e.g. the JavaScript tests. | 1 |
BrowserTestBase:: |
protected | function | Helper function to get the options of select field. | |
BrowserTestBase:: |
protected | function |
Provides a Guzzle middleware handler to log every response received. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
public | function | Returns Mink session. | |
BrowserTestBase:: |
protected | function | Get session cookies from current session. | |
BrowserTestBase:: |
protected | function |
Retrieves the current calling line in the class under test. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
protected | function | Visits the front page when initializing Mink. | 3 |
BrowserTestBase:: |
protected | function | Initializes Mink sessions. | 1 |
BrowserTestBase:: |
public | function | Installs Drupal into the Simpletest site. | 1 |
BrowserTestBase:: |
protected | function | Registers additional Mink sessions. | |
BrowserTestBase:: |
protected | function | 3 | |
BrowserTestBase:: |
protected | function | Transforms a nested array into a flat array suitable for drupalPostForm(). | |
BrowserTestBase:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
BrowserTestBase:: |
public | function | 1 | |
BrowserTestBase:: |
public | function | Prevents serializing any properties. | |
CommentTestTrait:: |
public | function | Adds the default comment field to an entity. | |
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
ContentTmgmtEntitySourceUiTest:: |
public static | property |
Modules to enable. Overrides TMGMTTestBase:: |
|
ContentTmgmtEntitySourceUiTest:: |
function |
Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase:: |
||
ContentTmgmtEntitySourceUiTest:: |
function | Test the entity source specific cart functionality. | ||
ContentTmgmtEntitySourceUiTest:: |
function | Test translating comments. | ||
ContentTmgmtEntitySourceUiTest:: |
public | function | Test consider field sequences. | |
ContentTmgmtEntitySourceUiTest:: |
function | Tests the embedded references. | ||
ContentTmgmtEntitySourceUiTest:: |
public | function | Test content entity source anonymous access. | |
ContentTmgmtEntitySourceUiTest:: |
function | Test content entity source preview. | ||
ContentTmgmtEntitySourceUiTest:: |
function | Test the translate tab for a multiple checkout. | ||
ContentTmgmtEntitySourceUiTest:: |
function | Test job submission of multiple jobs with an unsupported language | ||
ContentTmgmtEntitySourceUiTest:: |
function | Test the translate tab for a quick checkout. | ||
ContentTmgmtEntitySourceUiTest:: |
function | Test the translate tab for a single checkout. | ||
ContentTmgmtEntitySourceUiTest:: |
public | function | Test the handling existing content with continuous jobs. | |
ContentTmgmtEntitySourceUiTest:: |
public | function | Test content entity source preview. | |
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. Aliased as: drupalCreateContentType | 1 |
FunctionalTestSetupTrait:: |
protected | property | The flag to set 'apcu_ensure_unique_prefix' setting. | 1 |
FunctionalTestSetupTrait:: |
protected | property | The class loader to use for installation and initialization of setup. | |
FunctionalTestSetupTrait:: |
protected | property | The config directories used in this test. | |
FunctionalTestSetupTrait:: |
protected | property | The "#1" admin user. | |
FunctionalTestSetupTrait:: |
protected | function | Execute the non-interactive installer. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns all supported database driver installer objects. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize various configurations post-installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Initializes the kernel after installation. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize settings created during install. | |
FunctionalTestSetupTrait:: |
protected | function | Initializes user 1 for the site to be installed. | |
FunctionalTestSetupTrait:: |
protected | function | Installs the default theme defined by `static::$defaultTheme` when needed. | |
FunctionalTestSetupTrait:: |
protected | function | Install modules defined by `static::$modules`. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns the parameters that will be used when Simpletest installs Drupal. | 9 |
FunctionalTestSetupTrait:: |
protected | function | Prepares the current environment for running the test. | 23 |
FunctionalTestSetupTrait:: |
protected | function | Creates a mock request and sets it on the generator. | |
FunctionalTestSetupTrait:: |
protected | function | Prepares site settings and services before installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Resets and rebuilds the environment after setup. | |
FunctionalTestSetupTrait:: |
protected | function | Rebuilds \Drupal::getContainer(). | |
FunctionalTestSetupTrait:: |
protected | function | Resets all data structures after having enabled new modules. | |
FunctionalTestSetupTrait:: |
protected | function | Changes parameters in the services.yml file. | |
FunctionalTestSetupTrait:: |
protected | function | Sets up the base URL based upon the environment variable. | |
FunctionalTestSetupTrait:: |
protected | function | Rewrites the settings.php file of the test site. | |
NodeCreationTrait:: |
protected | function | Creates a node based on default settings. Aliased as: drupalCreateNode | |
NodeCreationTrait:: |
public | function | Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
RefreshVariablesTrait:: |
protected | function | Refreshes in-memory configuration and state information. | 3 |
SessionTestTrait:: |
protected | property | The name of the session cookie. | |
SessionTestTrait:: |
protected | function | Generates a session cookie name. | |
SessionTestTrait:: |
protected | function | Returns the session name in use on the child site. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
TestSetupTrait:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
TestSetupTrait:: |
protected | property | The dependency injection container used in the test. | |
TestSetupTrait:: |
protected | property | The DrupalKernel instance used in the test. | |
TestSetupTrait:: |
protected | property | The site directory of the original parent site. | |
TestSetupTrait:: |
protected | property | The private file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The public file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The site directory of this test run. | |
TestSetupTrait:: |
protected | property | Set to TRUE to strict check all configuration saved. | 2 |
TestSetupTrait:: |
protected | property | The temporary file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The test run ID. | |
TestSetupTrait:: |
protected | function | Changes the database connection to the prefixed one. | |
TestSetupTrait:: |
protected | function | Gets the config schema exclusions for this test. | |
TestSetupTrait:: |
public static | function | Returns the database connection to the site running Simpletest. | |
TestSetupTrait:: |
protected | function | Generates a database prefix for running tests. | 2 |
TmgmtEntityTestTrait:: |
public | property | ||
TmgmtEntityTestTrait:: |
function | Creates fields of type text and text_with_summary of different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates node type with several text fields with different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates a taxonomy term of a given vocabulary. | ||
TmgmtEntityTestTrait:: |
function | Creates taxonomy vocabulary with custom fields. | ||
TmgmtEntityTestTrait:: |
protected | function | Creates a node of a given bundle. | |
TMGMTTestBase:: |
protected | property |
The theme to install as the default for testing. Overrides BrowserTestBase:: |
|
TMGMTTestBase:: |
protected | property | A default translator using the test translator. | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | The language weight for new languages. | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsTranslator(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsTranslator(). | |
TmgmtTestTrait:: |
function | Sets the proper environment. | ||
TmgmtTestTrait:: |
function | Asserts job item language codes. | ||
TmgmtTestTrait:: |
protected | function | Asserts text in the page with an xpath expression. | |
TmgmtTestTrait:: |
function | Clicks on an image link with the provided title attribute. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translation job. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translator. | ||
TmgmtTestTrait:: |
function | Will create a user with admin permissions and log it in. | ||
TmgmtTestTrait:: |
function | Will create a user with translator permissions and log it in. | ||
UiHelperTrait:: |
protected | property | The current user logged in using the Mink controlled browser. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects to follow, or NULL if unlimited. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects followed during ::drupalGet(). | |
UiHelperTrait:: |
public | function | Returns WebAssert object. | 1 |
UiHelperTrait:: |
protected | function | Builds an a absolute URL from a system path or a URL object. | |
UiHelperTrait:: |
protected | function | Checks for meta refresh tag and if found call drupalGet() recursively. | |
UiHelperTrait:: |
protected | function | Clicks the element with the given CSS selector. | |
UiHelperTrait:: |
protected | function | Follows a link by complete name. | |
UiHelperTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
UiHelperTrait:: |
protected | function | Retrieves a Drupal path or an absolute path. | 3 |
UiHelperTrait:: |
protected | function | Logs in a user using the Mink controlled browser. | |
UiHelperTrait:: |
protected | function | Logs a user out of the Mink controlled browser and confirms. | |
UiHelperTrait:: |
protected | function | Executes a form submission. | |
UiHelperTrait:: |
protected | function | Returns whether a given user account is logged in. | |
UiHelperTrait:: |
protected | function | Takes a path and returns an absolute path. | |
UiHelperTrait:: |
protected | function | Retrieves the plain-text content from the current page. | |
UiHelperTrait:: |
protected | function | Get the current URL from the browser. | |
UiHelperTrait:: |
protected | function | Prepare for a request to testing site. | 1 |
UiHelperTrait:: |
protected | function | Fills and submits a form. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. Aliased as: drupalCreateRole | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. Aliased as: drupalCreateUser | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. | |
XdebugRequestTrait:: |
protected | function | Adds xdebug cookies, from request setup. |