diff --git a/tests/src/Functional/DiffAdminFormsTest.php b/tests/src/Functional/DiffAdminFormsTest.php index 58a2f3c09fdeeeb98ba6155e5e604180b81c6d44..6416e172fcf21525c1f18485c3031db831399887 100644 --- a/tests/src/Functional/DiffAdminFormsTest.php +++ b/tests/src/Functional/DiffAdminFormsTest.php @@ -67,16 +67,16 @@ class DiffAdminFormsTest extends DiffTestBase { public function testRequirements(): void { \Drupal::moduleHandler()->loadInclude('diff', 'install'); $requirements = \diff_requirements('runtime'); - $this->assertEquals($requirements['html_diff_advanced']['title'], 'Diff'); + $this->assertEquals('Diff', $requirements['html_diff_advanced']['title']); $has_htmlDiffAdvanced = \class_exists('\HtmlDiffAdvanced'); if (!$has_htmlDiffAdvanced) { // The plugin is disabled dependencies are missing. - $this->assertEquals($requirements['html_diff_advanced']['value'], 'Visual inline layout'); + $this->assertEquals('Visual inline layout', $requirements['html_diff_advanced']['value']); } else { // The plugin is enabled by default if dependencies are met. - $this->assertEquals($requirements['html_diff_advanced']['value'], 'Installed correctly'); + $this->assertEquals('Installed correctly', $requirements['html_diff_advanced']['value']); } } @@ -167,7 +167,7 @@ class DiffAdminFormsTest extends DiffTestBase { $this->assertSession()->linkExists('Raw'); $this->assertSession()->linkExists('Strip tags'); $text = $this->xpath('//tbody/tr[4]/td[3]'); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $text[0]->getHtml())), '<p>great_body</p>'); + $this->assertEquals('<p>great_body</p>', \htmlspecialchars_decode(\strip_tags((string) $text[0]->getHtml()))); // Change the settings of the layouts, disable the single column. $edit = [ diff --git a/tests/src/Functional/DiffPluginTest.php b/tests/src/Functional/DiffPluginTest.php index 233fbd8033285baf81a1dbbe6c77a2e6621f882e..345e562408a1ea5fab7282cac4aeb5c6b8b89f3b 100644 --- a/tests/src/Functional/DiffPluginTest.php +++ b/tests/src/Functional/DiffPluginTest.php @@ -196,7 +196,7 @@ class DiffPluginTest extends DiffPluginTestBase { $rows = $this->xpath('//tbody/tr'); $diff_row = $rows[1]->findAll('xpath', '/td'); $this->assertCount(3, $rows); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $diff_row[2]->getHtml())), '<p>body</p>'); + $this->assertEquals('<p>body</p>', \htmlspecialchars_decode(\strip_tags((string) $diff_row[2]->getHtml()))); // Create a new revision and update the body. $edit = [ @@ -216,9 +216,9 @@ class DiffPluginTest extends DiffPluginTestBase { // multiple rows show and all of them, including empty lines, display line // numbers. $this->assertGreaterThan(3, \count($rows)); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $rows[1]->findAll('xpath', '/td')[3]->getHtml())), '1'); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $rows[2]->findAll('xpath', '/td')[3]->getHtml())), '2'); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $rows[3]->findAll('xpath', '/td')[3]->getHtml())), '3'); + $this->assertEquals('1', \htmlspecialchars_decode(\strip_tags((string) $rows[1]->findAll('xpath', '/td')[3]->getHtml()))); + $this->assertEquals('2', \htmlspecialchars_decode(\strip_tags((string) $rows[2]->findAll('xpath', '/td')[3]->getHtml()))); + $this->assertEquals('3', \htmlspecialchars_decode(\strip_tags((string) $rows[3]->findAll('xpath', '/td')[3]->getHtml()))); } } diff --git a/tests/src/Functional/DiffRevisionTest.php b/tests/src/Functional/DiffRevisionTest.php index 39ff16acc0ac68b100c9c190b7f33edc9e467dcf..c56784348b98b51980a8a69dca5e085fa42d7e02 100644 --- a/tests/src/Functional/DiffRevisionTest.php +++ b/tests/src/Functional/DiffRevisionTest.php @@ -102,14 +102,14 @@ class DiffRevisionTest extends DiffTestBase { // Assert the revision comment. $this->assertSession()->responseContains('diff-revision__item-message">Revision 2 comment'); // Assert changes made to the body, text 1 changed to 2. - $this->assertEquals($diff_row[0]->getText(), '1'); - $this->assertEquals($diff_row[1]->getText(), '-'); - $this->assertEquals($diff_row[2]->find('xpath', 'span')->getText(), '1'); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $diff_row[2]->getHtml())), '<p>Revision 1</p>'); - $this->assertEquals($diff_row[3]->getText(), '1'); - $this->assertEquals($diff_row[4]->getText(), '+'); - $this->assertEquals($diff_row[5]->find('xpath', 'span')->getText(), '2'); - $this->assertEquals(\htmlspecialchars_decode((\strip_tags((string) $diff_row[5]->getHtml()))), '<p>Revision 2</p>'); + $this->assertEquals('1', $diff_row[0]->getText()); + $this->assertEquals('-', $diff_row[1]->getText()); + $this->assertEquals('1', $diff_row[2]->find('xpath', 'span')->getText()); + $this->assertEquals('<p>Revision 1</p>', \htmlspecialchars_decode(\strip_tags((string) $diff_row[2]->getHtml()))); + $this->assertEquals('1', $diff_row[3]->getText()); + $this->assertEquals('+', $diff_row[4]->getText()); + $this->assertEquals('2', $diff_row[5]->find('xpath', 'span')->getText()); + $this->assertEquals('<p>Revision 2</p>', \htmlspecialchars_decode((\strip_tags((string) $diff_row[5]->getHtml())))); // Compare the revisions in markdown mode. $this->clickLink('Strip tags'); @@ -124,12 +124,12 @@ class DiffRevisionTest extends DiffTestBase { // Extract the changes. $diff_row = $rows[1]->findAll('xpath', '/td'); // Assert changes made to the body, text 1 changed to 2. - $this->assertEquals($diff_row[0]->getText(), '-'); - $this->assertEquals($diff_row[1]->find('xpath', 'span')->getText(), '1'); - $this->assertEquals(\htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[1]->getHtml()))), 'Revision 1'); - $this->assertEquals($diff_row[2]->getText(), '+'); - $this->assertEquals($diff_row[3]->find('xpath', 'span')->getText(), '2'); - $this->assertEquals(\htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[3]->getHtml()))), 'Revision 2'); + $this->assertEquals('-', $diff_row[0]->getText()); + $this->assertEquals('1', $diff_row[1]->find('xpath', 'span')->getText()); + $this->assertEquals('Revision 1', \htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[1]->getHtml())))); + $this->assertEquals('+', $diff_row[2]->getText()); + $this->assertEquals('2', $diff_row[3]->find('xpath', 'span')->getText()); + $this->assertEquals('Revision 2', \htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[3]->getHtml())))); // Compare the revisions in single column mode. $this->clickLink('Unified fields'); @@ -144,25 +144,25 @@ class DiffRevisionTest extends DiffTestBase { $rows = $this->xpath('//tbody/tr'); $diff_row = $rows[1]->findAll('xpath', '/td'); // Assert changes made to the body, text 1 changed to 2. - $this->assertEquals($diff_row[0]->getText(), '1'); - $this->assertEquals($diff_row[1]->getText(), ''); - $this->assertEquals($diff_row[2]->getText(), '-'); - $this->assertEquals($diff_row[3]->find('xpath', 'span')->getText(), '1'); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $diff_row[3]->getHtml())), '<p>Revision 1</p>'); + $this->assertEquals('1', $diff_row[0]->getText()); + $this->assertEquals('', $diff_row[1]->getText()); + $this->assertEquals('-', $diff_row[2]->getText()); + $this->assertEquals('1', $diff_row[3]->find('xpath', 'span')->getText()); + $this->assertEquals('<p>Revision 1</p>', \htmlspecialchars_decode(\strip_tags((string) $diff_row[3]->getHtml()))); $diff_row = $rows[2]->findAll('xpath', '/td'); - $this->assertEquals($diff_row[0]->getText(), ''); - $this->assertEquals($diff_row[1]->getText(), '1'); - $this->assertEquals($diff_row[2]->getText(), '+'); - $this->assertEquals($diff_row[3]->find('xpath', 'span')->getText(), '2'); - $this->assertEquals(\htmlspecialchars_decode(\strip_tags((string) $diff_row[3]->getHtml())), '<p>Revision 2</p>'); + $this->assertEquals('', $diff_row[0]->getText()); + $this->assertEquals('1', $diff_row[1]->getText()); + $this->assertEquals('+', $diff_row[2]->getText()); + $this->assertEquals('2', $diff_row[3]->find('xpath', 'span')->getText()); + $this->assertEquals('<p>Revision 2</p>', \htmlspecialchars_decode(\strip_tags((string) $diff_row[3]->getHtml()))); $this->assertSession()->pageTextContainsOnce('first_unique_text'); $this->assertSession()->pageTextContainsOnce('second_unique_text'); $diff_row = $rows[3]->findAll('xpath', '/td'); - $this->assertEquals($diff_row[0]->getText(), '2'); - $this->assertEquals($diff_row[1]->getText(), '2'); + $this->assertEquals('2', $diff_row[0]->getText()); + $this->assertEquals('2', $diff_row[1]->getText()); $diff_row = $rows[4]->findAll('xpath', '/td'); - $this->assertEquals($diff_row[0]->getText(), '3'); - $this->assertEquals($diff_row[1]->getText(), '3'); + $this->assertEquals('3', $diff_row[0]->getText()); + $this->assertEquals('3', $diff_row[1]->getText()); $this->clickLink('Strip tags'); // Extract the changes. @@ -171,13 +171,13 @@ class DiffRevisionTest extends DiffTestBase { // Assert changes made to the body, with strip_tags filter and make sure // there are no line numbers. - $this->assertEquals($diff_row[0]->getText(), '-'); - $this->assertEquals($diff_row[1]->find('xpath', 'span')->getText(), '1'); - $this->assertEquals(\htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[1]->getHtml()))), 'Revision 1'); + $this->assertEquals('-', $diff_row[0]->getText()); + $this->assertEquals('1', $diff_row[1]->find('xpath', 'span')->getText()); + $this->assertEquals('Revision 1', \htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[1]->getHtml())))); $diff_row = $rows[2]->findAll('xpath', '/td'); - $this->assertEquals($diff_row[0]->getText(), '+'); - $this->assertEquals($diff_row[1]->find('xpath', 'span')->getText(), '2'); - $this->assertEquals(\htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[1]->getHtml()))), 'Revision 2'); + $this->assertEquals('+', $diff_row[0]->getText()); + $this->assertEquals('2', $diff_row[1]->find('xpath', 'span')->getText()); + $this->assertEquals('Revision 2', \htmlspecialchars_decode(\trim(\strip_tags((string) $diff_row[1]->getHtml())))); $this->drupalGet('node/' . $node->id()); $this->clickLink(\t('Revisions')); @@ -272,7 +272,7 @@ class DiffRevisionTest extends DiffTestBase { // Check that the last revision is not the current one. $this->assertSession()->linkExists('Set as current revision'); $text = $this->xpath('//tbody/tr[2]/td[4]/em'); - $this->assertEquals($text[0]->getText(), 'Current revision'); + $this->assertEquals('Current revision', $text[0]->getText()); // Set the last revision as current. $this->clickLink('Set as current revision'); @@ -282,12 +282,12 @@ class DiffRevisionTest extends DiffTestBase { // With content moderation, the new revision will not be current. // @see https://www.drupal.org/node/2899719 $text = $this->xpath('//tbody/tr[1]/td[4]/div/div/ul/li/a'); - $this->assertEquals($text[0]->getText(), 'Set as current revision'); + $this->assertEquals('Set as current revision', $text[0]->getText()); } else { // Check the last revision is set as current. $text = $this->xpath('//tbody/tr[1]/td[4]/em'); - $this->assertEquals($text[0]->getText(), 'Current revision'); + $this->assertEquals('Current revision', $text[0]->getText()); $this->assertSession()->linkNotExists('Set as current revision'); } diff --git a/tests/src/FunctionalJavascript/DiffLocaleTest.php b/tests/src/FunctionalJavascript/DiffLocaleTest.php index 86c3a26d3e0fbb685f0a5d8320837bd0258e8460..aba27be8427454aa77625ae7f431d4e9e95a3a1d 100644 --- a/tests/src/FunctionalJavascript/DiffLocaleTest.php +++ b/tests/src/FunctionalJavascript/DiffLocaleTest.php @@ -156,14 +156,14 @@ class DiffLocaleTest extends DiffTestBase { // Compare first two revisions. $this->drupalGet('node/' . $node->id() . '/revisions/view/' . $revision1 . '/' . $revision2 . '/split_fields'); $diffs = $this->getSession()->getPage()->findAll('xpath', '//span[@class="diffchange"]'); - $this->assertEquals($diffs[0]->getText(), 'english_revision_0'); - $this->assertEquals($diffs[1]->getText(), 'english_revision_1'); + $this->assertEquals('english_revision_0', $diffs[0]->getText()); + $this->assertEquals('english_revision_1', $diffs[1]->getText()); // Check next difference. $this->clickLink('Next change'); $diffs = $this->getSession()->getPage()->findAll('xpath', '//span[@class="diffchange"]'); - $this->assertEquals($diffs[0]->getText(), 'english_revision_1'); - $this->assertEquals($diffs[1]->getText(), 'english_revision_2'); + $this->assertEquals('english_revision_1', $diffs[0]->getText()); + $this->assertEquals('english_revision_2', $diffs[1]->getText()); // There shouldn't be other differences in the current language. $this->assertSession()->linkNotExists('Next change'); @@ -171,8 +171,8 @@ class DiffLocaleTest extends DiffTestBase { // Attempt to visit with a valid revision but for the wrong language. $this->drupalGet('node/' . $node->id() . '/revisions/view/' . $revision5 . '/' . $revision1 . '/split_fields'); $diffs = $this->getSession()->getPage()->findAll('xpath', '//span[@class="diffchange"]'); - $this->assertEquals($diffs[0]->getText(), 'english_revision_2'); - $this->assertEquals($diffs[1]->getText(), 'english_revision_0'); + $this->assertEquals('english_revision_2', $diffs[0]->getText()); + $this->assertEquals('english_revision_0', $diffs[1]->getText()); } /** @@ -209,14 +209,14 @@ class DiffLocaleTest extends DiffTestBase { // Compare the first two revisions. $this->drupalGet('node/' . $node->id() . '/revisions/view/' . $revision1 . '/' . $revision2 . '/split_fields'); $diffs = $this->getSession()->getPage()->findAll('xpath', '//span[@class="diffchange"]'); - $this->assertEquals($diffs[0]->getText(), 'undefined_language_revision_0'); - $this->assertEquals($diffs[1]->getText(), 'undefined_language_revision_1'); + $this->assertEquals('undefined_language_revision_0', $diffs[0]->getText()); + $this->assertEquals('undefined_language_revision_1', $diffs[1]->getText()); // Compare the next two revisions. $this->clickLink('Next change'); $diffs = $this->getSession()->getPage()->findAll('xpath', '//span[@class="diffchange"]'); - $this->assertEquals($diffs[0]->getText(), 'undefined_language_revision_1'); - $this->assertEquals($diffs[1]->getText(), 'undefined_language_revision_2'); + $this->assertEquals('undefined_language_revision_1', $diffs[0]->getText()); + $this->assertEquals('undefined_language_revision_2', $diffs[1]->getText()); } }