Issue #3108006 by mondrake, ravi.shankar, longwave: Replace assertInternalType() calls with dedicated methods

merge-requests/2419/head
Alex Pott 2020-04-11 06:35:50 +01:00
parent bcbb697561
commit 221b7aed06
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
37 changed files with 56 additions and 57 deletions

View File

@ -41,7 +41,7 @@ class MigrateBlockContentEntityDisplayTest extends MigrateDrupal7TestBase {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityViewDisplay::load($id)->getComponent($component_id);
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('hidden', $component['label']);
}

View File

@ -41,7 +41,7 @@ class MigrateBlockContentEntityFormDisplayTest extends MigrateDrupal7TestBase {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityFormDisplay::load($id)->getComponent($component_id);
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('text_textarea_with_summary', $component['type']);
}

View File

@ -52,7 +52,7 @@ class LanguageTest extends UnitTestCase {
$config = $this->plugin->getConfig($editor);
$this->assertInternalType('array', $config);
$this->assertIsArray($config);
$this->assertTrue(in_array('ar:Arabic:rtl', $config['language_list']));
$this->assertTrue(in_array('zh-hans:Chinese, Simplified', $config['language_list']));
$this->assertTrue(in_array('en:English', $config['language_list']));

View File

@ -44,7 +44,7 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal6TestBase {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityViewDisplay::load($id)->getComponent($component_id);
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('hidden', $component['label']);
$this->assertSame('comment_default', $component['type']);
$this->assertSame(20, $component['weight']);

View File

@ -38,7 +38,7 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase
*/
protected function assertSubjectVisible($id) {
$component = EntityFormDisplay::load($id)->getComponent('subject');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('string_textfield', $component['type']);
$this->assertSame(10, $component['weight']);
}

View File

@ -43,7 +43,7 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal6TestBase {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityFormDisplay::load($id)->getComponent($component_id);
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('comment_default', $component['type']);
$this->assertSame(20, $component['weight']);
}

View File

@ -42,7 +42,7 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityViewDisplay::load($id)->getComponent($component_id);
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('hidden', $component['label']);
$this->assertSame('comment_default', $component['type']);
$this->assertSame(20, $component['weight']);

View File

@ -35,7 +35,7 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase
*/
protected function assertSubjectVisible($id) {
$component = EntityFormDisplay::load($id)->getComponent('subject');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('string_textfield', $component['type']);
$this->assertSame(10, $component['weight']);
}

View File

@ -42,7 +42,7 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
*/
protected function assertDisplay($id, $component_id) {
$component = EntityFormDisplay::load($id)->getComponent($component_id);
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('comment_default', $component['type']);
$this->assertSame(20, $component['weight']);
}

View File

@ -206,7 +206,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
// reference field.
$display = EntityViewDisplay::load('node.employee.default');
$component = $display->getComponent('field_company');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('entity_reference_label', $component['type']);
// The default node reference formatter shows the referenced node's title
// as a link.
@ -214,14 +214,14 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
$display = EntityViewDisplay::load('node.employee.teaser');
$component = $display->getComponent('field_company');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('entity_reference_label', $component['type']);
// The plain node reference formatter shows the referenced node's title,
// unlinked.
$this->assertFalse($component['settings']['link']);
$component = $display->getComponent('field_commander');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('entity_reference_label', $component['type']);
// The default user reference formatter links to the referenced user.
$this->assertTrue($component['settings']['link']);

View File

@ -107,22 +107,22 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
$component = $display_repository->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('options_select', $component['type']);
$component = $display_repository->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company_2');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('options_buttons', $component['type']);
$component = $display_repository->getFormDisplay('node', 'employee', 'default')
->getComponent('field_company_3');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('entity_reference_autocomplete_tags', $component['type']);
$component = $display_repository->getFormDisplay('node', 'employee', 'default')
->getComponent('field_commander');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$this->assertSame('options_select', $component['type']);
}

View File

@ -29,7 +29,7 @@ class FieldInstanceSettingsTest extends MigrateTestCase {
->getMock();
$value = $plugin->transform([[], ['type' => 'image_image'], ['data' => '']], $executable, $row, 'foo');
$this->assertInternalType('array', $value['default_image']);
$this->assertIsArray($value['default_image']);
$this->assertSame('', $value['default_image']['alt']);
$this->assertSame('', $value['default_image']['title']);
$this->assertNull($value['default_image']['width']);

View File

@ -36,7 +36,7 @@ class FieldSettingsTest extends MigrateTestCase {
]);
$value = $plugin->transform([], $executable, $row, 'foo');
$this->assertInternalType('array', $value);
$this->assertIsArray($value);
$this->assertSame('', $value['default_image']['uuid']);
}

View File

@ -101,7 +101,7 @@ class MediaSourceOEmbedVideoTest extends MediaSourceTestBase {
$display = \Drupal::service('entity_display.repository')->getViewDisplay('media', $media_type_id);
$this->assertFalse($display->isNew());
$component = $display->getComponent('field_media_oembed_video');
$this->assertInternalType('array', $component);
$this->assertIsArray($component);
$component['settings']['max_width'] = 240;
$display->setComponent('field_media_oembed_video', $component);
$this->assertSame(SAVED_UPDATED, $display->save());

View File

@ -43,7 +43,7 @@ class OEmbedIframeControllerTest extends MediaKernelTestBase {
->get('controller_resolver')
->getControllerFromDefinition('\Drupal\media\Controller\OEmbedIframeController::render');
$this->assertInternalType('callable', $controller);
$this->assertIsCallable($controller);
$this->expectException('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException');
$this->expectExceptionMessage('This resource is not available');

View File

@ -239,7 +239,7 @@ class MediaLibraryDisplayModeTest extends BrowserTestBase {
$this->assertSame(['thumbnail'], array_keys($view_display->getComponents()));
// Assert the thumbnail image style.
$thumbnail = $view_display->getComponent('thumbnail');
$this->assertInternalType('array', $thumbnail);
$this->assertIsArray($thumbnail);
$this->assertSame($image_style, $thumbnail['settings']['image_style']);
}

View File

@ -90,7 +90,7 @@ class FileCopyTest extends FileTestBase {
clearstatcache(TRUE, $destination_path);
$timestamp = (new \SplFileInfo($file_reuse))->getMTime();
$this->assertInternalType('int', $timestamp);
$this->assertIsInt($timestamp);
// We need to make sure the modified timestamp on the file is sooner than
// the attempted migration.

View File

@ -19,7 +19,7 @@ class TimezoneTest extends KernelTestBase {
public function testSystemTimeZones() {
// Test the default parameters for system_time_zones().
$result = system_time_zones();
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertArrayHasKey('Africa/Dar_es_Salaam', $result);
$this->assertEquals('Africa/Dar es Salaam', $result['Africa/Dar_es_Salaam']);
@ -27,7 +27,7 @@ class TimezoneTest extends KernelTestBase {
$result = system_time_zones(NULL, TRUE);
// Check a two-level time zone.
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertArrayHasKey('Africa', $result);
$this->assertArrayHasKey('Africa/Dar_es_Salaam', $result['Africa']);
$this->assertEquals('Dar es Salaam', $result['Africa']['Africa/Dar_es_Salaam']);

View File

@ -87,7 +87,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
*/
public function testDefineOptions() {
$options = $this->plugin->defineOptions();
$this->assertInternalType('array', $options);
$this->assertIsArray($options);
$this->assertArrayHasKey('destination', $options);
}

View File

@ -64,7 +64,7 @@ class ViewPageControllerTest extends UnitTestCase {
$route_match = RouteMatch::createFromRequest($request);
$output = $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match);
$this->assertInternalType('array', $output);
$this->assertIsArray($output);
$this->assertEquals($build, $output);
}

View File

@ -66,9 +66,9 @@ class EntityReferenceAutocompleteWidgetTest extends WebDriverTestBase {
]);
// To satisfy config schema, the size setting must be an integer, not just
// a numeric value. See https://www.drupal.org/node/2885441.
$this->assertInternalType('integer', $form_display->getComponent($field_name)['settings']['size']);
$this->assertIsInt($form_display->getComponent($field_name)['settings']['size']);
$form_display->save();
$this->assertInternalType('integer', $form_display->getComponent($field_name)['settings']['size']);
$this->assertIsInt($form_display->getComponent($field_name)['settings']['size']);
// Visit the node add page.
$this->drupalGet('node/add/page');

View File

@ -51,7 +51,7 @@ class ContextAwarePluginBaseTest extends KernelTestBase {
* @covers ::getContextDefinitions
*/
public function testGetContextDefinitions() {
$this->assertInternalType('array', $this->plugin->getContextDefinitions());
$this->assertIsArray($this->plugin->getContextDefinitions());
}
/**

View File

@ -53,7 +53,7 @@ class ThemeRenderAndAutoescapeTest extends KernelTestBase {
$renderer = \Drupal::service('renderer');
$output = $renderer->executeInRenderContext($context, $theme_render_and_autoescape);
$this->assertEquals($expected, $output);
$this->assertInternalType('string', $output);
$this->assertIsString($output);
}
/**

View File

@ -83,7 +83,7 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
public function testGet() {
$this->setupDefaultExpectations();
$this->assertInternalType('string', $this->generator->get());
$this->assertIsString($this->generator->get());
$this->assertNotSame($this->generator->get(), $this->generator->get($this->randomMachineName()));
$this->assertNotSame($this->generator->get($this->randomMachineName()), $this->generator->get($this->randomMachineName()));
}
@ -107,7 +107,7 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
->method('setCsrfTokenSeed')
->with($this->isType('string'));
$this->assertInternalType('string', $this->generator->get());
$this->assertIsString($this->generator->get());
}
/**

View File

@ -23,9 +23,9 @@ class BatchBuilderTest extends UnitTestCase {
public function testDefaultValues() {
$batch = (new BatchBuilder())->toArray();
$this->assertInternalType('array', $batch);
$this->assertIsArray($batch);
$this->assertArrayHasKey('operations', $batch);
$this->assertInternalType('array', $batch['operations']);
$this->assertIsArray($batch['operations']);
$this->assertEmpty($batch['operations'], 'Operations array is empty.');
$this->assertEquals(new TranslatableMarkup('Processing'), $batch['title']);
$this->assertEquals(new TranslatableMarkup('Initializing.'), $batch['init_message']);
@ -34,10 +34,10 @@ class BatchBuilderTest extends UnitTestCase {
$this->assertNull($batch['finished']);
$this->assertNull($batch['file']);
$this->assertArrayHasKey('library', $batch);
$this->assertInternalType('array', $batch['library']);
$this->assertIsArray($batch['library']);
$this->assertEmpty($batch['library']);
$this->assertArrayHasKey('url_options', $batch);
$this->assertInternalType('array', $batch['url_options']);
$this->assertIsArray($batch['url_options']);
$this->assertEmpty($batch['url_options']);
$this->assertArrayHasKey('progressive', $batch);
$this->assertTrue($batch['progressive']);

View File

@ -564,7 +564,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
->method('getPropertiesToExport')
->willReturn(['id' => 'configId', 'dependencies' => 'dependencies']);
$properties = $this->entity->toArray();
$this->assertInternalType('array', $properties);
$this->assertIsArray($properties);
$this->assertEquals(['configId' => $this->entity->id(), 'dependencies' => []], $properties);
}
@ -590,7 +590,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
->with('id')
->willReturn('id');
$properties = $entity->toArray();
$this->assertInternalType('array', $properties);
$this->assertIsArray($properties);
$this->assertEquals(['configId' => $entity->id(), 'dependencies' => []], $properties);
}

View File

@ -139,15 +139,15 @@ class EntityListBuilderTest extends UnitTestCase {
$list->setRedirectDestination($this->redirectDestination);
$operations = $list->getOperations($this->role);
$this->assertInternalType('array', $operations);
$this->assertIsArray($operations);
$this->assertArrayHasKey('edit', $operations);
$this->assertInternalType('array', $operations['edit']);
$this->assertIsArray($operations['edit']);
$this->assertArrayHasKey('title', $operations['edit']);
$this->assertArrayHasKey('delete', $operations);
$this->assertInternalType('array', $operations['delete']);
$this->assertIsArray($operations['delete']);
$this->assertArrayHasKey('title', $operations['delete']);
$this->assertArrayHasKey($operation_name, $operations);
$this->assertInternalType('array', $operations[$operation_name]);
$this->assertIsArray($operations[$operation_name]);
$this->assertArrayHasKey('title', $operations[$operation_name]);
}

View File

@ -220,7 +220,7 @@ class EntityAdapterUnitTest extends UnitTestCase {
* @covers ::getConstraints
*/
public function testGetConstraints() {
$this->assertInternalType('array', $this->entityAdapter->getConstraints());
$this->assertIsArray($this->entityAdapter->getConstraints());
}
/**

View File

@ -53,7 +53,7 @@ class LockBackendAbstractTest extends UnitTestCase {
*/
public function testGetLockId() {
$lock_id = $this->lock->getLockId();
$this->assertInternalType('string', $lock_id);
$this->assertIsString($lock_id);
// Example lock ID would be '7213141505232b6ee2cb967.27683891'.
$this->assertRegExp('/[\da-f]+\.\d+/', $lock_id);
// Test the same lock ID is returned a second time.

View File

@ -333,7 +333,7 @@ class DefaultPluginManagerTest extends UnitTestCase {
$this->expectedDefinitions['banana']['provider'] = 'plugin_test';
$plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler, NULL);
$this->assertInternalType('array', $plugin_manager->getDefinitions());
$this->assertIsArray($plugin_manager->getDefinitions());
}
/**
@ -343,9 +343,9 @@ class DefaultPluginManagerTest extends UnitTestCase {
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler->reveal(), NULL);
$cache_contexts = $plugin_manager->getCacheContexts();
$this->assertInternalType('array', $cache_contexts);
$this->assertIsArray($cache_contexts);
array_map(function ($cache_context) {
$this->assertInternalType('string', $cache_context);
$this->assertIsString($cache_context);
}, $cache_contexts);
}
@ -356,9 +356,9 @@ class DefaultPluginManagerTest extends UnitTestCase {
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler->reveal(), NULL);
$cache_tags = $plugin_manager->getCacheTags();
$this->assertInternalType('array', $cache_tags);
$this->assertIsArray($cache_tags);
array_map(function ($cache_tag) {
$this->assertInternalType('string', $cache_tag);
$this->assertIsString($cache_tag);
}, $cache_tags);
}
@ -369,7 +369,7 @@ class DefaultPluginManagerTest extends UnitTestCase {
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler->reveal(), NULL);
$cache_max_age = $plugin_manager->getCacheMaxAge();
$this->assertInternalType('int', $cache_max_age);
$this->assertIsInt($cache_max_age);
}
/**

View File

@ -51,7 +51,7 @@ class YamlDirectoryDiscoveryTest extends UnitTestCase {
$definitions = $discovery->getDefinitions();
$this->assertInternalType('array', $definitions);
$this->assertIsArray($definitions);
$this->assertCount(4, $definitions);
foreach ($definitions as $id => $definition) {

View File

@ -70,7 +70,7 @@ class YamlDiscoveryDecoratorTest extends UnitTestCase {
public function testGetDefinitions() {
$definitions = $this->discoveryDecorator->getDefinitions();
$this->assertInternalType('array', $definitions);
$this->assertIsArray($definitions);
$this->assertCount(6, $definitions);
foreach ($this->expectedKeys as $expected_key) {

View File

@ -51,7 +51,7 @@ class YamlDiscoveryTest extends UnitTestCase {
public function testGetDefinitions() {
$definitions = $this->discovery->getDefinitions();
$this->assertInternalType('array', $definitions);
$this->assertIsArray($definitions);
$this->assertCount(4, $definitions);
foreach ($this->expectedKeys as $expected_key) {

View File

@ -62,7 +62,7 @@ class PrivateKeyTest extends UnitTestCase {
* Tests PrivateKey::get() with no private key from state.
*/
public function testGetNoState() {
$this->assertInternalType('string', $this->privateKey->get());
$this->assertIsString($this->privateKey->get());
}
/**

View File

@ -236,7 +236,7 @@ class UnroutedUrlTest extends UnitTestCase {
*/
public function testGetOptions($uri) {
$url = Url::fromUri($uri);
$this->assertInternalType('array', $url->getOptions());
$this->assertIsArray($url->getOptions());
}
}

View File

@ -271,7 +271,7 @@ class TokenTest extends UnitTestCase {
});
$result = $this->token->replace($string, ['tokens' => $tokens]);
$this->assertInternalType('string', $result);
$this->assertIsString($result);
$this->assertEquals($expected, $result);
}

View File

@ -26,7 +26,6 @@ trait PHPUnit8Warnings {
'Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead.',
'Using assertNotContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringNotContainsString() or assertStringNotContainsStringIgnoringCase() instead.',
'assertArraySubset() is deprecated and will be removed in PHPUnit 9.',
'assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(), assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(), assertIsResource(), assertIsString(), assertIsScalar(), assertIsCallable(), or assertIsIterable() instead.',
'readAttribute() is deprecated and will be removed in PHPUnit 9.',
'getObjectAttribute() is deprecated and will be removed in PHPUnit 9.',
'assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.',