Skip to content
Snippets Groups Projects
Commit b7108da7 authored by Shivam Tiwari's avatar Shivam Tiwari
Browse files

Removed deprecated code

parent 9a86ea1d
No related branches found
No related tags found
1 merge request!80Removed deprecated code
......@@ -27,7 +27,7 @@ class ContentModerationTranslationTest extends InlineEntityFormTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->user = $this->createUser([
......@@ -89,22 +89,22 @@ class ContentModerationTranslationTest extends InlineEntityFormTestBase {
$this->drupalGet('node/add/ief_test_complex');
// Reference the German node.
$this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Add existing node" and @data-drupal-selector="edit-multi-actions-ief-add-existing"]'));
$this->submitForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Add existing node" and @data-drupal-selector="edit-multi-actions-ief-add-existing"]'));
$edit = [
'multi[form][entity_id]' => 'An inline node (' . $first_inline_node->id() . ')',
];
$this->drupalPostAjaxForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @data-drupal-selector="edit-multi-form-actions-ief-reference-save"]'));
$this->submitForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @data-drupal-selector="edit-multi-form-actions-ief-reference-save"]'));
$this->assertSession()->statusCodeEquals(200, 'Adding a new referenced entity was successful.');
// Add a new English inline node.
$this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Add new node" and @data-drupal-selector="edit-multi-actions-ief-add"]'));
$this->submitForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Add new node" and @data-drupal-selector="edit-multi-actions-ief-add"]'));
$edit = [
'multi[form][inline_entity_form][title][0][value]' => 'Another inline node',
'multi[form][inline_entity_form][first_name][0][value]' => 'John',
'multi[form][inline_entity_form][last_name][0][value]' => 'Smith',
'multi[form][inline_entity_form][moderation_state][0][state]' => 'published',
];
$this->drupalPostAjaxForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @value="Create node" and @data-drupal-selector="edit-multi-form-inline-entity-form-actions-ief-add-save"]'));
$this->submitForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @value="Create node" and @data-drupal-selector="edit-multi-form-inline-entity-form-actions-ief-add-save"]'));
$this->assertSession()->statusCodeEquals(200, 'Creating a new inline entity was successful.');
$edit = [
......@@ -139,7 +139,7 @@ class ContentModerationTranslationTest extends InlineEntityFormTestBase {
$this->drupalGet('node/' . $node->id() . '/translations/add/de/fr');
// Confirm that IEF field is accessible on translation page.
$this->assertTrue((bool) $this->xpath('//fieldset[@id="edit-multi"]/legend/span'), 'IEF field is present in the node translation form');
$this->assertNotEmpty((bool) $this->xpath('//fieldset[@id="edit-multi"]/legend/span'), 'IEF field is present in the node translation form');
// Confirm that the translatability clue has been removed.
$widget_title_element = $this->xpath('//fieldset[@id="edit-multi"]/legend/span');
$this->assertEquals((string) $widget_title_element[0], 'Multiple nodes', 'The widget has the expected title.');
......@@ -147,24 +147,24 @@ class ContentModerationTranslationTest extends InlineEntityFormTestBase {
$this->assertFalse((bool) $this->xpath('//input[@type="submit" and @value="Add new node" and @data-drupal-selector="edit-multi-actions-ief-add"]'), 'Add new node button does not appear in the table.');
$this->assertFalse((bool) $this->xpath('//input[@type="submit" and @value="Remove"]'), 'Remove button does not appear in the table.');
// Confirm the presence of the two node titles, in the expected languages.
$this->assertTrue((bool) $this->xpath('//td[@class="inline-entity-form-node-label" and contains(.,"An inline node in French")]'), 'First inline node title appears in the table');
$this->assertTrue((bool) $this->xpath('//td[@class="inline-entity-form-node-label" and contains(.,"Another inline node")]'), 'Second node title appears in the table');
$this->assertNotEmpty((bool) $this->xpath('//td[@class="inline-entity-form-node-label" and contains(.,"An inline node in French")]'), 'First inline node title appears in the table');
$this->assertNotEmpty((bool) $this->xpath('//td[@class="inline-entity-form-node-label" and contains(.,"Another inline node")]'), 'Second node title appears in the table');
// Edit the translations of both inline entities.
$this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Edit" and @data-drupal-selector="edit-multi-entities-0-actions-ief-entity-edit"]'));
$this->submitForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Edit" and @data-drupal-selector="edit-multi-entities-0-actions-ief-entity-edit"]'));
$this->assertSession()->pageTextNotContains('Last name', 'The non-translatable last_name field is hidden.');
$edit = [
'multi[form][inline_entity_form][entities][0][form][title][0][value]' => 'An inline node in French!',
'multi[form][inline_entity_form][entities][0][form][first_name][0][value]' => 'Damien',
];
$this->drupalPostAjaxForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @value="Update node" and @data-drupal-selector="edit-multi-form-inline-entity-form-entities-0-form-actions-ief-edit-save"]'));
$this->submitForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @value="Update node" and @data-drupal-selector="edit-multi-form-inline-entity-form-entities-0-form-actions-ief-edit-save"]'));
$this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Edit" and @data-drupal-selector="edit-multi-entities-1-actions-ief-entity-edit"]'));
$this->submitForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Edit" and @data-drupal-selector="edit-multi-entities-1-actions-ief-entity-edit"]'));
$edit = [
'multi[form][inline_entity_form][entities][1][form][title][0][value]' => 'Another inline node in French!',
'multi[form][inline_entity_form][entities][1][form][first_name][0][value]' => 'Jacques',
];
$this->drupalPostAjaxForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @value="Update node" and @data-drupal-selector="edit-multi-form-inline-entity-form-entities-1-form-actions-ief-edit-save"]'));
$this->submitForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @value="Update node" and @data-drupal-selector="edit-multi-form-inline-entity-form-entities-1-form-actions-ief-edit-save"]'));
$this->submitForm(NULL, [], t('Save (this translation)'));
$this->assertSession()->statusCodeEquals(200, 'Saving the parent entity was successful.');
......@@ -173,8 +173,8 @@ class ContentModerationTranslationTest extends InlineEntityFormTestBase {
$first_inline_node = $this->drupalGetNodeByTitle('An inline node', TRUE);
$second_inline_node = $this->drupalGetNodeByTitle('Another inline node', TRUE);
// Confirm that the expected translated values are present.
$this->assertTrue($first_inline_node->hasTranslation('fr'), 'The first inline entity has a FR translation');
$this->assertTrue($second_inline_node->hasTranslation('fr'), 'The second inline entity has a FR translation');
$this->assertNotEmpty($first_inline_node->hasTranslation('fr'), 'The first inline entity has a FR translation');
$this->assertNotEmpty($second_inline_node->hasTranslation('fr'), 'The second inline entity has a FR translation');
$first_translation = $first_inline_node->getTranslation('fr');
$this->assertEquals($first_translation->title->value, 'An inline node in French!');
$this->assertEquals($first_translation->first_name->value, 'Damien');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment