Loading tests/src/Functional/CoreVersionUiTestTrait.php +12 −2 Original line number Diff line number Diff line Loading @@ -21,11 +21,11 @@ trait CoreVersionUiTestTrait { if (!version_compare(\Drupal::VERSION, '8.4', '<')) { // Check for translations. if (strpos($submit, 'translation') !== FALSE) { $submit = t('Save (this translation)'); $submit = 'Save (this translation)'; } else { // Form button is back to simply 'Save'. $submit = t('Save'); $submit = 'Save'; } // Check the publish checkbox. Loading @@ -36,4 +36,14 @@ trait CoreVersionUiTestTrait { $this->drupalPostForm($path, $edit, $submit); } protected function drupalPostForm($path, $edit, $submit, array $options = [], $form_html_id = NULL) { if (isset($path)) { $this->drupalGet($path, $options); } $this->submitForm($edit, $submit, $form_html_id); return $this->getSession()->getPage()->getContent(); } } tests/src/Functional/DiffAdminFormsTest.php +62 −58 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ class DiffAdminFormsTest extends DiffTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $this->drupalLogin($this->rootUser); Loading @@ -37,10 +37,10 @@ class DiffAdminFormsTest extends DiffTestBase { $this->drupalGet('admin/config/content/diff/general'); // Check the settings introduction text. $this->assertText('Configurations for the revision comparison functionality and diff layout plugins.'); $this->assertSession()->pageTextContains('Configurations for the revision comparison functionality and diff layout plugins.'); // Check the layout plugins descriptions. $this->assertText('Field based layout, displays revision comparison side by side.'); $this->assertText('Field based layout, displays revision comparison line by line.'); $this->assertSession()->pageTextContains('Field based layout, displays revision comparison side by side.'); $this->assertSession()->pageTextContains('Field based layout, displays revision comparison line by line.'); } /** Loading @@ -52,8 +52,9 @@ class DiffAdminFormsTest extends DiffTestBase { 'context_lines_leading' => 10, 'context_lines_trailing' => 5, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->assertText('The configuration options have been saved.'); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); $this->assertSession()->pageTextContains('The configuration options have been saved.'); } /** Loading @@ -62,16 +63,16 @@ class DiffAdminFormsTest extends DiffTestBase { public function testRequirements() { module_load_install('diff'); $requirements = diff_requirements('runtime'); $this->assertEqual($requirements['html_diff_advanced']['title'], 'Diff'); $this->assertEquals($requirements['html_diff_advanced']['title'], 'Diff'); $has_htmlDiffAdvanced = class_exists('\HtmlDiffAdvanced'); if (!$has_htmlDiffAdvanced) { // The plugin is disabled dependencies are missing. $this->assertEqual($requirements['html_diff_advanced']['value'], 'Visual inline layout'); $this->assertEquals($requirements['html_diff_advanced']['value'], 'Visual inline layout'); } else { // The plugin is enabled by default if dependencies are met. $this->assertEqual($requirements['html_diff_advanced']['value'], 'Installed correctly'); $this->assertEquals($requirements['html_diff_advanced']['value'], 'Installed correctly'); } } Loading @@ -85,55 +86,55 @@ class DiffAdminFormsTest extends DiffTestBase { $edit = [ 'fields[node__body][plugin][type]' => 'text_summary_field_diff_builder', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertFieldByName('fields[node__body][plugin][type]', 'text_summary_field_diff_builder'); $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('fields[node__body][plugin][type]', 'text_summary_field_diff_builder'); $edit = [ 'fields[node__body][plugin][type]' => 'text_field_diff_builder', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertFieldByName('fields[node__body][plugin][type]', 'text_field_diff_builder'); $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('fields[node__body][plugin][type]', 'text_field_diff_builder'); $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertText('Plugin settings: Text'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->pageTextContains('Plugin settings: Text'); $edit = [ 'fields[node__body][settings_edit_form][settings][show_header]' => TRUE, 'fields[node__body][settings_edit_form][settings][compare_format]' => FALSE, 'fields[node__body][settings_edit_form][settings][markdown]' => 'filter_xss_all', ]; $this->drupalPostForm(NULL, $edit, 'node__body_plugin_settings_update'); $this->drupalPostForm(NULL, [], t('Save')); $this->assertText('Your settings have been saved.'); $this->submitForm($edit, 'node__body_plugin_settings_update'); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); // Check the values were saved. $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertFieldByName('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); // Edit another field. $this->drupalPostForm(NULL, [], 'node__title_settings_edit'); $this->submitForm([], 'node__title_settings_edit'); $edit = [ 'fields[node__title][settings_edit_form][settings][markdown]' => 'filter_xss_all', ]; $this->drupalPostForm(NULL, $edit, 'node__title_plugin_settings_update'); $this->drupalPostForm(NULL, [], t('Save')); $this->submitForm($edit, 'node__title_plugin_settings_update'); $this->submitForm([], 'Save'); // Check both fields and their config values. $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertFieldByName('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->drupalPostForm(NULL, [], 'node__title_settings_edit'); $this->assertFieldByName('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__title_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); // Save field settings without changing anything and assert the config. $this->drupalPostForm(NULL, [], t('Save')); $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertFieldByName('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->drupalPostForm(NULL, [], 'node__title_settings_edit'); $this->assertFieldByName('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'Save'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__title_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); $edit = [ 'fields[node__sticky][plugin][type]' => 'hidden', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertFieldByName('fields[node__sticky][plugin][type]', 'hidden'); $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('fields[node__sticky][plugin][type]', 'hidden'); } /** Loading @@ -145,41 +146,42 @@ class DiffAdminFormsTest extends DiffTestBase { 'title[0][value]' => 'great_title', 'body[0][value]' => '<p>great_body</p>', ]; $this->drupalPostNodeForm('node/add/article', $edit, t('Save and publish')); $this->drupalPostNodeForm('node/add/article', $edit, 'Save and publish'); $this->clickLink('Edit'); $edit = [ 'title[0][value]' => 'greater_title', 'body[0][value]' => '<p>greater_body</p>', ]; $this->drupalPostNodeForm(NULL, $edit, t('Save and keep published')); $this->drupalPostNodeForm(NULL, $edit, 'Save and keep published'); // Assert the diff display uses the classic layout. $node = $this->getNodeByTitle('greater_title'); $this->drupalGet('node/' . $node->id() . '/revisions'); $this->drupalPostForm(NULL, [], t('Compare selected revisions')); $this->assertLink('Unified fields'); $this->assertLink('Split fields'); $this->assertLink('Raw'); $this->assertLink('Strip tags'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->linkExists('Unified fields'); $this->assertSession()->linkExists('Split fields'); $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $text = $this->xpath('//tbody/tr[4]/td[3]'); $this->assertEqual(htmlspecialchars_decode(strip_tags($text[0]->getHtml())), '<p>great_body</p>'); $this->assertEquals(htmlspecialchars_decode(strip_tags($text[0]->getHtml())), '<p>great_body</p>'); // Change the settings of the layouts, disable the single column. $edit = [ 'layout_plugins[split_fields][weight]' => '11', 'layout_plugins[unified_fields][enabled]' => FALSE, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); // Assert the diff display uses the markdown layout. $this->drupalGet('node/' . $node->id() . '/revisions'); $this->drupalPostForm(NULL, [], t('Compare selected revisions')); $this->assertResponse(200); $this->assertNoLink('Unified fields'); $this->assertLink('Split fields'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->linkNotExists('Unified fields'); $this->assertSession()->linkExists('Split fields'); $this->clickLink('Split fields'); $this->assertLink('Raw'); $this->assertLink('Strip tags'); $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $this->clickLink('Strip tags'); $assert_session = $this->assertSession(); $assert_session->elementContains('css', 'tr:nth-child(4) td:nth-child(2)', 'great_body'); Loading @@ -189,24 +191,26 @@ class DiffAdminFormsTest extends DiffTestBase { 'layout_plugins[unified_fields][enabled]' => TRUE, 'layout_plugins[split_fields][enabled]' => FALSE, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); // Test the validation of form. $edit = [ 'layout_plugins[unified_fields][enabled]' => FALSE, 'layout_plugins[split_fields][enabled]' => FALSE, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->assertText('At least one layout plugin needs to be enabled.'); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); $this->assertSession()->pageTextContains('At least one layout plugin needs to be enabled.'); // Assert the diff display uses the single column layout. $this->drupalGet('node/' . $node->id() . '/revisions'); $this->drupalPostForm(NULL, [], t('Compare selected revisions')); $this->assertResponse(200); $this->assertLink('Unified fields'); $this->assertNoLink('Split fields'); $this->assertLink('Raw'); $this->assertLink('Strip tags'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->linkExists('Unified fields'); $this->assertSession()->linkNotExists('Split fields'); $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $assert_session->elementTextContains('css', 'tr:nth-child(5) td:nth-child(4)', '<p>great_body</p>'); $this->clickLink('Strip tags'); $assert_session->elementContains('css', 'tr:nth-child(5) td:nth-child(2)', 'great_body'); Loading tests/src/Functional/DiffControllerTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class DiffControllerTest extends BrowserTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $this->config('diff.settings') ->set('entity.entity_test_rev.name', TRUE) Loading tests/src/Functional/DiffPluginEntityTest.php +7 −7 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ class DiffPluginEntityTest extends DiffPluginTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $this->fileSystem = \Drupal::service('file_system'); Loading Loading @@ -76,21 +76,21 @@ class DiffPluginEntityTest extends DiffPluginTestBase { 'field_reference[0][target_id]' => 'Article B (' . $node2->id() . ')', 'revision' => TRUE, ); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, t('Save and keep published')); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, 'Save and keep published'); // Update article A so it points to article C instead of B. $edit = array( 'field_reference[0][target_id]' => 'Article C (' . $node3->id() . ')', 'revision' => TRUE, ); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, t('Save and keep published')); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, 'Save and keep published'); // Check differences between revisions. $this->clickLink(t('Revisions')); $this->drupalPostForm(NULL, NULL, t('Compare selected revisions')); $this->assertText('Reference'); $this->assertText('Article B'); $this->assertText('Article C'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->pageTextContains('Reference'); $this->assertSession()->pageTextContains('Article B'); $this->assertSession()->pageTextContains('Article C'); } } tests/src/Functional/DiffPluginFileTest.php +69 −58 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
tests/src/Functional/CoreVersionUiTestTrait.php +12 −2 Original line number Diff line number Diff line Loading @@ -21,11 +21,11 @@ trait CoreVersionUiTestTrait { if (!version_compare(\Drupal::VERSION, '8.4', '<')) { // Check for translations. if (strpos($submit, 'translation') !== FALSE) { $submit = t('Save (this translation)'); $submit = 'Save (this translation)'; } else { // Form button is back to simply 'Save'. $submit = t('Save'); $submit = 'Save'; } // Check the publish checkbox. Loading @@ -36,4 +36,14 @@ trait CoreVersionUiTestTrait { $this->drupalPostForm($path, $edit, $submit); } protected function drupalPostForm($path, $edit, $submit, array $options = [], $form_html_id = NULL) { if (isset($path)) { $this->drupalGet($path, $options); } $this->submitForm($edit, $submit, $form_html_id); return $this->getSession()->getPage()->getContent(); } }
tests/src/Functional/DiffAdminFormsTest.php +62 −58 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ class DiffAdminFormsTest extends DiffTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $this->drupalLogin($this->rootUser); Loading @@ -37,10 +37,10 @@ class DiffAdminFormsTest extends DiffTestBase { $this->drupalGet('admin/config/content/diff/general'); // Check the settings introduction text. $this->assertText('Configurations for the revision comparison functionality and diff layout plugins.'); $this->assertSession()->pageTextContains('Configurations for the revision comparison functionality and diff layout plugins.'); // Check the layout plugins descriptions. $this->assertText('Field based layout, displays revision comparison side by side.'); $this->assertText('Field based layout, displays revision comparison line by line.'); $this->assertSession()->pageTextContains('Field based layout, displays revision comparison side by side.'); $this->assertSession()->pageTextContains('Field based layout, displays revision comparison line by line.'); } /** Loading @@ -52,8 +52,9 @@ class DiffAdminFormsTest extends DiffTestBase { 'context_lines_leading' => 10, 'context_lines_trailing' => 5, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->assertText('The configuration options have been saved.'); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); $this->assertSession()->pageTextContains('The configuration options have been saved.'); } /** Loading @@ -62,16 +63,16 @@ class DiffAdminFormsTest extends DiffTestBase { public function testRequirements() { module_load_install('diff'); $requirements = diff_requirements('runtime'); $this->assertEqual($requirements['html_diff_advanced']['title'], 'Diff'); $this->assertEquals($requirements['html_diff_advanced']['title'], 'Diff'); $has_htmlDiffAdvanced = class_exists('\HtmlDiffAdvanced'); if (!$has_htmlDiffAdvanced) { // The plugin is disabled dependencies are missing. $this->assertEqual($requirements['html_diff_advanced']['value'], 'Visual inline layout'); $this->assertEquals($requirements['html_diff_advanced']['value'], 'Visual inline layout'); } else { // The plugin is enabled by default if dependencies are met. $this->assertEqual($requirements['html_diff_advanced']['value'], 'Installed correctly'); $this->assertEquals($requirements['html_diff_advanced']['value'], 'Installed correctly'); } } Loading @@ -85,55 +86,55 @@ class DiffAdminFormsTest extends DiffTestBase { $edit = [ 'fields[node__body][plugin][type]' => 'text_summary_field_diff_builder', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertFieldByName('fields[node__body][plugin][type]', 'text_summary_field_diff_builder'); $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('fields[node__body][plugin][type]', 'text_summary_field_diff_builder'); $edit = [ 'fields[node__body][plugin][type]' => 'text_field_diff_builder', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertFieldByName('fields[node__body][plugin][type]', 'text_field_diff_builder'); $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('fields[node__body][plugin][type]', 'text_field_diff_builder'); $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertText('Plugin settings: Text'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->pageTextContains('Plugin settings: Text'); $edit = [ 'fields[node__body][settings_edit_form][settings][show_header]' => TRUE, 'fields[node__body][settings_edit_form][settings][compare_format]' => FALSE, 'fields[node__body][settings_edit_form][settings][markdown]' => 'filter_xss_all', ]; $this->drupalPostForm(NULL, $edit, 'node__body_plugin_settings_update'); $this->drupalPostForm(NULL, [], t('Save')); $this->assertText('Your settings have been saved.'); $this->submitForm($edit, 'node__body_plugin_settings_update'); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); // Check the values were saved. $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertFieldByName('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); // Edit another field. $this->drupalPostForm(NULL, [], 'node__title_settings_edit'); $this->submitForm([], 'node__title_settings_edit'); $edit = [ 'fields[node__title][settings_edit_form][settings][markdown]' => 'filter_xss_all', ]; $this->drupalPostForm(NULL, $edit, 'node__title_plugin_settings_update'); $this->drupalPostForm(NULL, [], t('Save')); $this->submitForm($edit, 'node__title_plugin_settings_update'); $this->submitForm([], 'Save'); // Check both fields and their config values. $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertFieldByName('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->drupalPostForm(NULL, [], 'node__title_settings_edit'); $this->assertFieldByName('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__title_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); // Save field settings without changing anything and assert the config. $this->drupalPostForm(NULL, [], t('Save')); $this->drupalPostForm(NULL, [], 'node__body_settings_edit'); $this->assertFieldByName('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->drupalPostForm(NULL, [], 'node__title_settings_edit'); $this->assertFieldByName('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'Save'); $this->submitForm([], 'node__body_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__body][settings_edit_form][settings][markdown]', 'filter_xss_all'); $this->submitForm([], 'node__title_settings_edit'); $this->assertSession()->fieldValueEquals('fields[node__title][settings_edit_form][settings][markdown]', 'filter_xss_all'); $edit = [ 'fields[node__sticky][plugin][type]' => 'hidden', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertFieldByName('fields[node__sticky][plugin][type]', 'hidden'); $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('fields[node__sticky][plugin][type]', 'hidden'); } /** Loading @@ -145,41 +146,42 @@ class DiffAdminFormsTest extends DiffTestBase { 'title[0][value]' => 'great_title', 'body[0][value]' => '<p>great_body</p>', ]; $this->drupalPostNodeForm('node/add/article', $edit, t('Save and publish')); $this->drupalPostNodeForm('node/add/article', $edit, 'Save and publish'); $this->clickLink('Edit'); $edit = [ 'title[0][value]' => 'greater_title', 'body[0][value]' => '<p>greater_body</p>', ]; $this->drupalPostNodeForm(NULL, $edit, t('Save and keep published')); $this->drupalPostNodeForm(NULL, $edit, 'Save and keep published'); // Assert the diff display uses the classic layout. $node = $this->getNodeByTitle('greater_title'); $this->drupalGet('node/' . $node->id() . '/revisions'); $this->drupalPostForm(NULL, [], t('Compare selected revisions')); $this->assertLink('Unified fields'); $this->assertLink('Split fields'); $this->assertLink('Raw'); $this->assertLink('Strip tags'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->linkExists('Unified fields'); $this->assertSession()->linkExists('Split fields'); $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $text = $this->xpath('//tbody/tr[4]/td[3]'); $this->assertEqual(htmlspecialchars_decode(strip_tags($text[0]->getHtml())), '<p>great_body</p>'); $this->assertEquals(htmlspecialchars_decode(strip_tags($text[0]->getHtml())), '<p>great_body</p>'); // Change the settings of the layouts, disable the single column. $edit = [ 'layout_plugins[split_fields][weight]' => '11', 'layout_plugins[unified_fields][enabled]' => FALSE, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); // Assert the diff display uses the markdown layout. $this->drupalGet('node/' . $node->id() . '/revisions'); $this->drupalPostForm(NULL, [], t('Compare selected revisions')); $this->assertResponse(200); $this->assertNoLink('Unified fields'); $this->assertLink('Split fields'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->linkNotExists('Unified fields'); $this->assertSession()->linkExists('Split fields'); $this->clickLink('Split fields'); $this->assertLink('Raw'); $this->assertLink('Strip tags'); $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $this->clickLink('Strip tags'); $assert_session = $this->assertSession(); $assert_session->elementContains('css', 'tr:nth-child(4) td:nth-child(2)', 'great_body'); Loading @@ -189,24 +191,26 @@ class DiffAdminFormsTest extends DiffTestBase { 'layout_plugins[unified_fields][enabled]' => TRUE, 'layout_plugins[split_fields][enabled]' => FALSE, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); // Test the validation of form. $edit = [ 'layout_plugins[unified_fields][enabled]' => FALSE, 'layout_plugins[split_fields][enabled]' => FALSE, ]; $this->drupalPostForm('admin/config/content/diff/general', $edit, t('Save configuration')); $this->assertText('At least one layout plugin needs to be enabled.'); $this->drupalGet('admin/config/content/diff/general'); $this->submitForm($edit, 'Save configuration'); $this->assertSession()->pageTextContains('At least one layout plugin needs to be enabled.'); // Assert the diff display uses the single column layout. $this->drupalGet('node/' . $node->id() . '/revisions'); $this->drupalPostForm(NULL, [], t('Compare selected revisions')); $this->assertResponse(200); $this->assertLink('Unified fields'); $this->assertNoLink('Split fields'); $this->assertLink('Raw'); $this->assertLink('Strip tags'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->linkExists('Unified fields'); $this->assertSession()->linkNotExists('Split fields'); $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $assert_session->elementTextContains('css', 'tr:nth-child(5) td:nth-child(4)', '<p>great_body</p>'); $this->clickLink('Strip tags'); $assert_session->elementContains('css', 'tr:nth-child(5) td:nth-child(2)', 'great_body'); Loading
tests/src/Functional/DiffControllerTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class DiffControllerTest extends BrowserTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $this->config('diff.settings') ->set('entity.entity_test_rev.name', TRUE) Loading
tests/src/Functional/DiffPluginEntityTest.php +7 −7 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ class DiffPluginEntityTest extends DiffPluginTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $this->fileSystem = \Drupal::service('file_system'); Loading Loading @@ -76,21 +76,21 @@ class DiffPluginEntityTest extends DiffPluginTestBase { 'field_reference[0][target_id]' => 'Article B (' . $node2->id() . ')', 'revision' => TRUE, ); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, t('Save and keep published')); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, 'Save and keep published'); // Update article A so it points to article C instead of B. $edit = array( 'field_reference[0][target_id]' => 'Article C (' . $node3->id() . ')', 'revision' => TRUE, ); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, t('Save and keep published')); $this->drupalPostNodeForm('node/' . $node1->id() . '/edit', $edit, 'Save and keep published'); // Check differences between revisions. $this->clickLink(t('Revisions')); $this->drupalPostForm(NULL, NULL, t('Compare selected revisions')); $this->assertText('Reference'); $this->assertText('Article B'); $this->assertText('Article C'); $this->submitForm([], 'Compare selected revisions'); $this->assertSession()->pageTextContains('Reference'); $this->assertSession()->pageTextContains('Article B'); $this->assertSession()->pageTextContains('Article C'); } }
tests/src/Functional/DiffPluginFileTest.php +69 −58 File changed.Preview size limit exceeded, changes collapsed. Show changes