Skip to content
Snippets Groups Projects
Commit d70c96a7 authored by Ide Braakman's avatar Ide Braakman Committed by Adam Bramley
Browse files

Issue #3534663 by idebr: Misordered 'assertEquals()' arguments in tests

parent ae96f386
No related branches found
No related tags found
1 merge request!141Issue #3534663: Misordered 'assertEquals()' arguments in tests
Pipeline #552526 failed
......@@ -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 = [
......
......@@ -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())));
}
}
......@@ -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');
}
......
......@@ -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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment