diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php index b3bd60113384c6b417fe83151d2159e74f87a565..49dc4f0ff3f727bc8b05ff3fa0fbf819f48b20b6 100644 --- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php +++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php @@ -64,7 +64,7 @@ protected function assertEntity($id) { */ protected function assertComponent($display_id, $component_id, $type, $label, $weight) { $component = EntityViewDisplay::load($display_id)->getComponent($component_id); - $this->assertTrue(is_array($component)); + $this->assertIsArray($component); $this->assertIdentical($type, $component['type']); $this->assertIdentical($label, $component['label']); $this->assertIdentical($weight, $component['weight']); diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php index ecee1a852dab51b9c777d8fc115277ba49036722..6f97ec66b5ceb3a93a1b5bcc23dfc74ac275847f 100644 --- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php +++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php @@ -71,7 +71,7 @@ protected function assertEntity($id, $expected_entity_type, $expected_bundle) { */ protected function assertComponent($display_id, $component_id, $widget_type, $weight) { $component = EntityFormDisplay::load($display_id)->getComponent($component_id); - $this->assertTrue(is_array($component)); + $this->assertIsArray($component); $this->assertIdentical($widget_type, $component['type']); $this->assertIdentical($weight, $component['weight']); } diff --git a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php index 9c17b145c4b1f25a31c231a7a6f927563f9a5ef3..05c6df74b9ff410fed3c623ff3d20e9327bdcd58 100644 --- a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php +++ b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php @@ -63,11 +63,11 @@ public function testForumMigration() { // Tests that the taxonomy_forums entity view display component exists. $entity_view_display = EntityViewDisplay::load('node.forum.default')->getComponent('taxonomy_forums'); - $this->assertTrue(is_array($entity_view_display)); + $this->assertIsArray($entity_view_display); // Tests that the taxonomy_forums entity form display component exists. $entity_form_display = EntityFormDisplay::load('node.forum.default')->getComponent('taxonomy_forums'); - $this->assertTrue(is_array($entity_form_display)); + $this->assertIsArray($entity_form_display); // Test that the taxonomy_forums field has the right value. $node = Node::load(19); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 2628bb544628228d2e98b28d75f3383bd9603a22..85881bfb8bcf4286d5c0af54d413fc9f388da27d 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -1366,7 +1366,7 @@ protected function assert406Response(ResponseInterface $response) { $this->assertSame(406, $response->getStatusCode()); $actual_link_header = $response->getHeader('Link'); if ($actual_link_header) { - $this->assertTrue(is_array($actual_link_header)); + $this->assertIsArray($actual_link_header); $expected_type = explode(';', static::$mimeType)[0]; $this->assertStringContainsString('?_format=' . static::$format . '>; rel="alternate"; type="' . $expected_type . '"', $actual_link_header[0]); $this->assertStringContainsString('?_format=foobar>; rel="alternate"', $actual_link_header[0]); diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php index 8a40b9e7b8f5f9cc9aa831b5fc1170713132fd92..606fcb4d019d4b8754016185eb4052c10bc98f00 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php @@ -50,7 +50,7 @@ public function testVocabularyEntityDisplay() { // Tests that a vocabulary named like a D8 base field will be migrated and // prefixed with 'field_' to avoid conflicts. $field_type = EntityViewDisplay::load('node.sponsor.default')->getComponent('field_type'); - $this->assertTrue(is_array($field_type)); + $this->assertIsArray($field_type); } /** diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php index 5024973bb02890b66363239f1e80daff02220da9..f768b939955468d77f6a01eabd4bf02c15d4df78 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php @@ -55,7 +55,7 @@ public function testVocabularyEntityFormDisplay() { // Tests that a vocabulary named like a D8 base field will be migrated and // prefixed with 'field_' to avoid conflicts. $field_type = EntityFormDisplay::load('node.sponsor.default')->getComponent('field_type'); - $this->assertTrue(is_array($field_type)); + $this->assertIsArray($field_type); } /** diff --git a/core/modules/views/tests/src/Functional/Handler/AreaTest.php b/core/modules/views/tests/src/Functional/Handler/AreaTest.php index 26d664d57a6f8d2fe6c243b591da3f90597ea2b0..5604790a3cbef8966b0f924c0106c9d19e63628c 100644 --- a/core/modules/views/tests/src/Functional/Handler/AreaTest.php +++ b/core/modules/views/tests/src/Functional/Handler/AreaTest.php @@ -175,7 +175,9 @@ public function testRenderAreaToken() { // Test the list of available tokens. $available = $empty_handler->getAvailableGlobalTokens(); foreach (['site', 'view'] as $type) { - $this->assertTrue(!empty($available[$type]) && is_array($available[$type])); + $this->assertNotEmpty($available[$type]); + $this->assertIsArray($available[$type]); + // Test that each item exists in the list. foreach ($available[$type] as $token => $info) { $this->assertText("[$type:$token]"); diff --git a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php index 61023b5225cafc4294619e39da028738ec7fe89a..5858ae115f25633a30ac76303df1270fa1b5cc4d 100644 --- a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php +++ b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\views\Kernel; -use Drupal\Component\Render\FormattableMarkup; use Drupal\views\Views; use Drupal\views\Plugin\views\PluginBase; @@ -65,12 +64,13 @@ protected function setUp($import_test_views = TRUE): void { */ public function testPluginData() { // Check that we have an array of data. - $this->assertTrue(is_array($this->definitions), 'Plugin data is an array.'); + $this->assertIsArray($this->definitions); // Check all plugin types. foreach ($this->pluginTypes as $type) { $this->assertArrayHasKey($type, $this->definitions); - $this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), new FormattableMarkup('Plugin type @type has an array of plugins.', ['@type' => $type])); + $this->assertIsArray($this->definitions[$type]); + $this->assertNotEmpty($this->definitions[$type], "Plugin type '$type' should contain plugins."); } // Tests that the plugin list has not missed any types. diff --git a/core/modules/views/tests/src/Kernel/ViewStorageTest.php b/core/modules/views/tests/src/Kernel/ViewStorageTest.php index af07634192fca42f06686c5d2efe069513bbbeb2..9a010be58da2c980f8a396f4e41bc07596738ecf 100644 --- a/core/modules/views/tests/src/Kernel/ViewStorageTest.php +++ b/core/modules/views/tests/src/Kernel/ViewStorageTest.php @@ -170,7 +170,9 @@ protected function displayTests() { $view->save(); $values = $this->config('views.view.test_view_storage_new_new2')->get(); - $this->assertTrue(isset($values['display']['test']) && is_array($values['display']['test']), 'New display was saved.'); + // Verify that the display was saved by ensuring it contains an array of + // values in the view data. + $this->assertIsArray($values['display']['test']); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php index 79172bce194d9361d42e05ee590e220842fff3a4..4dc11cee2a6ba1ad5f58e1d5c29c2bb8bd59feeb 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php @@ -432,7 +432,7 @@ public function testDynamicLibrary() { \Drupal::state()->set('common_test.library_info_build_test', TRUE); $library_discovery->clearCachedDefinitions(); $dynamic_library = $library_discovery->getLibraryByName('common_test', 'dynamic_library'); - $this->assertTrue(is_array($dynamic_library)); + $this->assertIsArray($dynamic_library); $this->assertArrayHasKey('version', $dynamic_library); $this->assertSame('1.0', $dynamic_library['version']); // Make sure the dynamic library definition could be altered. diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php index c164e5fb7fd7e9ad25a9c497d0ffed19c46f2341..f017aafe74ba06061ac8fe77d72c6b5247ae62da 100644 --- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php +++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php @@ -541,7 +541,7 @@ public function testTypedDataMaps() { $this->assertNull($typed_data->getValue()); $typed_data->setValue([]); $value = $typed_data->getValue(); - $this->assertTrue(isset($value) && is_array($value)); + $this->assertIsArray($value); // Test accessing invalid properties. $typed_data->setValue($value); diff --git a/core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php b/core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php index d70714bf334020051cde8016c046043915ae3d21..a710a409da310399e20bb8ac643f5e75be44f773 100644 --- a/core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php +++ b/core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php @@ -40,7 +40,7 @@ public function testNestedArraysWithNestedAnnotation() $this->assertEquals(3, count($annot->foo)); $this->assertEquals(1, $annot->foo[0]); $this->assertEquals(2, $annot->foo[1]); - $this->assertTrue(is_array($annot->foo[2])); + $this->assertIsArray($annot->foo[2]); $nestedArray = $annot->foo[2]; $this->assertTrue(isset($nestedArray['key'])); @@ -62,13 +62,13 @@ public function testBasicAnnotations() $result = $parser->parse('@Name(foo={"key1" = "value1"})'); $annot = $result[0]; $this->assertNull($annot->value); - $this->assertTrue(is_array($annot->foo)); + $this->assertIsArray($annot->foo); $this->assertTrue(isset($annot->foo['key1'])); // Numerical arrays $result = $parser->parse('@Name({2="foo", 4="bar"})'); $annot = $result[0]; - $this->assertTrue(is_array($annot->value)); + $this->assertIsArray($annot->value); $this->assertEquals('foo', $annot->value[2]); $this->assertEquals('bar', $annot->value[4]); $this->assertFalse(isset($annot->value[0])); @@ -80,7 +80,7 @@ public function testBasicAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertIsArray($annot->value); $this->assertInstanceOf(Name::class, $annot->value[0]); $this->assertInstanceOf(Name::class, $annot->value[1]); @@ -89,9 +89,9 @@ public function testBasicAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertIsArray($annot->value); $this->assertInstanceOf(Name::class, $annot->value[0]); - $this->assertTrue(is_array($annot->value[1])); + $this->assertIsArray($annot->value[1]); $this->assertEquals('value1', $annot->value[1]['key1']); $this->assertEquals('value2', $annot->value[1]['key2']); @@ -122,7 +122,7 @@ public function testDefaultValueAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertIsArray($annot->value); $this->assertEquals('value1', $annot->value['key1']); // Array as first value and additional values @@ -130,7 +130,7 @@ public function testDefaultValueAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertIsArray($annot->value); $this->assertEquals('value1', $annot->value['key1']); $this->assertEquals('bar', $annot->foo); } @@ -1108,7 +1108,8 @@ class A { try { $parser = $this->createTestParser(); $result = $parser->parse($docblock); - $this->assertTrue(is_array($result) && empty($result)); + $this->assertIsArray($result); + $this->assertEmpty($result); } catch (\Exception $e) { $this->fail($e->getMessage()); } @@ -1130,7 +1131,8 @@ class A { try { $parser = $this->createTestParser(); $result = $parser->parse($docblock); - $this->assertTrue(is_array($result) && empty($result)); + $this->assertIsArray($result); + $this->assertEmpty($result); } catch (\Exception $e) { $this->fail($e->getMessage()); }