diff --git a/sources/content/src/Tests/ContentEntitySourceUiTest.php b/sources/content/src/Tests/ContentEntitySourceUiTest.php index acda87e..bec8b9b 100644 --- a/sources/content/src/Tests/ContentEntitySourceUiTest.php +++ b/sources/content/src/Tests/ContentEntitySourceUiTest.php @@ -831,14 +831,6 @@ class ContentEntitySourceUiTest extends EntityTestBase { 'type' => 'string_textfield', 'weight' => 2, )) - ->setComponent('field_5', array( - 'type' => 'string_textfield', - 'weight' => 3, - )) - ->setComponent('field_3', array( - 'type' => 'string_textfield', - 'weight' => 4, - )) ->setComponent('field_2', array( 'type' => 'string_textfield', 'weight' => 5, @@ -862,22 +854,22 @@ class ContentEntitySourceUiTest extends EntityTestBase { // Visit job item review page. $this->drupalGet(URL::fromRoute('entity.tmgmt_job_item.canonical', ['tmgmt_job_item' => $node->id()])); - $edit_review = $this->xpath('//*[@id="edit-review"]'); + $review_elements = $this->xpath('//*[@id="edit-review"]/div'); - $key = 0; $ids = []; - foreach ($edit_review[0]->children() as $child) { - $ids[$key++] = (string) $child['id']; + foreach ($review_elements as $review_element) { + $ids[] = (string) $review_element['id']; } - // Check are fields showing on page in desired order. + // 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-5-wrapper'); - $this->assertEqual($ids[4], 'tmgmt-ui-element-field-3-wrapper'); - $this->assertEqual($ids[5], 'tmgmt-ui-element-field-2-wrapper'); - $this->assertEqual($ids[6], 'tmgmt-ui-element-field-0-wrapper'); - $this->assertEqual($ids[7], 'tmgmt-ui-element-field-4-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'); } } diff --git a/translators/tmgmt_local/src/Tests/LocalTranslatorTest.php b/translators/tmgmt_local/src/Tests/LocalTranslatorTest.php index 59489e4..183129c 100755 --- a/translators/tmgmt_local/src/Tests/LocalTranslatorTest.php +++ b/translators/tmgmt_local/src/Tests/LocalTranslatorTest.php @@ -154,16 +154,26 @@ class LocalTranslatorTest extends LocalTranslatorTestBase { $job = $this->createJob(); $job->translator = $translator->id(); $job->addItem('test_source', 'test', '1'); - \Drupal::state()->set('tmgmt.test_source_data', array( - 'dummy' => array( - 'deep_nesting' => array( + \Drupal::state()->set('tmgmt.test_source_data', [ + 'dummy' => [ + 'deep_nesting' => [ '#text' => file_get_contents(drupal_get_path('module', 'tmgmt') . '/tests/testing_html/sample.html'), '#label' => 'Label for job item with type test and id 2.', '#translate' => TRUE, '#format' => 'basic_html', - ), - ), - )); + ], + ], + 'second' => [ + '#text' => 'second text', + '#label' => 'Second label', + '#translate' => TRUE, + ], + 'third' => [ + '#text' => 'third text', + '#label' => 'Third label', + '#translate' => TRUE, + ], + ]); $job->addItem('test_source', 'test', '2'); $job->save(); @@ -447,6 +457,18 @@ class LocalTranslatorTest extends LocalTranslatorTestBase { $this->drupalGet('translate/items/' . $second_task_item->id()); $xpath = $this->xpath('//*[@id="edit-dummydeep-nesting-translation-format-guidelines"]/div')[0]; $this->assertEqual($xpath[0]->h4[0], t('Basic HTML')); + + // Assert the order of the displayed elements. + $translate_elements = $this->xpath('//*[@id="edit-translation"]/table'); + + $ids = []; + foreach ($translate_elements as $translate_element) { + $ids[] = (string) $translate_element['id']; + } + $this->assertEqual($ids[0], 'tmgmt-local-element-dummy-deep-nesting'); + $this->assertEqual($ids[1], 'tmgmt-local-element-second'); + $this->assertEqual($ids[2], 'tmgmt-local-element-third'); + $edit = array( 'dummy|deep_nesting[translation][value]' => $translation2 = 'German translation of source 2', ); @@ -491,7 +513,11 @@ class LocalTranslatorTest extends LocalTranslatorTestBase { // Mark the second item as completed now. $this->clickLink(t('View')); $this->clickLink(t('Translate')); - $this->drupalPostForm(NULL, array(), t('Save as completed')); + $remaining_translations = [ + 'second[translation]' => 'Third translation', + 'third[translation]' => 'Third translation', + ]; + $this->drupalPostForm(NULL, $remaining_translations, t('Save as completed')); $this->assertText('The translation for ' . $second_task_item->label() . ' has been saved as completed.'); $this->clickLink('View');