Issue by Spokje, LoMo, ravi.shankar, quietone, mondrake: Some calls to assertEquals have expected/actual parameters reversed

(cherry picked from commit e48dcff470)
merge-requests/820/head
catch 2021-06-21 11:27:34 +01:00
parent 9da6062e81
commit 76a1fb8ece
61 changed files with 198 additions and 199 deletions
core
modules
comment/tests/src/Unit
dblog/tests/src/Functional
field/tests/src/Kernel/Migrate/d7
field_ui/tests/src/FunctionalJavascript
hal/tests/src/Kernel
help_topics/tests/src/Unit
image/tests/src
jsonapi/tests/src/Kernel
language/tests/src/Unit
layout_builder/tests/src
locale/tests/src/Functional
menu_link_content/tests/src/Kernel/Migrate/d7
node/tests/src/Kernel
path_alias/tests/src/Kernel
rest/tests/src/Unit
serialization/tests/src/Kernel
settings_tray/tests/src/FunctionalJavascript
system/tests/src
update/tests/src/Functional
views/tests/src/Unit
views_ui/tests/src/Functional

View File

@ -97,7 +97,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
public function testRead() {
$this->calls_to_fetch = 0;
$results = $this->commentStatistics->read(['1' => 'boo', '2' => 'foo'], 'snafus');
$this->assertEquals($results, ['something', 'something-else']);
$this->assertEquals(['something', 'something-else'], $results);
}
/**

View File

@ -876,9 +876,9 @@ class DbLogTest extends BrowserTestBase {
$this->drupalGet('admin/reports/dblog');
$entries = $this->getLogEntries();
$this->assertEquals($entries[0]['message'], 'Third Entry #0');
$this->assertEquals($entries[1]['message'], 'Second Entry #0');
$this->assertEquals($entries[2]['message'], 'First Entry #0');
$this->assertEquals('Third Entry #0', $entries[0]['message']);
$this->assertEquals('Second Entry #0', $entries[1]['message']);
$this->assertEquals('First Entry #0', $entries[2]['message']);
}
/**

View File

@ -182,10 +182,10 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
}, iterator_to_array($migration->getIdMap()->getMessages()));
sort($errors);
$this->assertCount(4, $errors);
$this->assertEquals($errors[0], 'Can\'t migrate source field field_text_long_plain_filtered configured with both plain text and filtered text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text');
$this->assertEquals($errors[1], 'Can\'t migrate source field field_text_plain_filtered configured with both plain text and filtered text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text');
$this->assertEquals($errors[2], 'Can\'t migrate source field field_text_sum_plain of type text_with_summary configured with plain text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text');
$this->assertEquals($errors[3], 'Can\'t migrate source field field_text_sum_plain_filtered of type text_with_summary configured with plain text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text');
$this->assertEquals('Can\'t migrate source field field_text_long_plain_filtered configured with both plain text and filtered text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text', $errors[0]);
$this->assertEquals('Can\'t migrate source field field_text_plain_filtered configured with both plain text and filtered text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text', $errors[1]);
$this->assertEquals('Can\'t migrate source field field_text_sum_plain of type text_with_summary configured with plain text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text', $errors[2]);
$this->assertEquals('Can\'t migrate source field field_text_sum_plain_filtered of type text_with_summary configured with plain text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text', $errors[3]);
}
}

View File

@ -182,7 +182,7 @@ class ManageDisplayTest extends WebDriverTestBase {
$id = 'node.' . $this->type . '.default';
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
$display = $display_storage->loadUnchanged($id);
$this->assertEquals($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'), 'foo');
$this->assertEquals('foo', $display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'));
$this->assertContains('field_third_party_test', $display->calculateDependencies()->getDependencies()['module'], 'The display has a dependency on field_third_party_test module.');
// Change the formatter to an empty setting and validate it's initialized
@ -329,7 +329,7 @@ class ManageDisplayTest extends WebDriverTestBase {
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */
$display = $form_storage->loadUnchanged('node.' . $this->type . '.default');
$this->assertEquals($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'), 'foo');
$this->assertEquals('foo', $display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'));
$this->assertContains('field_third_party_test', $display->calculateDependencies()->getDependencies()['module'], 'Form display does not have a dependency on field_third_party_test module.');
// Creates a new field that can not be used with the multiple formatter.

View File

@ -937,116 +937,116 @@ www.example.com with a newline in comments -->
public function testHtmlCorrectorFilter() {
// Tag closing.
$f = Html::normalize('<p>text');
$this->assertEquals($f, '<p>text</p>', 'HTML corrector -- tag closing at the end of input.');
$this->assertEquals('<p>text</p>', $f, 'HTML corrector -- tag closing at the end of input.');
$f = Html::normalize('<p>text<p><p>text');
$this->assertEquals($f, '<p>text</p><p></p><p>text</p>', 'HTML corrector -- tag closing.');
$this->assertEquals('<p>text</p><p></p><p>text</p>', $f, 'HTML corrector -- tag closing.');
$f = Html::normalize("<ul><li>e1<li>e2");
$this->assertEquals($f, "<ul><li>e1</li><li>e2</li></ul>", 'HTML corrector -- unclosed list tags.');
$this->assertEquals("<ul><li>e1</li><li>e2</li></ul>", $f, 'HTML corrector -- unclosed list tags.');
$f = Html::normalize('<div id="d">content');
$this->assertEquals($f, '<div id="d">content</div>', 'HTML corrector -- unclosed tag with attribute.');
$this->assertEquals('<div id="d">content</div>', $f, 'HTML corrector -- unclosed tag with attribute.');
// XHTML slash for empty elements.
$f = Html::normalize('<hr><br>');
$this->assertEquals($f, '<hr /><br />', 'HTML corrector -- XHTML closing slash.');
$this->assertEquals('<hr /><br />', $f, 'HTML corrector -- XHTML closing slash.');
$f = Html::normalize('<P>test</P>');
$this->assertEquals($f, '<p>test</p>', 'HTML corrector -- Convert uppercased tags to proper lowercased ones.');
$this->assertEquals('<p>test</p>', $f, 'HTML corrector -- Convert uppercased tags to proper lowercased ones.');
$f = Html::normalize('<P>test</p>');
$this->assertEquals($f, '<p>test</p>', 'HTML corrector -- Convert uppercased tags to proper lowercased ones.');
$this->assertEquals('<p>test</p>', $f, 'HTML corrector -- Convert uppercased tags to proper lowercased ones.');
$f = Html::normalize('test<hr />');
$this->assertEquals($f, 'test<hr />', 'HTML corrector -- Let proper XHTML pass through.');
$this->assertEquals('test<hr />', $f, 'HTML corrector -- Let proper XHTML pass through.');
$f = Html::normalize('test<hr/>');
$this->assertEquals($f, 'test<hr />', 'HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.');
$this->assertEquals('test<hr />', $f, 'HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.');
$f = Html::normalize('test<hr />');
$this->assertEquals($f, 'test<hr />', 'HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.');
$this->assertEquals('test<hr />', $f, 'HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.');
$f = Html::normalize('<span class="test" />');
$this->assertEquals($f, '<span class="test"></span>', 'HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.');
$this->assertEquals('<span class="test"></span>', $f, 'HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.');
$f = Html::normalize('test1<br class="test">test2');
$this->assertEquals($f, 'test1<br class="test" />test2', 'HTML corrector -- Automatically close single tags.');
$this->assertEquals('test1<br class="test" />test2', $f, 'HTML corrector -- Automatically close single tags.');
$f = Html::normalize('line1<hr>line2');
$this->assertEquals($f, 'line1<hr />line2', 'HTML corrector -- Automatically close single tags.');
$this->assertEquals('line1<hr />line2', $f, 'HTML corrector -- Automatically close single tags.');
$f = Html::normalize('line1<HR>line2');
$this->assertEquals($f, 'line1<hr />line2', 'HTML corrector -- Automatically close single tags.');
$this->assertEquals('line1<hr />line2', $f, 'HTML corrector -- Automatically close single tags.');
$f = Html::normalize('<img src="http://example.com/test.jpg">test</img>');
$this->assertEquals($f, '<img src="http://example.com/test.jpg" />test', 'HTML corrector -- Automatically close single tags.');
$this->assertEquals('<img src="http://example.com/test.jpg" />test', $f, 'HTML corrector -- Automatically close single tags.');
$f = Html::normalize('<br></br>');
$this->assertEquals($f, '<br />', "HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY.");
$this->assertEquals('<br />', $f, "HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY.");
$f = Html::normalize('<div></div>');
$this->assertEquals($f, '<div></div>', "HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY.");
$this->assertEquals('<div></div>', $f, "HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY.");
$f = Html::normalize('<p>line1<br/><hr/>line2</p>');
$this->assertEquals($f, '<p>line1<br /></p><hr />line2', 'HTML corrector -- Move non-inline elements outside of inline containers.');
$this->assertEquals('<p>line1<br /></p><hr />line2', $f, 'HTML corrector -- Move non-inline elements outside of inline containers.');
$f = Html::normalize('<p>line1<div>line2</div></p>');
$this->assertEquals($f, '<p>line1</p><div>line2</div>', 'HTML corrector -- Move non-inline elements outside of inline containers.');
$this->assertEquals('<p>line1</p><div>line2</div>', $f, 'HTML corrector -- Move non-inline elements outside of inline containers.');
$f = Html::normalize('<p>test<p>test</p>\n');
$this->assertEquals($f, '<p>test</p><p>test</p>\n', 'HTML corrector -- Auto-close improperly nested tags.');
$this->assertEquals('<p>test</p><p>test</p>\n', $f, 'HTML corrector -- Auto-close improperly nested tags.');
$f = Html::normalize('<p>Line1<br><STRONG>bold stuff</b>');
$this->assertEquals($f, '<p>Line1<br /><strong>bold stuff</strong></p>', 'HTML corrector -- Properly close unclosed tags, and remove useless closing tags.');
$this->assertEquals('<p>Line1<br /><strong>bold stuff</strong></p>', $f, 'HTML corrector -- Properly close unclosed tags, and remove useless closing tags.');
$f = Html::normalize('test <!-- this is a comment -->');
$this->assertEquals($f, 'test <!-- this is a comment -->', 'HTML corrector -- Do not touch HTML comments.');
$this->assertEquals('test <!-- this is a comment -->', $f, 'HTML corrector -- Do not touch HTML comments.');
$f = Html::normalize('test <!--this is a comment-->');
$this->assertEquals($f, 'test <!--this is a comment-->', 'HTML corrector -- Do not touch HTML comments.');
$this->assertEquals('test <!--this is a comment-->', $f, 'HTML corrector -- Do not touch HTML comments.');
$f = Html::normalize('test <!-- comment <p>another
<strong>multiple</strong> line
comment</p> -->');
$this->assertEquals($f, 'test <!-- comment <p>another
$this->assertEquals('test <!-- comment <p>another
<strong>multiple</strong> line
comment</p> -->', 'HTML corrector -- Do not touch HTML comments.');
comment</p> -->', $f, 'HTML corrector -- Do not touch HTML comments.');
$f = Html::normalize('test <!-- comment <p>another comment</p> -->');
$this->assertEquals($f, 'test <!-- comment <p>another comment</p> -->', 'HTML corrector -- Do not touch HTML comments.');
$this->assertEquals('test <!-- comment <p>another comment</p> -->', $f, 'HTML corrector -- Do not touch HTML comments.');
$f = Html::normalize('test <!--break-->');
$this->assertEquals($f, 'test <!--break-->', 'HTML corrector -- Do not touch HTML comments.');
$this->assertEquals('test <!--break-->', $f, 'HTML corrector -- Do not touch HTML comments.');
$f = Html::normalize('<p>test\n</p>\n');
$this->assertEquals($f, '<p>test\n</p>\n', 'HTML corrector -- New-lines are accepted and kept as-is.');
$this->assertEquals('<p>test\n</p>\n', $f, 'HTML corrector -- New-lines are accepted and kept as-is.');
// cSpell:disable
$f = Html::normalize('<p>دروبال');
$this->assertEquals($f, '<p>دروبال</p>', 'HTML corrector -- Encoding is correctly kept.');
$this->assertEquals('<p>دروبال</p>', $f, 'HTML corrector -- Encoding is correctly kept.');
// cSpell:enable
$f = Html::normalize('<script>alert("test")</script>');
$this->assertEquals($f, '<script>
$this->assertEquals('<script>
<!--//--><![CDATA[// ><!--
alert("test")
//--><!]]>
</script>', 'HTML corrector -- CDATA added to script element');
</script>', $f, 'HTML corrector -- CDATA added to script element');
$f = Html::normalize('<p><script>alert("test")</script></p>');
$this->assertEquals($f, '<p><script>
$this->assertEquals('<p><script>
<!--//--><![CDATA[// ><!--
alert("test")
//--><!]]>
</script></p>', 'HTML corrector -- CDATA added to a nested script element');
</script></p>', $f, 'HTML corrector -- CDATA added to a nested script element');
$f = Html::normalize('<p><style> /* Styling */ body {color:red}</style></p>');
$this->assertEquals($f, '<p><style>
$this->assertEquals('<p><style>
<!--/*--><![CDATA[/* ><!--*/
/* Styling */ body {color:red}
/*--><!]]>*/
</style></p>', 'HTML corrector -- CDATA added to a style element.');
</style></p>', $f, 'HTML corrector -- CDATA added to a style element.');
$filtered_data = Html::normalize('<p><style>
/*<![CDATA[*/
@ -1054,7 +1054,7 @@ alert("test")
body {color:red}
/*]]>*/
</style></p>');
$this->assertEquals($filtered_data, '<p><style>
$this->assertEquals('<p><style>
<!--/*--><![CDATA[/* ><!--*/
/*<![CDATA[*/
@ -1063,7 +1063,7 @@ body {color:red}
/*]]]]><![CDATA[>*/
/*--><!]]>*/
</style></p>',
</style></p>', $filtered_data,
new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '/*<![CDATA[*/'])
);
@ -1073,7 +1073,7 @@ body {color:red}
body {color:red}
/*--><!]]>*/
</style></p>');
$this->assertEquals($filtered_data, '<p><style>
$this->assertEquals('<p><style>
<!--/*--><![CDATA[/* ><!--*/
<!--/*--><![CDATA[/* ><!--*/
@ -1082,7 +1082,7 @@ body {color:red}
/*--><!]]]]><![CDATA[>*/
/*--><!]]>*/
</style></p>',
</style></p>', $filtered_data,
new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/'])
);
@ -1091,7 +1091,7 @@ body {color:red}
alert("test");
//--><!]]>
</script></p>');
$this->assertEquals($filtered_data, '<p><script>
$this->assertEquals('<p><script>
<!--//--><![CDATA[// ><!--
<!--//--><![CDATA[// ><!--
@ -1099,7 +1099,7 @@ body {color:red}
//--><!]]]]><![CDATA[>
//--><!]]>
</script></p>',
</script></p>', $filtered_data,
new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '<!--//--><![CDATA[// ><!--'])
);
@ -1108,7 +1108,7 @@ body {color:red}
alert("test");
// ]]>
</script></p>');
$this->assertEquals($filtered_data, '<p><script>
$this->assertEquals('<p><script>
<!--//--><![CDATA[// ><!--
// <![CDATA[
@ -1116,7 +1116,7 @@ body {color:red}
// ]]]]><![CDATA[>
//--><!]]>
</script></p>',
</script></p>', $filtered_data,
new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '// <![CDATA['])
);

View File

@ -26,7 +26,7 @@ class FilterFormatPermissionTest extends MigrateDrupalTestBase {
$reflected_config = new \ReflectionProperty($filterFormatPermissionMigration, 'configuration');
$reflected_config->setAccessible(TRUE);
$config = $reflected_config->getValue($filterFormatPermissionMigration);
$this->assertEquals($config['migration'], 'custom_filter_format');
$this->assertEquals('custom_filter_format', $config['migration']);
}
}

View File

@ -157,7 +157,7 @@ class DenormalizeTest extends NormalizerTestBase {
public function testDenormalizeInvalidCustomSerializedField() {
$entity = EntitySerializedField::create(['serialized_long' => serialize(['Hello world!'])]);
$normalized = $this->serializer->normalize($entity);
$this->assertEquals($normalized['serialized_long'][0]['value'], ['Hello world!']);
$this->assertEquals(['Hello world!'], $normalized['serialized_long'][0]['value']);
$normalized['serialized_long'][0]['value'] = 'boo';
$this->expectException(\LogicException::class);

View File

@ -80,9 +80,9 @@ class HelpTopicTwigTest extends UnitTestCase {
* @covers ::getCacheMaxAge
*/
public function testCacheInfo() {
$this->assertEquals($this->helpTopic->getCacheContexts(), []);
$this->assertEquals($this->helpTopic->getCacheTags(), ['core.extension']);
$this->assertEquals($this->helpTopic->getCacheMaxAge(), Cache::PERMANENT);
$this->assertEquals([], $this->helpTopic->getCacheContexts());
$this->assertEquals(['core.extension'], $this->helpTopic->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $this->helpTopic->getCacheMaxAge());
}
/**

View File

@ -155,7 +155,7 @@ class ImageItemTest extends FieldKernelTestBase {
}
catch (EntityStorageException $exception) {
$this->assertInstanceOf(Warning::class, $exception->getPrevious());
$this->assertEquals($exception->getMessage(), 'Missing file with ID 9999.');
$this->assertEquals('Missing file with ID 9999.', $exception->getMessage());
$this->assertEmpty($entity->image_test->width);
$this->assertEmpty($entity->image_test->height);
}

View File

@ -113,7 +113,7 @@ class ImageStyleTest extends UnitTestCase {
$extensions = ['jpeg', 'gif', 'png'];
foreach ($extensions as $extension) {
$extensionReturned = $image_style->getDerivativeExtension($extension);
$this->assertEquals($extensionReturned, 'png');
$this->assertEquals('png', $extensionReturned);
}
}

View File

@ -253,8 +253,8 @@ class JsonApiDocumentTopLevelNormalizerTest extends JsonapiKernelTestBase {
$normalized = $jsonapi_doc_object->getNormalization();
// @see http://jsonapi.org/format/#document-jsonapi-object
$this->assertEquals($normalized['jsonapi']['version'], '1.0');
$this->assertEquals($normalized['jsonapi']['meta']['links']['self']['href'], 'http://jsonapi.org/format/1.0/');
$this->assertEquals('1.0', $normalized['jsonapi']['version']);
$this->assertEquals('http://jsonapi.org/format/1.0/', $normalized['jsonapi']['meta']['links']['self']['href']);
$this->assertSame($normalized['data']['attributes']['title'], 'dummy_title');
$this->assertEquals($normalized['data']['id'], $this->node->uuid());
@ -338,7 +338,7 @@ class JsonApiDocumentTopLevelNormalizerTest extends JsonapiKernelTestBase {
$normalized = $jsonapi_doc_object->getNormalization();
$this->assertSame($normalized['data']['attributes']['name'], 'user1');
$this->assertEquals($normalized['data']['id'], User::load(1)->uuid());
$this->assertEquals($normalized['data']['type'], 'user--user');
$this->assertEquals('user--user', $normalized['data']['type']);
// Make sure that the cache tags for the includes and the requested entities
// are bubbling as expected.
$this->assertSame(['user:1'], $jsonapi_doc_object->getCacheTags());

View File

@ -383,29 +383,29 @@ class FilterTest extends JsonapiKernelTestBase {
$root = $filter->root();
// Make sure the implicit root group was added.
$this->assertEquals($root->conjunction(), 'AND');
$this->assertEquals('AND', $root->conjunction());
// Ensure the or-group and the and-group were added correctly.
$members = $root->members();
// Ensure the OR group was added.
$or_group = $members[0];
$this->assertEquals($or_group->conjunction(), 'OR');
$this->assertEquals('OR', $or_group->conjunction());
$or_group_members = $or_group->members();
// Make sure the nested OR group was added with the right conditions.
$nested_or_group = $or_group_members[0];
$this->assertEquals($nested_or_group->conjunction(), 'OR');
$this->assertEquals('OR', $nested_or_group->conjunction());
$nested_or_group_members = $nested_or_group->members();
$this->assertEquals($nested_or_group_members[0]->field(), 'field0');
$this->assertEquals($nested_or_group_members[1]->field(), 'field1');
$this->assertEquals('field0', $nested_or_group_members[0]->field());
$this->assertEquals('field1', $nested_or_group_members[1]->field());
// Make sure the nested AND group was added with the right conditions.
$nested_and_group = $or_group_members[1];
$this->assertEquals($nested_and_group->conjunction(), 'AND');
$this->assertEquals('AND', $nested_and_group->conjunction());
$nested_and_group_members = $nested_and_group->members();
$this->assertEquals($nested_and_group_members[0]->field(), 'field2');
$this->assertEquals($nested_and_group_members[1]->field(), 'field3');
$this->assertEquals('field2', $nested_and_group_members[0]->field());
$this->assertEquals('field3', $nested_and_group_members[1]->field());
}
/**

View File

@ -37,8 +37,8 @@ class ConfigurableLanguageUnitTest extends UnitTestCase {
// The weight, an integer. Used to order languages with larger positive
// weights sinking items toward the bottom of lists.
$configurableLanguage = new ConfigurableLanguage(['weight' => -5], 'configurable_language');
$this->assertEquals($configurableLanguage->getWeight(), -5);
$this->assertEquals($configurableLanguage->setWeight(13)->getWeight(), 13);
$this->assertEquals(-5, $configurableLanguage->getWeight());
$this->assertEquals(13, $configurableLanguage->setWeight(13)->getWeight());
}
}

View File

@ -164,7 +164,7 @@ class InlineBlockTest extends InlineBlockTestBase {
$this->assertCount(1, $blocks);
$block = array_pop($blocks);
$this->assertEquals($block->getRevisionId(), $revision_id);
$this->assertEquals($block->get('body')->getValue()[0]['value'], 'The block body');
$this->assertEquals('The block body', $block->get('body')->getValue()[0]['value']);
}
else {
// The block should not be visible.

View File

@ -83,11 +83,11 @@ class LayoutBuilderEntityViewDisplayTest extends SectionStorageTestBase {
// Set Overridable to TRUE and ensure Layout Builder is enabled.
$this->sectionStorage->setOverridable();
$this->assertEquals($this->sectionStorage->isLayoutBuilderEnabled(), TRUE);
$this->assertTrue($this->sectionStorage->isLayoutBuilderEnabled());
// Ensure Layout Builder is still enabled after setting Overridable to FALSE.
$this->sectionStorage->setOverridable(FALSE);
$this->assertEquals($this->sectionStorage->isLayoutBuilderEnabled(), TRUE);
$this->assertTrue($this->sectionStorage->isLayoutBuilderEnabled());
}
}

View File

@ -209,7 +209,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
->countQuery()
->execute()
->fetchField();
$this->assertEquals($count, 6, 'Customized translations successfully imported.');
$this->assertEquals(6, $count, 'Customized translations successfully imported.');
// Try importing a .po file with overriding strings, and ensure existing
// customized strings are kept.

View File

@ -81,7 +81,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
foreach ($tree as $menu_link_tree_element) {
$children += $menu_link_tree_element->hasChildren;
if ($menu_link_tree_element->link->getUrlObject()->toString() == 'http://bing.com') {
$this->assertEquals(reset($menu_link_tree_element->subtree)->link->getUrlObject()->toString(), 'http://google.com');
$this->assertEquals('http://google.com', reset($menu_link_tree_element->subtree)->link->getUrlObject()->toString());
$google_found = TRUE;
}
}

View File

@ -59,7 +59,7 @@ class DownloadFunctionalTest extends BrowserTestBase {
$result = $executable->import();
// Check that the migration has completed.
$this->assertEquals($result, MigrationInterface::RESULT_COMPLETED);
$this->assertEquals(MigrationInterface::RESULT_COMPLETED, $result);
/** @var \Drupal\migrate\Plugin\MigrateIdMapInterface $id_map_plugin */
$id_map_plugin = $migration->getIdMap();

View File

@ -68,7 +68,7 @@ class MigrateBundleTest extends MigrateTestBase {
$term_executable->import();
/** @var \Drupal\taxonomy\Entity\Term $term */
$term = Term::load(1);
$this->assertEquals($term->bundle(), 'categories');
$this->assertEquals('categories', $term->bundle());
}
/**
@ -106,9 +106,9 @@ class MigrateBundleTest extends MigrateTestBase {
$term_executable->import();
/** @var \Drupal\taxonomy\Entity\Term $term */
$term = Term::load(1);
$this->assertEquals($term->bundle(), 'categories');
$this->assertEquals('categories', $term->bundle());
$term = Term::load(2);
$this->assertEquals($term->bundle(), 'tags');
$this->assertEquals('tags', $term->bundle());
}
/**
@ -148,9 +148,9 @@ class MigrateBundleTest extends MigrateTestBase {
$term_executable->import();
/** @var \Drupal\taxonomy\Entity\Term $term */
$term = Term::load(1);
$this->assertEquals($term->bundle(), 'categories');
$this->assertEquals('categories', $term->bundle());
$term = Term::load(2);
$this->assertEquals($term->bundle(), 'tags');
$this->assertEquals('tags', $term->bundle());
}
}

View File

@ -86,7 +86,7 @@ class MigrateSkipRowTest extends KernelTestBase {
$executable = new MigrateExecutable($migration);
$result = $executable->import();
$this->assertEquals($result, MigrationInterface::RESULT_COMPLETED);
$this->assertEquals(MigrationInterface::RESULT_COMPLETED, $result);
$id_map_plugin = $migration->getIdMap();

View File

@ -328,7 +328,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$this->assertEquals($message_default, $message_row->message);
$this->assertEquals(MigrationInterface::MESSAGE_ERROR, $message_row->level);
}
$this->assertEquals($count, 1);
$this->assertEquals(1, $count);
// Retrieve messages with a specific level.
$messages = $id_map->getMessages([], MigrationInterface::MESSAGE_WARNING);
@ -337,7 +337,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$count = 1;
$this->assertEquals(MigrationInterface::MESSAGE_WARNING, $message_row->level);
}
$this->assertEquals($count, 1);
$this->assertEquals(1, $count);
}
/**

View File

@ -56,7 +56,7 @@ class ConfigTest extends UnitTestCase {
->will($this->returnValue($config));
$destination = new Config(['config_name' => 'd8_config'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config']);
$this->assertEquals(['d8_config'], $destination_id);
}
/**
@ -106,7 +106,7 @@ class ConfigTest extends UnitTestCase {
->will($this->returnValue($config));
$destination = new Config(['config_name' => 'd8_config', 'translations' => 'true'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config', 'mi']);
$this->assertEquals(['d8_config', 'mi'], $destination_id);
}
}

View File

@ -53,7 +53,7 @@ class NodeFieldOverridesTest extends EntityKernelTestBase {
$uid_field = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('node')['uid'];
$config = $uid_field->getConfig('ponies');
$config->save();
$this->assertEquals($config->get('default_value_callback'), 'Drupal\node\Entity\Node::getDefaultEntityOwner');
$this->assertEquals('Drupal\node\Entity\Node::getDefaultEntityOwner', $config->get('default_value_callback'));
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create(['type' => 'ponies']);
$owner = $node->getOwner();

View File

@ -194,7 +194,7 @@ class AliasTest extends KernelTestBase {
// Destruct the whitelist so it persists its cache.
$whitelist->destruct();
$this->assertEquals($memoryCounterBackend->getCounter('set', 'path_alias_whitelist'), 1);
$this->assertEquals(1, $memoryCounterBackend->getCounter('set', 'path_alias_whitelist'));
// Cache data should have data for 'user' and 'admin', even though just
// 'admin' was looked up. This is because the cache is primed with all
// menu router base paths.
@ -217,7 +217,7 @@ class AliasTest extends KernelTestBase {
// from underneath it and not save anything to cache, to protect from
// cache corruption.
$whitelist->destruct();
$this->assertEquals($memoryCounterBackend->getCounter('set', 'path_alias_whitelist'), 0);
$this->assertEquals(0, $memoryCounterBackend->getCounter('set', 'path_alias_whitelist'));
$this->assertFalse($memoryCounterBackend->get('path_alias_whitelist'));
$memoryCounterBackend->resetCounter();
}

View File

@ -155,7 +155,7 @@ class CollectRoutesTest extends UnitTestCase {
// Check auth options.
$auth = $this->routes->get('view.test_view.page_1')->getOption('_auth');
$this->assertCount(1, $auth, 'View route with rest export has an auth option added');
$this->assertEquals($auth[0], 'basic_auth', 'View route with rest export has the correct auth option added');
$this->assertEquals('basic_auth', $auth[0], 'View route with rest export has the correct auth option added');
}
}

View File

@ -295,7 +295,7 @@ class EntitySerializationTest extends NormalizerTestBase {
public function testDenormalizeCustomSerializedItem() {
$entity = EntitySerializedField::create(['serialized_text' => serialize(['Hello world!'])]);
$normalized = $this->serializer->normalize($entity);
$this->assertEquals($normalized['serialized_text'][0]['value'], ['Hello world!']);
$this->assertEquals(['Hello world!'], $normalized['serialized_text'][0]['value']);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized_text" field (field item class: Drupal\entity_test\Plugin\Field\FieldType\SerializedPropertyItem).');
$this->serializer->denormalize([
@ -314,7 +314,7 @@ class EntitySerializationTest extends NormalizerTestBase {
public function testDenormalizeInvalidCustomSerializedField() {
$entity = EntitySerializedField::create(['serialized_long' => serialize(['Hello world!'])]);
$normalized = $this->serializer->normalize($entity);
$this->assertEquals($normalized['serialized_long'][0]['value'], ['Hello world!']);
$this->assertEquals(['Hello world!'], $normalized['serialized_long'][0]['value']);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized_long" field (field item class: Drupal\Core\Field\Plugin\Field\FieldType\StringLongItem).');
$this->serializer->denormalize([

View File

@ -99,9 +99,9 @@ class SettingsTrayBlockFormTest extends SettingsTrayTestBase {
// Confirm "Display Title" is not checked.
$web_assert->checkboxNotChecked('settings[label_display]');
// Confirm Title is not visible.
$this->assertEquals($this->isLabelInputVisible(), FALSE, 'Label is not visible');
$this->assertFalse($this->isLabelInputVisible(), 'Label is not visible');
$page->checkField('settings[label_display]');
$this->assertEquals($this->isLabelInputVisible(), TRUE, 'Label is visible');
$this->assertTrue($this->isLabelInputVisible(), 'Label is visible');
// Fill out form, save the form.
$page->fillField('settings[label]', $new_page_text);

View File

@ -137,11 +137,11 @@ class SettingsTrayTestBase extends OffCanvasTestBase {
$web_assert->elementTextContains('css', '.form-item-settings-label-display label', 'Display block title');
// Confirm Block title label is shown if checkbox is checked.
if ($this->getSession()->getPage()->find('css', 'input[name="settings[label_display]"]')->isChecked()) {
$this->assertEquals($this->isLabelInputVisible(), TRUE, 'Label is visible');
$this->assertTrue($this->isLabelInputVisible(), 'Label is visible');
$web_assert->elementTextContains('css', '.form-item-settings-label label', 'Block title');
}
else {
$this->assertEquals($this->isLabelInputVisible(), FALSE, 'Label is not visible');
$this->assertFalse($this->isLabelInputVisible(), 'Label is not visible');
}
// Check that common block form elements exist.

View File

@ -98,10 +98,9 @@ class HtmlResponseAttachmentsTest extends BrowserTestBase {
* Helper function to make assertions about added HTTP headers.
*/
protected function assertTeapotHeaders() {
$headers = $this->getSession()->getResponseHeaders();
$this->assertEquals($headers['X-Test-Teapot'], ['Teapot Mode Active']);
$this->assertEquals($headers['X-Test-Teapot-Replace'], ['Teapot replaced']);
$this->assertEquals($headers['X-Test-Teapot-No-Replace'], ['This value is not replaced', 'This one is added']);
$this->assertSession()->responseHeaderEquals('X-Test-Teapot', 'Teapot Mode Active');
$this->assertSession()->responseHeaderEquals('X-Test-Teapot-Replace', 'Teapot replaced');
$this->assertSession()->responseHeaderEquals('X-Test-Teapot-No-Replace', 'This value is not replaced');
}
/**

View File

@ -179,7 +179,7 @@ class ModuleHandlerTest extends KernelTestBase {
$result = $this->moduleInstaller()->uninstall([$non_dependency]);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.');
$this->assertFalse($this->moduleHandler()->moduleExists($non_dependency));
$this->assertEquals(drupal_get_installed_schema_version($non_dependency), SCHEMA_UNINSTALLED, "$non_dependency module was uninstalled.");
$this->assertEquals(SCHEMA_UNINSTALLED, drupal_get_installed_schema_version($non_dependency), "$non_dependency module was uninstalled.");
// Verify that the installation profile itself was not uninstalled.
$uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order', []);

View File

@ -872,8 +872,8 @@ class UpdateContribTest extends UpdateTestBase {
$this->assertFalse($compatibility_details->hasAttribute('open'));
$this->assertSame('Compatible', $details_summary_element->getText());
$this->assertEquals(
$update_element->findLink('Download')->getAttribute('href'),
"http://example.com/{$this->updateProject}-$download_version.tar.gz"
"http://example.com/{$this->updateProject}-$download_version.tar.gz",
$update_element->findLink('Download')->getAttribute('href')
);
}
else {

View File

@ -84,7 +84,7 @@ class RestRegisterUserTest extends ResourceTestBase {
$this->assertFalse(empty($user->getPassword()));
$email_count = count($this->drupalGetMails());
$this->assertEquals($email_count, 0);
$this->assertEquals(0, $email_count);
// Attempt to register without sending a password.
$response = $this->registerRequest('Rick.Deckard', FALSE);

View File

@ -18,13 +18,13 @@ class UserRoleEntityTest extends KernelTestBase {
->grantPermission('a')
->grantPermission('c')
->save();
$this->assertEquals($role->getPermissions(), ['a', 'b', 'c']);
$this->assertEquals(['a', 'b', 'c'], $role->getPermissions());
$role->revokePermission('b')->save();
$this->assertEquals($role->getPermissions(), ['a', 'c']);
$this->assertEquals(['a', 'c'], $role->getPermissions());
$role->grantPermission('b')->save();
$this->assertEquals($role->getPermissions(), ['a', 'b', 'c']);
$this->assertEquals(['a', 'b', 'c'], $role->getPermissions());
}
}

View File

@ -327,12 +327,12 @@ EOF
$actual_permissions = $this->permissionHandler->getPermissions();
$this->assertCount(2, $actual_permissions);
$this->assertEquals($actual_permissions['access module a']['title'], 'Access A');
$this->assertEquals($actual_permissions['access module a']['provider'], 'module_a');
$this->assertEquals($actual_permissions['access module a']['description'], 'bla bla');
$this->assertEquals($actual_permissions['access module b']['title'], 'Access B');
$this->assertEquals($actual_permissions['access module b']['provider'], 'module_a');
$this->assertEquals($actual_permissions['access module b']['description'], 'bla bla');
$this->assertEquals('Access A', $actual_permissions['access module a']['title']);
$this->assertEquals('module_a', $actual_permissions['access module a']['provider']);
$this->assertEquals('bla bla', $actual_permissions['access module a']['description']);
$this->assertEquals('Access B', $actual_permissions['access module b']['title']);
$this->assertEquals('module_a', $actual_permissions['access module b']['provider']);
$this->assertEquals('bla bla', $actual_permissions['access module b']['description']);
}
/**
@ -343,14 +343,14 @@ EOF
*/
protected function assertPermissions(array $actual_permissions) {
$this->assertCount(4, $actual_permissions);
$this->assertEquals($actual_permissions['access_module_a']['title'], 'single_description');
$this->assertEquals($actual_permissions['access_module_a']['provider'], 'module_a');
$this->assertEquals($actual_permissions['access module b']['title'], 'Access B');
$this->assertEquals($actual_permissions['access module b']['provider'], 'module_b');
$this->assertEquals($actual_permissions['access_module_c']['title'], 'Access C');
$this->assertEquals($actual_permissions['access_module_c']['provider'], 'module_c');
$this->assertEquals($actual_permissions['access_module_c']['restrict access'], TRUE);
$this->assertEquals($actual_permissions['access module a via module b']['provider'], 'module_a');
$this->assertEquals('single_description', $actual_permissions['access_module_a']['title']);
$this->assertEquals('module_a', $actual_permissions['access_module_a']['provider']);
$this->assertEquals('Access B', $actual_permissions['access module b']['title']);
$this->assertEquals('module_b', $actual_permissions['access module b']['provider']);
$this->assertEquals('Access C', $actual_permissions['access_module_c']['title']);
$this->assertEquals('module_c', $actual_permissions['access_module_c']['provider']);
$this->assertTrue($actual_permissions['access_module_c']['restrict access']);
$this->assertEquals('module_a', $actual_permissions['access module a via module b']['provider']);
}
}

View File

@ -344,8 +344,8 @@ class ViewExecutableTest extends UnitTestCase {
public function testGenerateHandlerId() {
// Test the generateHandlerId() method.
$test_ids = ['test' => 'test', 'test_1' => 'test_1'];
$this->assertEquals(ViewExecutable::generateHandlerId('new', $test_ids), 'new');
$this->assertEquals(ViewExecutable::generateHandlerId('test', $test_ids), 'test_2');
$this->assertEquals('new', ViewExecutable::generateHandlerId('new', $test_ids));
$this->assertEquals('test_2', ViewExecutable::generateHandlerId('test', $test_ids));
}
/**

View File

@ -128,7 +128,7 @@ class FilterNumericWebTest extends UITestBase {
$max_element_label = $this->xpath('//fieldset[contains(@id, "edit-age-wrapper")]//label[contains(@for, "edit-age-max") and contains(text(), "Max")]');
$this->assertCount(1, $max_element_label);
// Check that the description is shown in the right place.
$this->assertEquals(trim($this->cssSelect('#edit-age-wrapper--description')[0]->getText()), 'Description of the exposed filter');
$this->assertEquals('Description of the exposed filter', trim($this->cssSelect('#edit-age-wrapper--description')[0]->getText()));
// Change to an operation that only requires one form element ('>').
$this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/age');

View File

@ -114,10 +114,10 @@ class ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest extends B
// Assert that after rearranging the field items the user input will be
// mapped on the correct delta field items.
$this->assertEquals($entity->get($this->fieldName)->getValue(), [
$this->assertEquals([
['shape' => 'circle', 'color' => 'blue'],
['shape' => 'rectangle', 'color' => 'green'],
]);
], $entity->get($this->fieldName)->getValue());
}
}

View File

@ -105,7 +105,7 @@ class UpdatePathTestBaseTest extends UpdatePathTestBase {
// Ensure the index was added for column a.
$this->assertTrue($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.');
// Ensure update_test_semver_update_n_update_8001 was run.
$this->assertEquals(\Drupal::state()->get('update_test_semver_update_n_update_8001'), 'Yes, I was run. Thanks for testing!');
$this->assertEquals('Yes, I was run. Thanks for testing!', \Drupal::state()->get('update_test_semver_update_n_update_8001'));
}
/**

View File

@ -57,9 +57,9 @@ class EmailActionTest extends KernelTestBase {
->execute()
->fetch();
$this->assertEquals($log->message, 'Sent email to %recipient');
$this->assertEquals('Sent email to %recipient', $log->message);
$variables = unserialize($log->variables);
$this->assertEquals($variables['%recipient'], 'test@example.com');
$this->assertEquals('test@example.com', $variables['%recipient']);
}
}

View File

@ -41,7 +41,7 @@ class EntityDuplicateTest extends EntityKernelTestBase {
$duplicate_first_revision = $this->entityTestRevStorage->loadRevision($first_revision_id)->createDuplicate();
$this->assertTrue($duplicate_first_revision->isDefaultRevision(), 'Duplicating a non-default revision creates a default revision.');
$this->assertEquals($duplicate_first_revision->label(), 'First Revision');
$this->assertEquals('First Revision', $duplicate_first_revision->label());
$duplicate_first_revision->save();
$duplicate_first_revision->name = 'Updated name';

View File

@ -47,7 +47,7 @@ class EntityHasFieldConstraintValidatorTest extends EntityKernelTestBase {
// field has been created.
$violations = $entity->validate();
$this->assertCount(1, $violations);
$this->assertEquals($violations[0]->getMessage(), 'The entity must have the <em class="placeholder">body</em> field.');
$this->assertEquals('The entity must have the <em class="placeholder">body</em> field.', $violations[0]->getMessage());
$storage->save($entity);
// Create the field.

View File

@ -134,8 +134,8 @@ class EntityRevisionTranslationTest extends EntityKernelTestBase {
$pending_revision = $storage->loadRevision($pending_revision_id);
$this->assertEquals($pending_revision->name->value, 'updated pending revision - en');
$this->assertEquals($pending_revision->getTranslation('de')->name->value, 'pending revision - de');
$this->assertEquals('updated pending revision - en', $pending_revision->name->value);
$this->assertEquals('pending revision - de', $pending_revision->getTranslation('de')->name->value);
}
/**

View File

@ -211,7 +211,7 @@ DOCBLOCK;
$this->assertNull($annot->name);
$this->assertNotNull($annot->data);
$this->assertEquals($annot->data, "Some data");
$this->assertEquals("Some data", $annot->data);
@ -230,8 +230,8 @@ DOCBLOCK;
$this->assertNotNull($annot);
$this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot);
$this->assertEquals($annot->name, "Some Name");
$this->assertEquals($annot->data, "Some data");
$this->assertEquals("Some Name", $annot->name);
$this->assertEquals("Some data", $annot->data);
@ -246,7 +246,7 @@ DOCBLOCK;
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->data, "Some data");
$this->assertEquals("Some data", $annot->data);
$this->assertNull($annot->name);
@ -260,7 +260,7 @@ DOCBLOCK;
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals("Some name", $annot->name);
$this->assertNull($annot->data);
$docblock = <<<DOCBLOCK
@ -273,7 +273,7 @@ DOCBLOCK;
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->data, "Some data");
$this->assertEquals("Some data", $annot->data);
$this->assertNull($annot->name);
@ -288,8 +288,8 @@ DOCBLOCK;
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals($annot->data, "Some data");
$this->assertEquals("Some name", $annot->name);
$this->assertEquals("Some data", $annot->data);
$docblock = <<<DOCBLOCK
@ -302,8 +302,8 @@ DOCBLOCK;
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals($annot->data, "Some data");
$this->assertEquals("Some name", $annot->name);
$this->assertEquals("Some data", $annot->data);
$docblock = <<<DOCBLOCK
/**

View File

@ -168,7 +168,7 @@ class ContainerTest extends TestCase {
$this->assertEquals($some_parameter, $service->getSomeParameter(), '%some_config% was injected via constructor.');
$this->assertEquals($this->container, $service->getContainer(), 'Container was injected via setter injection.');
$this->assertEquals($some_other_parameter, $service->getSomeOtherParameter(), '%some_other_config% was injected via setter injection.');
$this->assertEquals($service->_someProperty, 'foo', 'Service has added properties.');
$this->assertEquals('foo', $service->_someProperty, 'Service has added properties.');
}
/**
@ -540,13 +540,13 @@ class ContainerTest extends TestCase {
public function testResolveServicesAndParametersForPrivateService() {
$service = $this->container->get('service_using_private');
$private_service = $service->getSomeOtherService();
$this->assertEquals($private_service->getSomeParameter(), 'really_private_lama', 'Private was found successfully.');
$this->assertEquals('really_private_lama', $private_service->getSomeParameter(), 'Private was found successfully.');
// Test that sharing the same private services works.
$service = $this->container->get('another_service_using_private');
$another_private_service = $service->getSomeOtherService();
$this->assertNotSame($private_service, $another_private_service, 'Private service is not shared.');
$this->assertEquals($private_service->getSomeParameter(), 'really_private_lama', 'Private was found successfully.');
$this->assertEquals('really_private_lama', $private_service->getSomeParameter(), 'Private was found successfully.');
}
/**
@ -559,13 +559,13 @@ class ContainerTest extends TestCase {
public function testResolveServicesAndParametersForSharedPrivateService() {
$service = $this->container->get('service_using_shared_private');
$private_service = $service->getSomeOtherService();
$this->assertEquals($private_service->getSomeParameter(), 'really_private_lama', 'Private was found successfully.');
$this->assertEquals('really_private_lama', $private_service->getSomeParameter(), 'Private was found successfully.');
// Test that sharing the same private services works.
$service = $this->container->get('another_service_using_shared_private');
$same_private_service = $service->getSomeOtherService();
$this->assertSame($private_service, $same_private_service, 'Private service is shared.');
$this->assertEquals($private_service->getSomeParameter(), 'really_private_lama', 'Private was found successfully.');
$this->assertEquals('really_private_lama', $private_service->getSomeParameter(), 'Private was found successfully.');
}
/**

View File

@ -62,7 +62,7 @@ class YamlDiscoveryTest extends TestCase {
foreach (['test_1', 'test_2', 'test_3'] as $key) {
$this->assertArrayHasKey('name', $data[$key]);
$this->assertEquals($data[$key]['name'], 'test');
$this->assertEquals('test', $data[$key]['name']);
}
$this->assertSame([], $data['test_4']);

View File

@ -541,7 +541,7 @@ class XssTest extends TestCase {
*/
public function testFilterXSSAdmin() {
$value = Xss::filterAdmin('<style /><iframe /><frame /><frameset /><meta /><link /><embed /><applet /><param /><layer />');
$this->assertEquals($value, '', 'Admin HTML filter -- should never allow some tags.');
$this->assertEquals('', $value, 'Admin HTML filter -- should never allow some tags.');
}
/**

View File

@ -147,9 +147,9 @@ class AccessManagerTest extends UnitTestCase {
$this->checkProvider->setChecks($this->routeCollection);
$this->assertEquals($this->routeCollection->get('test_route_1')->getOption('_access_checks'), NULL);
$this->assertEquals($this->routeCollection->get('test_route_2')->getOption('_access_checks'), ['test_access_default']);
$this->assertEquals($this->routeCollection->get('test_route_3')->getOption('_access_checks'), ['test_access_default']);
$this->assertNull($this->routeCollection->get('test_route_1')->getOption('_access_checks'));
$this->assertEquals(['test_access_default'], $this->routeCollection->get('test_route_2')->getOption('_access_checks'));
$this->assertEquals(['test_access_default'], $this->routeCollection->get('test_route_3')->getOption('_access_checks'));
}
/**

View File

@ -88,7 +88,7 @@ class AjaxResponseTest extends UnitTestCase {
);
$subscriber->onResponse($event);
$this->assertEquals('text/html; charset=utf-8', $response->headers->get('Content-Type'));
$this->assertEquals($response->getContent(), '<textarea>[]</textarea>');
$this->assertEquals('<textarea>[]</textarea>', $response->getContent());
}
}

View File

@ -40,7 +40,7 @@ class EmptyStatementTest extends UnitTestCase {
public function testEmptyFetchAll() {
$result = new StatementEmpty();
$this->assertEquals($result->fetchAll(), [], 'Empty array returned from empty result set.');
$this->assertEquals([], $result->fetchAll(), 'Empty array returned from empty result set.');
}
}

View File

@ -36,7 +36,7 @@ class OrderByTest extends UnitTestCase {
public function testInvalidDirection() {
$this->query->orderBy('test', 'invalid direction');
$order_bys = $this->query->getOrderBy();
$this->assertEquals($order_bys['test'], 'ASC', 'Invalid order by direction is converted to ASC.');
$this->assertEquals('ASC', $order_bys['test'], 'Invalid order by direction is converted to ASC.');
}
/**

View File

@ -54,8 +54,8 @@ class EntityRouteEnhancerTest extends UnitTestCase {
$defaults['_route_object'] = (new Route('/test', $defaults));
$defaults = $route_enhancer->enhance($defaults, $request);
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityViewController::view', $defaults['_controller'], 'The entity view controller was not set.');
$this->assertEquals($defaults['_entity'], 'Mock entity');
$this->assertEquals($defaults['view_mode'], 'full');
$this->assertEquals('Mock entity', $defaults['_entity']);
$this->assertEquals('full', $defaults['view_mode']);
$this->assertFalse(isset($defaults['_entity_view']));
// Set _entity_view and ensure that the entity view controller is set using
@ -73,8 +73,8 @@ class EntityRouteEnhancerTest extends UnitTestCase {
$defaults[RouteObjectInterface::ROUTE_OBJECT] = $route;
$defaults = $route_enhancer->enhance($defaults, $request);
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityViewController::view', $defaults['_controller'], 'The entity view controller was not set.');
$this->assertEquals($defaults['_entity'], 'Mock entity');
$this->assertEquals($defaults['view_mode'], 'full');
$this->assertEquals('Mock entity', $defaults['_entity']);
$this->assertEquals('full', $defaults['view_mode']);
$this->assertFalse(isset($defaults['_entity_view']));
// Set _entity_view without a view mode.
@ -84,7 +84,7 @@ class EntityRouteEnhancerTest extends UnitTestCase {
$defaults['_route_object'] = (new Route('/test', $defaults));
$defaults = $route_enhancer->enhance($defaults, $request);
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityViewController::view', $defaults['_controller'], 'The entity view controller was not set.');
$this->assertEquals($defaults['_entity'], 'Mock entity');
$this->assertEquals('Mock entity', $defaults['_entity']);
$this->assertTrue(empty($defaults['view_mode']));
$this->assertFalse(isset($defaults['_entity_view']));
}

View File

@ -519,9 +519,9 @@ COMMONTEST;
],
]);
$info_values = $this->infoParser->parse(vfsStream::url("modules/fixtures/$filename"));
$this->assertEquals($info_values['simple_string'], 'A simple string', 'Simple string value was parsed correctly.');
$this->assertEquals($info_values['version'], \Drupal::VERSION, 'Constant value was parsed correctly.');
$this->assertEquals($info_values['double_colon'], 'dummyClassName::method', 'Value containing double-colon was parsed correctly.');
$this->assertEquals('A simple string', $info_values['simple_string'], 'Simple string value was parsed correctly.');
$this->assertEquals(\Drupal::VERSION, $info_values['version'], 'Constant value was parsed correctly.');
$this->assertEquals('dummyClassName::method', $info_values['double_colon'], 'Value containing double-colon was parsed correctly.');
$this->assertFalse($info_values['core_incompatible']);
}
}
@ -548,7 +548,7 @@ CORETEST;
],
]);
$info_values = $this->infoParser->parse(vfsStream::url("core/fixtures/$filename"));
$this->assertEquals($info_values['version'], \Drupal::VERSION, 'Constant value was parsed correctly.');
$this->assertEquals(\Drupal::VERSION, $info_values['version'], 'Constant value was parsed correctly.');
$this->assertFalse($info_values['core_incompatible']);
$this->assertEquals(\Drupal::VERSION, $info_values['core_version_requirement']);
}

View File

@ -187,7 +187,7 @@ class ModuleHandlerTest extends UnitTestCase {
$module_handler->expects($this->once())->method('resetImplementations');
// Make sure we're starting empty.
$this->assertEquals($module_handler->getModuleList(), []);
$this->assertEquals([], $module_handler->getModuleList());
// Replace the list with a prebuilt list.
$module_handler->setModuleList($fixture_module_handler->getModuleList());

View File

@ -94,7 +94,7 @@ class LoggerChannelTest extends UnitTestCase {
$channel->log(rand(0, 7), $this->randomMachineName());
// Ensure that the logger added in the end fired first.
$this->assertEquals($index_order, '3210');
$this->assertEquals('3210', $index_order);
}
/**

View File

@ -71,14 +71,14 @@ class HookDiscoveryTest extends UnitTestCase {
$definitions = $this->hookDiscovery->getDefinitions();
$this->assertCount(3, $definitions);
$this->assertEquals($definitions['test_id_1']['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple');
$this->assertEquals($definitions['test_id_2']['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange');
$this->assertEquals($definitions['test_id_3']['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry');
$this->assertEquals('Drupal\plugin_test\Plugin\plugin_test\fruit\Apple', $definitions['test_id_1']['class']);
$this->assertEquals('Drupal\plugin_test\Plugin\plugin_test\fruit\Orange', $definitions['test_id_2']['class']);
$this->assertEquals('Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry', $definitions['test_id_3']['class']);
// Ensure that the module was set.
$this->assertEquals($definitions['test_id_1']['provider'], 'hook_discovery_test');
$this->assertEquals($definitions['test_id_2']['provider'], 'hook_discovery_test');
$this->assertEquals($definitions['test_id_3']['provider'], 'hook_discovery_test2');
$this->assertEquals('hook_discovery_test', $definitions['test_id_1']['provider']);
$this->assertEquals('hook_discovery_test', $definitions['test_id_2']['provider']);
$this->assertEquals('hook_discovery_test2', $definitions['test_id_3']['provider']);
}
/**
@ -103,16 +103,16 @@ class HookDiscoveryTest extends UnitTestCase {
$this->assertNull($this->hookDiscovery->getDefinition('test_non_existent', FALSE));
$plugin_definition = $this->hookDiscovery->getDefinition('test_id_1');
$this->assertEquals($plugin_definition['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple');
$this->assertEquals($plugin_definition['provider'], 'hook_discovery_test');
$this->assertEquals('Drupal\plugin_test\Plugin\plugin_test\fruit\Apple', $plugin_definition['class']);
$this->assertEquals('hook_discovery_test', $plugin_definition['provider']);
$plugin_definition = $this->hookDiscovery->getDefinition('test_id_2');
$this->assertEquals($plugin_definition['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange');
$this->assertEquals($plugin_definition['provider'], 'hook_discovery_test');
$this->assertEquals('Drupal\plugin_test\Plugin\plugin_test\fruit\Orange', $plugin_definition['class']);
$this->assertEquals('hook_discovery_test', $plugin_definition['provider']);
$plugin_definition = $this->hookDiscovery->getDefinition('test_id_3');
$this->assertEquals($plugin_definition['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry');
$this->assertEquals($plugin_definition['provider'], 'hook_discovery_test2');
$this->assertEquals('Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry', $plugin_definition['class']);
$this->assertEquals('hook_discovery_test2', $plugin_definition['provider']);
}
/**

View File

@ -763,7 +763,7 @@ class RendererTest extends RendererTestBase {
->willReturn('foobar');
// Test that defaults work.
$this->assertEquals($this->renderer->renderRoot($element), 'foobar', 'Defaults work');
$this->assertEquals('foobar', $this->renderer->renderRoot($element), 'Defaults work');
}
/**

View File

@ -79,7 +79,7 @@ class ContentTypeHeaderMatcherTest extends UnitTestCase {
$this->assertNotNull($routes->get('route_f'), 'The json route was found.');
$this->assertNull($routes->get('route_g'), 'The xml route was not found.');
foreach ($routes as $name => $route) {
$this->assertEquals($name, 'route_f', 'The json route is the first one in the collection.');
$this->assertEquals('route_f', $name, 'The json route is the first one in the collection.');
break;
}
}

View File

@ -57,8 +57,8 @@ class RouteCompilerTest extends UnitTestCase {
$route->setOption('compiler_class', RouteCompiler::class);
$compiled = $route->compile();
$this->assertEquals($compiled->getFit(), 5 /* That's 101 binary*/, 'The fit was incorrect.');
$this->assertEquals($compiled->getPatternOutline(), '/test/%/more', 'The pattern outline was not correct.');
$this->assertEquals(5 /* That's 101 binary*/, $compiled->getFit(), 'The fit was incorrect.');
$this->assertEquals('/test/%/more', $compiled->getPatternOutline(), 'The pattern outline was not correct.');
}
/**
@ -73,8 +73,8 @@ class RouteCompilerTest extends UnitTestCase {
$route->setOption('compiler_class', RouteCompiler::class);
$compiled = $route->compile();
$this->assertEquals($compiled->getFit(), 5 /* That's 101 binary*/, 'The fit was not correct.');
$this->assertEquals($compiled->getPatternOutline(), '/test/%/more', 'The pattern outline was not correct.');
$this->assertEquals(5 /* That's 101 binary*/, $compiled->getFit(), 'The fit was not correct.');
$this->assertEquals('/test/%/more', $compiled->getPatternOutline(), 'The pattern outline was not correct.');
}
}

View File

@ -390,7 +390,7 @@ class UrlGeneratorTest extends UnitTestCase {
->method('processOutbound');
$path = $this->generator->getPathFromRoute('test_3');
$this->assertEquals($path, 'test/two');
$this->assertEquals('test/two', $path);
}
/**

View File

@ -101,7 +101,7 @@ class TwigSandboxTest extends UnitTestCase {
->method('getEntityType')
->willReturn('test');
$result = $this->twig->render('{{ entity.getEntityType }}', ['entity' => $entity]);
$this->assertEquals($result, 'test', 'Sandbox policy allows get* functions to be called.');
$this->assertEquals('test', $result, 'Sandbox policy allows get* functions to be called.');
}
/**
@ -119,28 +119,28 @@ class TwigSandboxTest extends UnitTestCase {
->with('title')
->willReturn('test');
$result = $this->twig->render('{{ entity.get("title") }}', ['entity' => $entity]);
$this->assertEquals($result, 'test', 'Sandbox policy allows get() to be called.');
$this->assertEquals('test', $result, 'Sandbox policy allows get() to be called.');
$entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->atLeastOnce())
->method('id')
->willReturn('1234');
$result = $this->twig->render('{{ entity.id }}', ['entity' => $entity]);
$this->assertEquals($result, '1234', 'Sandbox policy allows get() to be called.');
$this->assertEquals('1234', $result, 'Sandbox policy allows get() to be called.');
$entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->atLeastOnce())
->method('label')
->willReturn('testing');
$result = $this->twig->render('{{ entity.label }}', ['entity' => $entity]);
$this->assertEquals($result, 'testing', 'Sandbox policy allows get() to be called.');
$this->assertEquals('testing', $result, 'Sandbox policy allows get() to be called.');
$entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->atLeastOnce())
->method('bundle')
->willReturn('testing');
$result = $this->twig->render('{{ entity.bundle }}', ['entity' => $entity]);
$this->assertEquals($result, 'testing', 'Sandbox policy allows get() to be called.');
$this->assertEquals('testing', $result, 'Sandbox policy allows get() to be called.');
}
/**
@ -154,7 +154,7 @@ class TwigSandboxTest extends UnitTestCase {
->method('toString')
->willReturn('http://kittens.cat/are/cute');
$result = $this->twig->render('{{ url.toString }}', ['url' => $url]);
$this->assertEquals($result, 'http://kittens.cat/are/cute', 'Sandbox policy allows toString() to be called.');
$this->assertEquals('http://kittens.cat/are/cute', $result, 'Sandbox policy allows toString() to be called.');
}
}

View File

@ -30,13 +30,13 @@ class JUnitConverterTest extends UnitTestCase {
$res = JUnitConverter::xmlToRows(1, $phpunit_error_xml);
$this->assertCount(4, $res, 'All testcases got extracted');
$this->assertNotEquals($res[0]['status'], 'pass');
$this->assertEquals($res[0]['status'], 'fail');
$this->assertNotEquals('pass', $res[0]['status']);
$this->assertEquals('fail', $res[0]['status']);
// Test nested testsuites, which appear when you use @dataProvider.
for ($i = 0; $i < 3; $i++) {
$this->assertNotEquals($res[$i + 1]['status'], 'pass');
$this->assertEquals($res[$i + 1]['status'], 'fail');
$this->assertNotEquals('pass', $res[$i + 1]['status']);
$this->assertEquals('fail', $res[$i + 1]['status']);
}
// Make sure xmlToRows() does not balk if there are no test results.