summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--core/modules/block/tests/src/Kernel/BlockInterfaceTest.php2
-rw-r--r--core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php11
-rw-r--r--core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php2
-rw-r--r--core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php4
-rw-r--r--core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php8
-rw-r--r--core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php26
-rw-r--r--core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php9
-rw-r--r--core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php9
-rw-r--r--core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php17
-rw-r--r--core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php4
-rw-r--r--core/modules/views/tests/src/Kernel/ModuleTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/AssertContentTrait.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/KernelTestBase.php2
-rw-r--r--core/tests/Drupal/Tests/AssertHelperTrait.php6
-rw-r--r--core/tests/Drupal/Tests/AssertHelperTraitTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php7
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php5
-rw-r--r--core/tests/Drupal/Tests/UiHelperTrait.php4
19 files changed, 55 insertions, 81 deletions
diff --git a/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php b/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php
index 6e1a4d25451..b917d718423 100644
--- a/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php
@@ -87,7 +87,7 @@ class BlockInterfaceTest extends KernelTestBase {
$actual_form = $display_block->buildConfigurationForm([], $form_state);
// Remove the visibility sections, as that just tests condition plugins.
unset($actual_form['visibility'], $actual_form['visibility_tabs']);
- $this->assertIdentical($this->castSafeStrings($actual_form), $this->castSafeStrings($expected_form), 'Only the expected form elements were present.');
+ $this->assertEquals($expected_form, $actual_form, 'Only the expected form elements were present.');
$expected_build = [
'#children' => 'My custom display message.',
diff --git a/core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php b/core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
index 4868c76fdcd..bca2e9a3501 100644
--- a/core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
+++ b/core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
@@ -2,7 +2,6 @@
namespace Drupal\Tests\book\Unit;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
@@ -11,8 +10,6 @@ use Drupal\Tests\UnitTestCase;
*/
class BookUninstallValidatorTest extends UnitTestCase {
- use AssertHelperTrait;
-
/**
* @var \Drupal\book\BookUninstallValidator|\PHPUnit\Framework\MockObject\MockObject
*/
@@ -42,7 +39,7 @@ class BookUninstallValidatorTest extends UnitTestCase {
$module = 'not_book';
$expected = [];
$reasons = $this->bookUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -59,7 +56,7 @@ class BookUninstallValidatorTest extends UnitTestCase {
$module = 'book';
$expected = [];
$reasons = $this->bookUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -76,7 +73,7 @@ class BookUninstallValidatorTest extends UnitTestCase {
$module = 'book';
$expected = ['To uninstall Book, delete all content that has the Book content type'];
$reasons = $this->bookUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -92,7 +89,7 @@ class BookUninstallValidatorTest extends UnitTestCase {
$module = 'book';
$expected = ['To uninstall Book, delete all content that is part of a book'];
$reasons = $this->bookUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
}
diff --git a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
index 495c877a978..e8f9672e811 100644
--- a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
+++ b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
@@ -192,7 +192,7 @@ class BreakpointDiscoveryTest extends KernelTestBase {
];
$breakpoint_groups = \Drupal::service('breakpoint.manager')->getGroups();
// Ensure the order is as expected. Should be sorted by label.
- $this->assertIdentical($expected, $this->castSafeStrings($breakpoint_groups));
+ $this->assertEquals($expected, $breakpoint_groups);
$expected = [
'breakpoint_theme_test' => 'theme',
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
index ac551ec1217..9344ab97f0d 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
@@ -112,7 +112,7 @@ class CKEditorAdminTest extends BrowserTestBase {
],
'plugins' => ['language' => ['language_list' => 'un']],
];
- $this->assertIdentical($this->castSafeStrings($ckeditor->getDefaultSettings()), $expected_default_settings);
+ $this->assertEquals($expected_default_settings, $ckeditor->getDefaultSettings());
// Keep the "CKEditor" editor selected and click the "Configure" button.
$this->drupalPostForm(NULL, $edit, 'editor_configure');
@@ -300,7 +300,7 @@ class CKEditorAdminTest extends BrowserTestBase {
$expected_settings['plugins']['stylescombo']['styles'] = '';
$editor = Editor::load('amazing_format');
$this->assertInstanceOf(Editor::class, $editor);
- $this->assertEqual($this->castSafeStrings($expected_settings), $this->castSafeStrings($editor->getSettings()), 'The Editor config entity has the correct settings.');
+ $this->assertEquals($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
}
}
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
index 39c7e9a3a77..89baa22bcb5 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
@@ -119,14 +119,14 @@ class CKEditorLoadingTest extends BrowserTestBase {
'filtered_html' => [
'format' => 'filtered_html',
'editor' => 'ckeditor',
- 'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)),
+ 'editorSettings' => $ckeditor_plugin->getJSSettings($editor),
'editorSupportsContentFiltering' => TRUE,
'isXssSafe' => FALSE,
],
],
];
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
- $this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
+ $this->assertEquals($expected, $settings['editor'], "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertCount(1, $format_selector, 'A single text format selector exists on the page.');
@@ -152,14 +152,14 @@ class CKEditorLoadingTest extends BrowserTestBase {
'filtered_html' => [
'format' => 'filtered_html',
'editor' => 'ckeditor',
- 'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)),
+ 'editorSettings' => $ckeditor_plugin->getJSSettings($editor),
'editorSupportsContentFiltering' => TRUE,
'isXssSafe' => FALSE,
],
],
];
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
- $this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
+ $this->assertEquals($expected, $settings['editor'], "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertContains('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries']), 'CKEditor glue library is present.');
diff --git a/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php b/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
index 68d2b64d349..32e755b5ce1 100644
--- a/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
+++ b/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
@@ -97,10 +97,7 @@ class CKEditorTest extends KernelTestBase {
'drupallink' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupallink/plugin.js')),
],
];
- $expected_config = $this->castSafeStrings($expected_config);
- ksort($expected_config);
- ksort($expected_config['allowedContent']);
- $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for default configuration.');
+ $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for default configuration.');
// Customize the configuration: add button, have two contextually enabled
// buttons, and configure a CKEditor plugin setting.
@@ -120,8 +117,7 @@ class CKEditorTest extends KernelTestBase {
$expected_config['drupalExternalPlugins']['llama_contextual'] = file_url_transform_relative(file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual.js'));
$expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = file_url_transform_relative(file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js'));
$expected_config['contentsCss'][] = file_url_transform_relative(file_create_url('core/modules/ckeditor/tests/modules/ckeditor_test.css')) . $query_string;
- ksort($expected_config);
- $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
+ $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.');
// Change the allowed HTML tags; the "allowedContent" and "format_tags"
// settings for CKEditor should automatically be updated as well.
@@ -134,8 +130,7 @@ class CKEditorTest extends KernelTestBase {
$expected_config['allowedContent']['blockquote'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE];
$expected_config['allowedContent']['address'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*'];
$expected_config['format_tags'] = 'p;h1;h2;h3;h4;h5;h6;pre';
- ksort($expected_config['allowedContent']);
- $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
+ $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.');
// Disable the filter_html filter: allow *all *tags.
$format->setFilterConfig('filter_html', ['status' => 0]);
@@ -144,7 +139,7 @@ class CKEditorTest extends KernelTestBase {
$expected_config['allowedContent'] = TRUE;
$expected_config['disallowedContent'] = FALSE;
$expected_config['format_tags'] = 'p;h1;h2;h3;h4;h5;h6;pre';
- $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
+ $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.');
// Enable the filter_test_restrict_tags_and_attributes filter.
$format->setFilterConfig('filter_test_restrict_tags_and_attributes', [
@@ -215,10 +210,7 @@ class CKEditorTest extends KernelTestBase {
],
];
$expected_config['format_tags'] = 'p';
- ksort($expected_config);
- ksort($expected_config['allowedContent']);
- ksort($expected_config['disallowedContent']);
- $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
+ $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.');
}
/**
@@ -229,7 +221,7 @@ class CKEditorTest extends KernelTestBase {
// Default toolbar.
$expected = $this->getDefaultToolbarConfig();
- $this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for default toolbar.');
+ $this->assertIdentical($expected, $this->ckeditor->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for default toolbar.');
// Customize the configuration.
$settings = $editor->getSettings();
@@ -237,7 +229,7 @@ class CKEditorTest extends KernelTestBase {
$editor->setSettings($settings);
$editor->save();
$expected[0]['items'][] = 'Strike';
- $this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');
+ $this->assertEquals($expected, $this->ckeditor->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');
// Enable the editor_test module, customize further.
$this->enableModules(['ckeditor_test']);
@@ -249,7 +241,7 @@ class CKEditorTest extends KernelTestBase {
$editor->save();
$expected[0]['name'] = 'JunkScience';
$expected[0]['items'][] = 'Llama';
- $this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar with contrib module-provided CKEditor plugin.');
+ $this->assertEquals($expected, $this->ckeditor->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar with contrib module-provided CKEditor plugin.');
}
/**
@@ -261,7 +253,7 @@ class CKEditorTest extends KernelTestBase {
// Default toolbar.
$expected = $this->getDefaultContentsCssConfig();
- $this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly for default toolbar.');
+ $this->assertEquals($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly for default toolbar.');
// Enable the editor_test module, which implements hook_ckeditor_css_alter().
$this->enableModules(['ckeditor_test']);
diff --git a/core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php b/core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php
index fbc09ab0bdc..1a08dcf1882 100644
--- a/core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php
+++ b/core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php
@@ -2,7 +2,6 @@
namespace Drupal\Tests\field\Unit;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
@@ -11,8 +10,6 @@ use Drupal\Tests\UnitTestCase;
*/
class FieldUninstallValidatorTest extends UnitTestCase {
- use AssertHelperTrait;
-
/**
* @var \Drupal\field\FieldUninstallValidator|\PHPUnit\Framework\MockObject\MockObject
*/
@@ -48,7 +45,7 @@ class FieldUninstallValidatorTest extends UnitTestCase {
$module = $this->randomMachineName();
$expected = [];
$reasons = $this->fieldUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -68,7 +65,7 @@ class FieldUninstallValidatorTest extends UnitTestCase {
$module = $this->randomMachineName();
$expected = ['Fields pending deletion'];
$reasons = $this->fieldUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -100,7 +97,7 @@ class FieldUninstallValidatorTest extends UnitTestCase {
$module = $this->randomMachineName();
$expected = ["The <em class=\"placeholder\">$field_type_label</em> field type is used in the following field: $field_name"];
$reasons = $this->fieldUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
}
diff --git a/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php b/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php
index e7d02aebf35..8387f14e022 100644
--- a/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php
+++ b/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php
@@ -2,7 +2,6 @@
namespace Drupal\Tests\filter\Unit;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
@@ -11,8 +10,6 @@ use Drupal\Tests\UnitTestCase;
*/
class FilterUninstallValidatorTest extends UnitTestCase {
- use AssertHelperTrait;
-
/**
* @var \Drupal\filter\FilterUninstallValidator|\PHPUnit\Framework\MockObject\MockObject
*/
@@ -43,7 +40,7 @@ class FilterUninstallValidatorTest extends UnitTestCase {
$module = $this->randomMachineName();
$expected = [];
$reasons = $this->filterUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -65,7 +62,7 @@ class FilterUninstallValidatorTest extends UnitTestCase {
$module = $this->randomMachineName();
$expected = [];
$reasons = $this->filterUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -160,7 +157,7 @@ class FilterUninstallValidatorTest extends UnitTestCase {
'Provides a filter plugin that is in use in the following filter formats: <em class="placeholder">Filter Format 1 Label, Filter Format 2 Label</em>',
];
$reasons = $this->filterUninstallValidator->validate($this->randomMachineName());
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
}
diff --git a/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php b/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php
index 33067032396..714cd926532 100644
--- a/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php
+++ b/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php
@@ -3,7 +3,6 @@
namespace Drupal\Tests\forum\Unit;
use Drupal\Core\Url;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
@@ -12,8 +11,6 @@ use Drupal\Tests\UnitTestCase;
*/
class ForumUninstallValidatorTest extends UnitTestCase {
- use AssertHelperTrait;
-
/**
* @var \Drupal\forum\ForumUninstallValidator|\PHPUnit\Framework\MockObject\MockObject
*/
@@ -45,7 +42,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
$module = 'not_forum';
$expected = [];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -68,7 +65,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
$module = 'forum';
$expected = [];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -93,7 +90,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
'To uninstall Forum, first delete all <em>Forum</em> content',
];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -131,7 +128,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
'To uninstall Forum, first delete all <a href="/path/to/vocabulary/overview"><em class="placeholder">Vocabulary label</em></a> terms',
];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -165,7 +162,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
'To uninstall Forum, first delete all <em class="placeholder">Vocabulary label</em> terms',
];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -202,7 +199,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
'To uninstall Forum, first delete all <a href="/path/to/vocabulary/overview"><em class="placeholder">Vocabulary label</em></a> terms',
];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -235,7 +232,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
'To uninstall Forum, first delete all <em class="placeholder">Vocabulary label</em> terms',
];
$reasons = $this->forumUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
}
diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
index f2e919a7e79..cc1d570ddb8 100644
--- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
+++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
@@ -478,7 +478,7 @@ class StyleSerializerTest extends ViewTestBase {
$expected[] = $expected_row;
}
- $this->assertIdentical(Json::decode($this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']])), $this->castSafeStrings($expected));
+ $this->assertEquals($expected, Json::decode($this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']])));
// Test a random aliases for fields, they should be replaced.
$alias_map = [
@@ -513,7 +513,7 @@ class StyleSerializerTest extends ViewTestBase {
$expected[] = $expected_row;
}
- $this->assertIdentical(Json::decode($this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']])), $this->castSafeStrings($expected));
+ $this->assertEquals($expected, Json::decode($this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']])));
}
/**
diff --git a/core/modules/views/tests/src/Kernel/ModuleTest.php b/core/modules/views/tests/src/Kernel/ModuleTest.php
index 6c2f7078752..e3b132cdcdf 100644
--- a/core/modules/views/tests/src/Kernel/ModuleTest.php
+++ b/core/modules/views/tests/src/Kernel/ModuleTest.php
@@ -152,14 +152,14 @@ class ModuleTest extends ViewsKernelTestBase {
foreach ($all_views as $id => $view) {
$expected_options[$id] = $view->label();
}
- $this->assertIdentical($expected_options, $this->castSafeStrings(Views::getViewsAsOptions(TRUE)), 'Expected options array was returned.');
+ $this->assertIdentical($expected_options, Views::getViewsAsOptions(TRUE), 'Expected options array was returned.');
// Test the default.
- $this->assertIdentical($this->formatViewOptions($all_views), $this->castSafeStrings(Views::getViewsAsOptions()), 'Expected options array for all views was returned.');
+ $this->assertEquals($this->formatViewOptions($all_views), Views::getViewsAsOptions(), 'Expected options array for all views was returned.');
// Test enabled views.
- $this->assertIdentical($this->formatViewOptions($expected_enabled), $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'enabled')), 'Expected enabled options array was returned.');
+ $this->assertEquals($this->formatViewOptions($expected_enabled), Views::getViewsAsOptions(FALSE, 'enabled'), 'Expected enabled options array was returned.');
// Test disabled views.
- $this->assertIdentical($this->formatViewOptions($expected_disabled), $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'disabled')), 'Expected disabled options array was returned.');
+ $this->assertEquals($this->formatViewOptions($expected_disabled), Views::getViewsAsOptions(FALSE, 'disabled'), 'Expected disabled options array was returned.');
// Test the sort parameter.
$all_views_sorted = $all_views;
@@ -178,7 +178,7 @@ class ModuleTest extends ViewsKernelTestBase {
$expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = (string) t('@view : @display', ['@view' => $view->id(), '@display' => $display['id']]);
}
}
- $this->assertIdentical($expected_opt_groups, $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'all', NULL, TRUE)), 'Expected option array for an option group returned.');
+ $this->assertEquals($expected_opt_groups, Views::getViewsAsOptions(FALSE, 'all', NULL, TRUE), 'Expected option array for an option group returned.');
}
/**
diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php
index 0357a6b4111..e1fd22e2659 100644
--- a/core/tests/Drupal/KernelTests/AssertContentTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertContentTrait.php
@@ -802,8 +802,6 @@ trait AssertContentTrait {
preg_match('@<title>(.*)</title>@', $this->getRawContent(), $matches);
if (isset($matches[1])) {
$actual = $matches[1];
- $actual = $this->castSafeStrings($actual);
- $title = $this->castSafeStrings($title);
if (!$message) {
$message = new FormattableMarkup('Page title @actual is equal to @expected.', [
'@actual' => var_export($actual, TRUE),
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php
index a737d9a5ef8..3541cf802c8 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php
@@ -31,8 +31,8 @@ class InspectionTest extends PluginTestBase {
$plugin = $this->mockBlockManager->createInstance($id);
$expected_definition = $this->mockBlockExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
- $this->assertIdentical($this->castSafeStrings($this->mockBlockManager->getDefinition($id)), $expected_definition);
- $this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);
+ $this->assertEquals($expected_definition, $this->mockBlockManager->getDefinition($id));
+ $this->assertEquals($expected_definition, $plugin->getPluginDefinition());
}
// Test a plugin manager that provides defaults.
foreach (['test_block1', 'test_block2'] as $id) {
@@ -40,7 +40,7 @@ class InspectionTest extends PluginTestBase {
$expected_definition = $this->defaultsTestPluginExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
$this->assertIdentical($this->defaultsTestPluginManager->getDefinition($id), $expected_definition);
- $this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);
+ $this->assertEquals($expected_definition, $plugin->getPluginDefinition());
}
}
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index afe40b747a9..ae72732df2d 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -16,7 +16,6 @@ use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\Language\Language;
use Drupal\Core\Site\Settings;
use Drupal\Core\Test\TestDatabase;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\ConfigTestTrait;
use Drupal\Tests\RandomGeneratorTrait;
use Drupal\Tests\TestRequirementsTrait;
@@ -76,7 +75,6 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
use AssertLegacyTrait;
use AssertContentTrait;
- use AssertHelperTrait;
use RandomGeneratorTrait;
use ConfigTestTrait;
use TestRequirementsTrait;
diff --git a/core/tests/Drupal/Tests/AssertHelperTrait.php b/core/tests/Drupal/Tests/AssertHelperTrait.php
index ba814d9641d..29c0b290470 100644
--- a/core/tests/Drupal/Tests/AssertHelperTrait.php
+++ b/core/tests/Drupal/Tests/AssertHelperTrait.php
@@ -17,8 +17,14 @@ trait AssertHelperTrait {
*
* @return mixed
* The input value, with MarkupInterface objects casted to string.
+ *
+ * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. There is no
+ * replacement, just use assertEquals in tests.
+ *
+ * @see https://www.drupal.org/node/3123638
*/
protected static function castSafeStrings($value) {
+ @trigger_error('AssertHelperTrait::castSafeStrings() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. There is no replacement; assertEquals() will automatically cast MarkupInterface to strings when needed. See https://www.drupal.org/node/3123638', E_USER_DEPRECATED);
if ($value instanceof MarkupInterface) {
$value = (string) $value;
}
diff --git a/core/tests/Drupal/Tests/AssertHelperTraitTest.php b/core/tests/Drupal/Tests/AssertHelperTraitTest.php
index f2e7eca6c7c..27dbee19ef7 100644
--- a/core/tests/Drupal/Tests/AssertHelperTraitTest.php
+++ b/core/tests/Drupal/Tests/AssertHelperTraitTest.php
@@ -8,12 +8,14 @@ use Drupal\Core\Render\Markup;
* @coversDefaultClass \Drupal\Tests\AssertHelperTrait
* @group simpletest
* @group Tests
+ * @group legacy
*/
class AssertHelperTraitTest extends UnitTestCase {
/**
* @covers ::castSafeStrings
* @dataProvider providerCastSafeStrings
+ * @expectDeprecation AssertHelperTrait::castSafeStrings() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. There is no replacement; assertEquals() will automatically cast MarkupInterface to strings when needed. See https://www.drupal.org/node/3123638
*/
public function testCastSafeStrings($expected, $value) {
$class = new AssertHelperTestClass();
diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php
index 3c2eb03d528..a2571764ba0 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php
@@ -5,7 +5,6 @@ namespace Drupal\Tests\Core\Extension;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator;
use Drupal\Core\Extension\ThemeExtensionList;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
@@ -14,8 +13,6 @@ use Drupal\Tests\UnitTestCase;
*/
class ModuleRequiredByThemesUninstallValidatorTest extends UnitTestCase {
- use AssertHelperTrait;
-
/**
* Instance of ModuleRequiredByThemesUninstallValidator.
*
@@ -104,7 +101,7 @@ class ModuleRequiredByThemesUninstallValidatorTest extends UnitTestCase {
];
$reasons = $this->moduleRequiredByThemeUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
/**
@@ -151,7 +148,7 @@ class ModuleRequiredByThemesUninstallValidatorTest extends UnitTestCase {
];
$reasons = $this->moduleRequiredByThemeUninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
}
diff --git a/core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php b/core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php
index 0bee0ee6d3d..4baaa19f54c 100644
--- a/core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php
@@ -2,7 +2,6 @@
namespace Drupal\Tests\Core\Extension;
-use Drupal\Tests\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
@@ -11,8 +10,6 @@ use Drupal\Tests\UnitTestCase;
*/
class RequiredModuleUninstallValidatorTest extends UnitTestCase {
- use AssertHelperTrait;
-
/**
* @var \Drupal\Core\Extension\RequiredModuleUninstallValidator|\PHPUnit\Framework\MockObject\MockObject
*/
@@ -71,7 +68,7 @@ class RequiredModuleUninstallValidatorTest extends UnitTestCase {
$expected = ["The $module module is required"];
$reasons = $this->uninstallValidator->validate($module);
- $this->assertSame($expected, $this->castSafeStrings($reasons));
+ $this->assertEquals($expected, $reasons);
}
}
diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php
index 9db833596e6..bc2b956f2d7 100644
--- a/core/tests/Drupal/Tests/UiHelperTrait.php
+++ b/core/tests/Drupal/Tests/UiHelperTrait.php
@@ -17,7 +17,6 @@ use Drupal\Core\Url;
trait UiHelperTrait {
use BrowserHtmlDebugTrait;
- use AssertHelperTrait;
use RefreshVariablesTrait;
/**
@@ -198,9 +197,6 @@ trait UiHelperTrait {
if ($edit === NULL) {
$edit = [];
}
- if (is_array($edit)) {
- $edit = $this->castSafeStrings($edit);
- }
if (isset($path)) {
$this->drupalGet($path, $options);