Issue #3101247 by mondrake, longwave, Saurabh_sgh, alexpott, jhedstrom, xjm: Deprecate AssertHelperTrait::castSafeStrings() in favour of MarkupInterfaceComparator
parent
c532b2f9b2
commit
15de0783ff
|
@ -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.',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.');
|
||||
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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']])));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue