diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index acafd7d9aa..4706e225ed 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -385,14 +385,14 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
     $placeholders = array_map(function (NodeElement $element) {
       return $element->getAttribute('data-big-pipe-placeholder-id');
     }, $this->cssSelect('[data-big-pipe-placeholder-id]'));
-    $this->assertEqual(count($expected_big_pipe_placeholders), count(array_unique($placeholders)));
+    $this->assertSame(count($expected_big_pipe_placeholders), count(array_unique($placeholders)));
     $expected_big_pipe_placeholders_with_replacements = [];
     foreach ($expected_big_pipe_placeholder_stream_order as $big_pipe_placeholder_id) {
       $expected_big_pipe_placeholders_with_replacements[$big_pipe_placeholder_id] = $expected_big_pipe_placeholders[$big_pipe_placeholder_id];
     }
     $this->assertEqual($expected_big_pipe_placeholders_with_replacements, array_filter($expected_big_pipe_placeholders));
     $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders_with_replacements), array_values($placeholder_replacement_positions));
-    $this->assertEqual(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));
+    $this->assertSame(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));
 
     $this->pass('Verifying BigPipe start/stop signals…', 'Debug');
     $this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
diff --git a/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php b/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php
index 9e415f712a..d027a6f14e 100644
--- a/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php
+++ b/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php
@@ -63,7 +63,7 @@ public function testNewDefaultThemeBlocks() {
     $new_blocks = $block_storage->getQuery()
       ->condition('theme', $new_theme)
       ->execute();
-    $this->assertEquals(count($default_block_names), count($new_blocks));
+    $this->assertSame(count($default_block_names), count($new_blocks));
 
     foreach ($default_block_names as $default_block_name) {
       // Remove the matching block from the list of blocks in the new theme.
diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php
index 4f413c45df..4006b73956 100644
--- a/core/modules/book/tests/src/Functional/BookTest.php
+++ b/core/modules/book/tests/src/Functional/BookTest.php
@@ -305,13 +305,13 @@ public function testGetTableOfContents() {
     $manager = $this->container->get('book.manager');
     $options = $manager->getTableOfContents($book->id(), 3);
     $expected_nids = [$book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[3]->id(), $nodes[6]->id(), $nodes[4]->id()];
-    $this->assertEqual(count($options), count($expected_nids));
+    $this->assertSame(count($expected_nids), count($options));
     $diff = array_diff($expected_nids, array_keys($options));
     $this->assertTrue(empty($diff), 'Found all expected option keys');
     // Exclude Node 3.
     $options = $manager->getTableOfContents($book->id(), 3, [$nodes[3]->id()]);
     $expected_nids = [$book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id()];
-    $this->assertEqual(count($options), count($expected_nids));
+    $this->assertSame(count($expected_nids), count($options));
     $diff = array_diff($expected_nids, array_keys($options));
     $this->assertTrue(empty($diff), 'Found all expected option keys after excluding Node 3');
   }
diff --git a/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php b/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php
index c984dc3b39..936eba8196 100644
--- a/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php
@@ -136,7 +136,7 @@ public function testBlockDisplay() {
     $this->assertIdenticalResultset($view, $expected_result, $map);
 
     // Check the number of results given by the display is the expected.
-    $this->assertEqual(count($view->result), $this->blockDisplayResults,
+    $this->assertCount($this->blockDisplayResults, $view->result, 
       new FormattableMarkup('There are exactly @results comments. Expected @expected',
         ['@results' => count($view->result), '@expected' => $this->blockDisplayResults]
       )
diff --git a/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php b/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php
index 298b9774ed..3f13184470 100644
--- a/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php
+++ b/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php
@@ -101,7 +101,7 @@ public function testContactLink() {
    */
   public function assertContactLinks(array $accounts, array $names) {
     $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a');
-    $this->assertEqual(count($result), count($names));
+    $this->assertSame(count($names), count($result));
     foreach ($names as $name) {
       $account = $accounts[$name];
 
diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
index 95600b43cc..a94f2f59c5 100644
--- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
+++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
@@ -64,7 +64,7 @@ public function checkHooksInvocations($expected_hooks, $actual_hooks) {
       $actual_invocations = $actual_hooks[$hook];
 
       // Check that the number of invocations is correct.
-      $this->assertEqual(count($actual_invocations), count($invocations), "$hook() was called the expected number of times.");
+      $this->assertSame(count($invocations), count($actual_invocations), "$hook() was called the expected number of times.");
 
       // Check that the hook was called for each expected argument.
       foreach ($invocations as $argument) {
@@ -336,7 +336,7 @@ public function testPurgeField() {
         ->condition('type', $bundle)
         ->condition($field_name . '.deleted', 1)
         ->execute();
-      $this->assertEqual(count($found), $count, 'Correct number of entities found after purging 2');
+      $this->assertCount($count, $found, 'Correct number of entities found after purging 2');
     }
 
     // Check hooks invocations.
diff --git a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
index 6a92626c37..3816bbddd5 100644
--- a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
@@ -52,7 +52,7 @@ public function testFieldAttachSaveLoad() {
     $entity = $storage->load($entity_id);
     // Confirm current revision loads the correct data.
     // Number of values per field loaded equals the field cardinality.
-    $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, 'Current revision: expected number of values');
+    $this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name}, 'Current revision: expected number of values');
     for ($delta = 0; $delta < $cardinality; $delta++) {
       // The field value loaded matches the one inserted or updated.
       $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$current_revision][$delta]['value'], new FormattableMarkup('Current revision: expected value %delta was found.', ['%delta' => $delta]));
@@ -62,7 +62,7 @@ public function testFieldAttachSaveLoad() {
     foreach (array_keys($values) as $revision_id) {
       $entity = $storage->loadRevision($revision_id);
       // Number of values per field loaded equals the field cardinality.
-      $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, new FormattableMarkup('Revision %revision_id: expected number of values.', ['%revision_id' => $revision_id]));
+      $this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name}, new FormattableMarkup('Revision %revision_id: expected number of values.', ['%revision_id' => $revision_id]));
       for ($delta = 0; $delta < $cardinality; $delta++) {
         // The field value loaded matches the one inserted or updated.
         $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$revision_id][$delta]['value'], new FormattableMarkup('Revision %revision_id: expected value %delta was found.', ['%revision_id' => $revision_id, '%delta' => $delta]));
@@ -256,7 +256,7 @@ public function testFieldAttachDelete() {
     // Confirm each revision loads
     foreach ($vids as $vid) {
       $revision = $controller->loadRevision($vid);
-      $this->assertEqual(count($revision->{$this->fieldTestData->field_name}), $cardinality, "The test entity revision $vid has $cardinality values.");
+      $this->assertCount($cardinality, $revision->{$this->fieldTestData->field_name}, "The test entity revision $vid has $cardinality values.");
     }
 
     // Delete revision 1, confirm the other two still load.
@@ -265,13 +265,13 @@ public function testFieldAttachDelete() {
     foreach ([0, 2] as $key) {
       $vid = $vids[$key];
       $revision = $controller->loadRevision($vid);
-      $this->assertEqual(count($revision->{$this->fieldTestData->field_name}), $cardinality, "The test entity revision $vid has $cardinality values.");
+      $this->assertCount($cardinality, $revision->{$this->fieldTestData->field_name}, "The test entity revision $vid has $cardinality values.");
     }
 
     // Confirm the current revision still loads
     $controller->resetCache();
     $current = $controller->load($entity->id());
-    $this->assertEqual(count($current->{$this->fieldTestData->field_name}), $cardinality, "The test entity current revision has $cardinality values.");
+    $this->assertCount($cardinality, $current->{$this->fieldTestData->field_name}, "The test entity current revision has $cardinality values.");
 
     // Delete all field data, confirm nothing loads
     $entity->delete();
@@ -308,7 +308,7 @@ public function testEntityCreateBundle() {
 
     // Verify the field data is present on load.
     $entity = $this->entitySaveReload($entity);
-    $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, "Data is retrieved for the new bundle");
+    $this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name}, "Data is retrieved for the new bundle");
   }
 
   /**
diff --git a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php
index bef94e1e18..b871eca2e0 100644
--- a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php
@@ -139,7 +139,7 @@ public function testEntityCountAndHasData() {
 
     $storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
     $entity = $storage->loadRevision($first_revision);
-    $this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, new FormattableMarkup('Revision %revision_id: expected number of values.', ['%revision_id' => $first_revision]));
+    $this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name_2}, new FormattableMarkup('Revision %revision_id: expected number of values.', ['%revision_id' => $first_revision]));
   }
 
   /**
diff --git a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php
index 7228716ea6..ff4d9cf1d9 100644
--- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php
+++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php
@@ -193,6 +193,8 @@ protected function _generateTestFieldValues($cardinality) {
    *   (Optional) The name of the column to check. Defaults to 'value'.
    */
   protected function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $column = 'value') {
+    $expected_values_count = count($expected_values);
+    
     // Re-load the entity to make sure we have the latest changes.
     $storage = $this->container->get('entity_type.manager')
       ->getStorage($entity->getEntityTypeId());
@@ -203,7 +205,7 @@ protected function assertFieldValues(EntityInterface $entity, $field_name, $expe
     // Filter out empty values so that they don't mess with the assertions.
     $field->filterEmptyItems();
     $values = $field->getValue();
-    $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
+    $this->assertCount($expected_values_count, $values, 'Expected number of values were saved.');
     foreach ($expected_values as $key => $value) {
       $this->assertEqual($values[$key][$column], $value, new FormattableMarkup('Value @value was saved correctly.', ['@value' => $value]));
     }
diff --git a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
index 33d69abd70..3c40df22ae 100644
--- a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
@@ -361,7 +361,7 @@ public function testDeleteNoData() {
     $entity = $this->entitySaveReload($entity);
 
     // Verify the field is present on load
-    $this->assertIdentical(count($entity->{$field_storage->getName()}), count($values), "Data in previously deleted field saves and loads correctly");
+    $this->assertCount(1, $entity->{$field_storage->getName()}, "Data in previously deleted field saves and loads correctly");
     foreach ($values as $delta => $value) {
       $this->assertEqual($entity->{$field_storage->getName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly");
     }
@@ -452,7 +452,7 @@ public function testUpdate() {
       }
       // Load back and assert there are $cardinality number of values.
       $entity = $this->entitySaveReload($entity);
-      $this->assertEqual(count($entity->field_update), $field_storage->getCardinality());
+      $this->assertCount($field_storage->getCardinality(), $entity->field_update);
       // Now check the values themselves.
       for ($delta = 0; $delta < $cardinality; $delta++) {
         $this->assertEqual($entity->field_update[$delta]->value, $delta + 1);
diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
index eb29d644a9..8dc8b01bc6 100644
--- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
@@ -221,24 +221,24 @@ public function testMultiValuedWidget() {
     $client->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $edit);
 
     $node = $node_storage->loadUnchanged($nid);
-    $this->assertEqual(count($node->{$field_name}), $cardinality, 'More files than allowed could not be saved to node.');
+    $this->assertCount($cardinality, $node->{$field_name}, 'More files than allowed could not be saved to node.');
 
     $upload_files_node_creation = [$test_file, $test_file];
     // Try to upload multiple files, but fewer than the maximum.
     $nid = $this->uploadNodeFiles($upload_files_node_creation, $field_name, $type_name, TRUE, []);
     $node = $node_storage->loadUnchanged($nid);
-    $this->assertEqual(count($node->{$field_name}), count($upload_files_node_creation), 'Node was successfully saved with multiple files.');
+    $this->assertSame(count($upload_files_node_creation), count($node->{$field_name}), 'Node was successfully saved with multiple files.');
 
     // Try to upload exactly the allowed number of files on revision.
     $this->uploadNodeFile($test_file, $field_name, $node->id(), 1, [], TRUE);
     $node = $node_storage->loadUnchanged($nid);
-    $this->assertEqual(count($node->{$field_name}), $cardinality, 'Node was successfully revised to maximum number of files.');
+    $this->assertCount($cardinality, $node->{$field_name}, 'Node was successfully revised to maximum number of files.');
 
     // Try to upload exactly the allowed number of files, new node.
     $upload_files = [$test_file, $test_file, $test_file];
     $nid = $this->uploadNodeFiles($upload_files, $field_name, $type_name, TRUE, []);
     $node = $node_storage->loadUnchanged($nid);
-    $this->assertEqual(count($node->{$field_name}), $cardinality, 'Node was successfully saved with maximum number of files.');
+    $this->assertCount($cardinality, $node->{$field_name}, 'Node was successfully saved with maximum number of files.');
   }
 
   /**
diff --git a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
index fe8b53c37a..ce1c73bc7f 100644
--- a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
+++ b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
@@ -58,7 +58,7 @@ protected function assertEntity($id, $label, array $expected_effect_plugins, arr
 
     // Check the number of effects associated with the style.
     $effects = $style->getEffects();
-    $this->assertIdentical(count($effects), count($expected_effect_plugins));
+    $this->assertSame(count($expected_effect_plugins), count($effects));
 
     $index = 0;
     foreach ($effects as $effect) {
diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
index 0c1127fffd..3d4028aa21 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
@@ -64,6 +64,7 @@ public function testBlockFilter() {
 
     // Get all blocks, for assertions later.
     $blocks = $page->findAll('css', '.js-layout-builder-block-link');
+    $blocks_count = count($blocks);
     $categories = $page->findAll('css', '.js-layout-builder-category');
 
     $filter = $assert_session->elementExists('css', '.js-layout-builder-filter');
@@ -75,7 +76,7 @@ public function testBlockFilter() {
     $filter->setValue('a');
     $this->assertAnnounceContains($init_message);
     $visible_rows = $this->filterVisibleElements($blocks);
-    $this->assertEquals(count($blocks), count($visible_rows));
+    $this->assertCount($blocks_count, $visible_rows);
 
     // Get the Content Fields category, which will be closed before filtering.
     $contentFieldsCategory = $page->find('named', ['content', 'Content fields']);
diff --git a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
index 6b41adb08b..0447ab3582 100644
--- a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
@@ -107,7 +107,7 @@ public function testFileParsing() {
         $this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, $message);
       }
 
-      $this->assertEqual(count($source_strings), count($test_strings), 'Found correct number of source strings.');
+      $this->assertSame(count($test_strings), count($source_strings), 'Found correct number of source strings.');
     }
   }
 
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateEmbeddedDataTest.php b/core/modules/migrate/tests/src/Kernel/MigrateEmbeddedDataTest.php
index bfcd801c1a..c7aa13fc73 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateEmbeddedDataTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateEmbeddedDataTest.php
@@ -58,7 +58,7 @@ public function testEmbeddedData() {
     $this->assertIdentical($results, $data_rows);
 
     // Validate the public APIs.
-    $this->assertIdentical($source->count(), count($data_rows));
+    $this->assertSame(count($data_rows), $source->count());
     $this->assertIdentical($source->getIds(), $ids);
     $expected_fields = [
       'key' => 'key',
diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
index 5e2855d3cd..fb7aaba071 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
@@ -404,7 +404,7 @@ public function testProcessRow() {
     foreach ($expected as $key => $value) {
       $this->assertSame($row->getDestinationProperty($key), $value);
     }
-    $this->assertSame(count($row->getDestination()), count($expected));
+    $this->assertSame(count($expected), count($row->getDestination()));
   }
 
   /**
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/StateFileExists.php b/core/modules/migrate_drupal/tests/src/Kernel/StateFileExists.php
index affc56be38..2e77c48928 100644
--- a/core/modules/migrate_drupal/tests/src/Kernel/StateFileExists.php
+++ b/core/modules/migrate_drupal/tests/src/Kernel/StateFileExists.php
@@ -98,7 +98,7 @@ public function testMigrationState() {
     foreach ($this->stateFileRequired as $module) {
       $this->assertArrayHasKey($module, $has_state_file, sprintf("Module '%s' should have a migrate_drupal.yml file", $module));
     }
-    $this->assertEquals(count($this->stateFileRequired), count($has_state_file));
+    $this->assertSame(count($this->stateFileRequired), count($has_state_file));
   }
 
 }
diff --git a/core/modules/node/tests/src/Functional/NodeAccessLanguageFallbackTest.php b/core/modules/node/tests/src/Functional/NodeAccessLanguageFallbackTest.php
index b0215c38b1..111b556f92 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessLanguageFallbackTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessLanguageFallbackTest.php
@@ -129,7 +129,7 @@ public function checkRecords($count, $langcode = 'hu') {
       ->condition('na.gid', 8888, '=');
     $records = $select->execute()->fetchAll();
     // Check that the expected record count is returned.
-    $this->assertEquals(count($records), $count);
+    $this->assertCount($count, $records);
     // The fallback value is 'hu' and should be set to 1. For other languages,
     // it should be set to 0. Casting to boolean lets us run that comparison.
     foreach ($records as $record) {
diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
index fea180f3ae..b422c883af 100644
--- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php
+++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
@@ -134,7 +134,7 @@ public function testNodeEdit() {
     $this->assertRaw('<details class="node-form-author js-form-wrapper form-wrapper" data-drupal-selector="edit-author" id="edit-author" open="open">');
     // Only one extra details element should now be open.
     $open_details_elements++;
-    $this->assertEqual(count($this->cssSelect('details[open="open"]')), $open_details_elements, 'Exactly one extra open &lt;details&gt; element found.');
+    $this->assertCount($open_details_elements, $this->cssSelect('details[open="open"]'),  'Exactly one extra open &lt;details&gt; element found.');
 
     // Edit the same node, save it and verify it's unpublished after unchecking
     // the 'Published' boolean_checkbox and clicking 'Save'.
diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
index 2f6cc82c99..d418fb9a14 100644
--- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
+++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
@@ -440,7 +440,7 @@ protected function doUninstallTest() {
     $language_count = count(\Drupal::configFactory()->listAll('language.content_settings.'));
     \Drupal::service('module_installer')->uninstall(['content_translation']);
     $this->rebuildContainer();
-    $this->assertEqual($language_count, count(\Drupal::configFactory()->listAll('language.content_settings.')), 'Languages have been fixed rather than deleted during content_translation uninstall.');
+    $this->assertCount($language_count, \Drupal::configFactory()->listAll('language.content_settings.'), 'Languages have been fixed rather than deleted during content_translation uninstall.');
   }
 
   /**
diff --git a/core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php b/core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php
index 6738dbf68c..5578b1ff89 100644
--- a/core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php
+++ b/core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php
@@ -28,7 +28,8 @@ public function testSelectListDynamic() {
     // Display form.
     $this->drupalGet('entity_test_rev/manage/' . $this->entity->id() . '/edit');
     $options = $this->xpath('//select[@id="edit-test-options"]/option');
-    $this->assertEqual(count($options), count($this->test) + 1);
+    $options_expected_count = count($this->test) + 1;
+    $this->assertCount($options_expected_count, $options);
     foreach ($options as $option) {
       $value = $option->getValue();
       if ($value != '_none') {
diff --git a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php
index 21b5c85580..a2e539b283 100644
--- a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php
+++ b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php
@@ -212,7 +212,7 @@ protected function doFrontPageRdfaTests() {
     $this->drupalGet(Url::fromRoute('<front>'));
 
     // Ensure that both articles are listed.
-    // $this->assertEqual(2, count($this->getRdfGraph(Url::fromRoute('<front>'), $this->baseUri)->allOfType('http://schema.org/Article')), 'Two articles found on front page.');
+    // $this->assertCount(2, $this->getRdfGraph(Url::fromRoute('<front>'), $this->baseUri)->allOfType('http://schema.org/Article'), 'Two articles found on front page.');
     $this->assertEqual(2, $this->getElementByRdfTypeCount(Url::fromRoute('<front>'), $this->baseUri, 'http://schema.org/Article'), 'Two articles found on front page.');
 
     // Test interaction count.
diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
index ddc463c907..d10f49a5dc 100644
--- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
+++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
@@ -707,7 +707,7 @@ public function testFieldapiField() {
     $this->executeView($view);
 
     $result = Json::decode($this->drupalGet('test/serialize/node-field', ['query' => ['_format' => 'json']]));
-    $this->assertEqual(count($result[2]['body']), $node->body->count(), 'Expected count of values');
+    $this->assertSame($node->body->count(), count($result[2]['body']), 'Expected count of values');
     $this->assertEqual($result[2]['body'], array_map(function ($item) {
       return $item['value'];
     }, $node->body->getValue()), 'Expected raw body values found.');
diff --git a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
index 2908ff86ee..48060def3c 100644
--- a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
+++ b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
@@ -66,7 +66,7 @@ protected function assertEntity($id, $label, $expected_size) {
 
     // Check the number of shortcuts in the set.
     $shortcuts = $shortcut_set->getShortcuts();
-    $this->assertIdentical(count($shortcuts), $expected_size);
+    $this->assertCount($expected_size, $shortcuts);
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php b/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php
index e48ba65a24..32b5272922 100644
--- a/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php
+++ b/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php
@@ -118,7 +118,7 @@ protected function _testLanguageSelectElementOptions($id, $options) {
       $this->assertEqual($option->getText(), $option_title);
       next($options);
     }
-    $this->assertEqual($count, count($options), new FormattableMarkup('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', ['@languages' => count($options), '@number' => $count]));
+    $this->assertCount($count, $options, new FormattableMarkup('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', ['@languages' => count($options), '@number' => $count]));
   }
 
 }
diff --git a/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php b/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php
index c2ca15e1fb..16b9810535 100644
--- a/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php
+++ b/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php
@@ -117,7 +117,7 @@ public function testReferenceablesWithNoLabelKey($match, $match_operator, $limit
       $this->assertTrue(empty($referenceables[$this->bundle]));
     }
     else {
-      $this->assertSame(count($referenceables[$this->bundle]), $count_limited);
+      $this->assertCount($count_limited, $referenceables[$this->bundle]);
     }
 
     // Test returned items.
diff --git a/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php b/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php
index 92b1aa48b7..dd1ac8fbfa 100644
--- a/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php
@@ -44,8 +44,7 @@ public function testTaxonomyTermMultipleLoad() {
 
     // Load the same terms again by tid.
     $terms2 = Term::loadMultiple(array_keys($terms));
-    $this->assertEqual($count, count($terms2), 'Five terms were loaded by tid.');
-    $this->assertEqual($terms, $terms2, 'Both arrays contain the same terms.');
+    $this->assertEquals($terms, $terms2, 'Both arrays contain the same terms.');
 
     // Remove one term from the array, then delete it.
     $deleted = array_shift($terms2);
diff --git a/core/modules/user/tests/src/Kernel/UserValidationTest.php b/core/modules/user/tests/src/Kernel/UserValidationTest.php
index 3884cc5925..34bea3174e 100644
--- a/core/modules/user/tests/src/Kernel/UserValidationTest.php
+++ b/core/modules/user/tests/src/Kernel/UserValidationTest.php
@@ -199,7 +199,7 @@ public function testValidation() {
    */
   protected function assertLengthViolation(EntityInterface $entity, $field_name, $length, $count = 1, $expected_index = 0) {
     $violations = $entity->validate();
-    $this->assertEqual(count($violations), $count, "Violation found when $field_name is too long.");
+    $this->assertCount($count, $violations, "Violation found when $field_name is too long.");
     $this->assertEqual($violations[$expected_index]->getPropertyPath(), "$field_name.0.value");
     $field_label = $entity->get($field_name)->getFieldDefinition()->getLabel();
     $this->assertEqual($violations[$expected_index]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => $field_label, '@max' => $length]));
diff --git a/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php b/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php
index 4fa2fd4269..0e6e1d71d5 100644
--- a/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php
@@ -81,7 +81,7 @@ public function testMiniPagerRender() {
     $view->setDisplay('page_4');
     $this->executeView($view);
     $this->assertTrue($view->get_total_rows, 'The query was set to calculate the total number of rows.');
-    $this->assertEqual(count($this->nodes), $view->total_rows, 'The total row count is equal to the number of nodes.');
+    $this->assertSame(count($this->nodes), $view->total_rows, 'The total row count is equal to the number of nodes.');
 
     $this->drupalGet('test_mini_pager_total', ['query' => ['page' => 1]]);
     $this->assertText('of ' . count($this->nodes), 'The first page shows the total row count.');
@@ -111,7 +111,7 @@ public function testMiniPagerRender() {
     $this->assertNoText('Page 1', 'The current page info shows the only page.');
     $this->assertNoText('test ››', 'The next link does not appear on the page.');
     $result = $this->xpath('//div[contains(@class, "views-row")]');
-    $this->assertEqual(count($result), count($this->nodes), 'All rows appear on the page.');
+    $this->assertSame(count($this->nodes), count($result), 'All rows appear on the page.');
 
     // Remove all items beside 1, so there should be no links shown.
     for ($i = 0; $i < 19; $i++) {
diff --git a/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php b/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php
index dd408f8786..afb696b6c6 100644
--- a/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php
@@ -190,7 +190,7 @@ public function testDateOrdering() {
         $this->executeView($view);
 
         // Verify the result.
-        $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
+        $this->assertSame(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
         $this->assertIdenticalResultset($view, $this->expectedResultSet($granularity, $reverse), [
           'views_test_data_name' => 'name',
         ], new FormattableMarkup('Result is returned correctly when ordering by granularity @granularity, @reverse.', ['@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward']));
diff --git a/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php b/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
index 941ed8d9ef..76738bcb3e 100644
--- a/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
@@ -75,7 +75,7 @@ public function testRandomOrdering() {
     $this->executeView($view);
 
     // Verify the result.
-    $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
     $this->assertIdenticalResultset($view, $this->dataSet(), [
       'views_test_data_name' => 'name',
       'views_test_data_age' => 'age',
@@ -84,7 +84,7 @@ public function testRandomOrdering() {
     // Execute a random view, we expect the result set to be different.
     $view_random = $this->getBasicRandomView();
     $this->executeView($view_random);
-    $this->assertEqual(count($this->dataSet()), count($view_random->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view_random->result), 'The number of returned rows match.');
     $this->assertNotIdenticalResultset($view_random, $view->result, [
       'views_test_data_name' => 'views_test_data_name',
       'views_test_data_age' => 'views_test_data_name',
@@ -93,7 +93,7 @@ public function testRandomOrdering() {
     // Execute a second random view, we expect the result set to be different again.
     $view_random_2 = $this->getBasicRandomView();
     $this->executeView($view_random_2);
-    $this->assertEqual(count($this->dataSet()), count($view_random_2->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view_random_2->result), 'The number of returned rows match.');
     $this->assertNotIdenticalResultset($view_random, $view->result, [
       'views_test_data_name' => 'views_test_data_name',
       'views_test_data_age' => 'views_test_data_name',
diff --git a/core/modules/views/tests/src/Kernel/Handler/SortTest.php b/core/modules/views/tests/src/Kernel/Handler/SortTest.php
index 91560495fb..7ab0fb8079 100644
--- a/core/modules/views/tests/src/Kernel/Handler/SortTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/SortTest.php
@@ -41,7 +41,7 @@ public function testNumericOrdering() {
     $this->executeView($view);
 
     // Verify the result.
-    $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
     $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age'), [
       'views_test_data_name' => 'name',
       'views_test_data_age' => 'age',
@@ -65,7 +65,7 @@ public function testNumericOrdering() {
     $this->executeView($view);
 
     // Verify the result.
-    $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
     $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age', TRUE), [
       'views_test_data_name' => 'name',
       'views_test_data_age' => 'age',
@@ -94,7 +94,7 @@ public function testStringOrdering() {
     $this->executeView($view);
 
     // Verify the result.
-    $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
     $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name'), [
       'views_test_data_name' => 'name',
       'views_test_data_age' => 'age',
@@ -118,7 +118,7 @@ public function testStringOrdering() {
     $this->executeView($view);
 
     // Verify the result.
-    $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
+    $this->assertSame(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
     $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name', TRUE), [
       'views_test_data_name' => 'name',
       'views_test_data_age' => 'age',
diff --git a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
index 1e5b716334..9e736f6e8a 100644
--- a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
+++ b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
@@ -449,7 +449,7 @@ public function testValidate() {
       $count++;
     }
 
-    $this->assertEqual(count($view->displayHandlers), $count, 'Error messages from all handlers merged.');
+    $this->assertCount($count, $view->displayHandlers, 'Error messages from all handlers merged.');
 
     // Test that a deleted display is not included.
     $display = &$view->storage->getDisplay('default');
diff --git a/core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php b/core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php
index 0ca4b57d19..64cd674192 100644
--- a/core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php
@@ -73,11 +73,12 @@ public function testRearrangeFields() {
     foreach ($reversedFields as $delta => $field) {
       $fields['fields[' . $field . '][weight]'] = $delta;
     }
+    $fields_count = count($fields);
     $this->drupalPostForm('admin/structure/views/nojs/rearrange/' . $view_name . '/default/field', $fields, t('Apply'));
     $this->assertFieldOrder($view_name, $reversedFields);
 
     // Checks that there is a remove link for each field.
-    $this->assertEqual(count($this->cssSelect('a.views-remove-link')), count($fields));
+    $this->assertCount($fields_count, $this->cssSelect('a.views-remove-link'));
   }
 
 }
diff --git a/core/modules/views_ui/tests/src/Functional/ViewsListTest.php b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php
index 63500d0add..21fea815ea 100644
--- a/core/modules/views_ui/tests/src/Functional/ViewsListTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php
@@ -74,7 +74,7 @@ public function testViewsListLimit() {
     $this->drupalGet('admin/structure/views');
 
     // Check that all the rows are listed.
-    $this->assertEqual(count($this->xpath('//tbody/tr[contains(@class,"views-ui-list-enabled")]')), $limit);
+    $this->assertCount($limit, $this->xpath('//tbody/tr[contains(@class,"views-ui-list-enabled")]'));
   }
 
 }
diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
index d57849fbff..2f512f6696 100644
--- a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
+++ b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
@@ -915,10 +915,10 @@ protected function assertEntityQuery(array $expected_values, $entity_type_id) {
 
     // Check entity query counts.
     $result = $storage->getQuery()->count()->execute();
-    $this->assertEquals(count($expected_default_revisions), $result);
+    $this->assertSame(count($expected_default_revisions), $result);
 
     $result = $storage->getAggregateQuery()->count()->execute();
-    $this->assertEquals(count($expected_default_revisions), $result);
+    $this->assertSame(count($expected_default_revisions), $result);
 
     // Check entity queries with no conditions.
     $result = $storage->getQuery()->execute();
diff --git a/core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php b/core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php
index 641dba464b..5200077619 100644
--- a/core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php
+++ b/core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php
@@ -83,7 +83,7 @@ public function testVerifyTemplateTestProviderIsAccurate() {
       ->name('composer.json')
       ->in($root . '/composer/Template');
 
-    $this->assertEquals(count($template_files), count($data));
+    $this->assertSame(count($template_files), count($data));
 
     // We could have the same number of templates but different names.
     $template_data = [];
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
index f5f7954767..941562d4bf 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
@@ -365,7 +365,7 @@ public function testUnionCount() {
     $count = $query_3->execute()->fetchField();
 
     // Ensure the counts match.
-    $this->assertEqual(count($names), $count, "The count query's result matched the number of rows in the UNION query.");
+    $this->assertSame(count($names), $count, "The count query's result matched the number of rows in the UNION query.");
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
index 53a80abc7c..c98e043e43 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
@@ -410,7 +410,7 @@ public function testCount() {
     $count = $this->entityStorage->getQuery()
       ->count()
       ->execute();
-    $this->assertIdentical($count, count($this->entities));
+    $this->assertCount($count, $this->entities);
 
     // Test count on a complex query.
     $query = $this->entityStorage->getQuery('OR');
@@ -689,11 +689,7 @@ public function testLookupKeys() {
    *   Array of expected entity IDs.
    */
   protected function assertResults($expected) {
-    $this->assertIdentical(count($this->queryResults), count($expected));
-    foreach ($expected as $value) {
-      // This also tests whether $this->queryResults[$value] is even set at all.
-      $this->assertIdentical($this->queryResults[$value], $value);
-    }
+    $this->assertEquals($expected, $this->queryResults);
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
index a5bcc73fda..f2be89d3fd 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
@@ -205,7 +205,7 @@ public function dataTestDecoupledPendingRevisions() {
    */
   public function testDecoupledPendingRevisions($sequence) {
     $revision_id = $this->doTestEditSequence($sequence);
-    $this->assertEquals(count($sequence), $revision_id);
+    $this->assertCount($revision_id, $sequence);
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
index 991862bbaf..915fe2e417 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
@@ -319,7 +319,7 @@ protected function doTestReadWrite($entity_type) {
     $this->assertTrue($entity->name[0]->isEmpty(), new FormattableMarkup('%entity_type: Name item is empty.', ['%entity_type' => $entity_type]));
     $this->assertTrue($entity->name->isEmpty(), new FormattableMarkup('%entity_type: Name field is empty.', ['%entity_type' => $entity_type]));
     $this->assertCount(1, $entity->name, new FormattableMarkup('%entity_type: Empty item is considered when counting.', ['%entity_type' => $entity_type]));
-    $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), new FormattableMarkup('%entity_type: Count matches iterator count.', ['%entity_type' => $entity_type]));
+    $this->assertCount(1, iterator_to_array($entity->name->getIterator()), new FormattableMarkup('%entity_type: Count matches iterator count.', ['%entity_type' => $entity_type]));
     $this->assertTrue($entity->name->getValue() === [0 => ['value' => NULL]], new FormattableMarkup('%entity_type: Name field value contains a NULL value.', ['%entity_type' => $entity_type]));
 
     // Test using filterEmptyItems().
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
index 985d1b8aff..208b538975 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
@@ -211,7 +211,8 @@ public function testInvalidSpecifier() {
    *   A list of indexes in the $this->entities array.
    */
   protected function assertResults($expected) {
-    $this->assertEqual(count($this->queryResults), count($expected));
+    $expected_count = count($expected);
+    $this->assertCount($expected_count, $this->queryResults);
     foreach ($expected as $key) {
       $id = $this->entities[$key]->id();
       $this->assertEqual($this->queryResults[$id], $id);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
index 2461d6b45c..58ab32abdb 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
@@ -196,7 +196,7 @@ public function testFieldWrite() {
     $connection = Database::getConnection();
     // Read the tables and check the correct values have been stored.
     $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
-    $this->assertEqual(count($rows), $this->fieldCardinality);
+    $this->assertCount($this->fieldCardinality, $rows);
     foreach ($rows as $delta => $row) {
       $expected = [
         'bundle' => $bundle,
@@ -216,10 +216,11 @@ public function testFieldWrite() {
     for ($delta = 0; $delta <= $this->fieldCardinality - 2; $delta++) {
       $values[$delta]['value'] = mt_rand(1, 127);
     }
+    $values_count = count($values);
     $entity->{$this->fieldName} = $values;
     $entity->save();
     $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
-    $this->assertEqual(count($rows), count($values));
+    $this->assertCount($values_count, $rows);
     foreach ($rows as $delta => $row) {
       $expected = [
         'bundle' => $bundle,
@@ -247,7 +248,7 @@ public function testFieldWrite() {
     // Check that data for both revisions are in the revision table.
     foreach ($revision_values as $revision_id => $values) {
       $rows = $connection->select($this->revisionTable, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
-      $this->assertEqual(count($rows), min(count($values), $this->fieldCardinality));
+      $this->assertCount(min(count($values), $this->fieldCardinality), $rows);
       foreach ($rows as $delta => $row) {
         $expected = [
           'bundle' => $bundle,
diff --git a/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php b/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php
index 0381e2e9ff..83854c8243 100644
--- a/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php
@@ -31,7 +31,7 @@ public function testInstallerTranslationFiles() {
     $file_translation = new FileTranslation('core/tests/fixtures/files/translations', $this->container->get('file_system'));
     foreach ($expected_translation_files as $langcode => $files_expected) {
       $files_found = $file_translation->findTranslationFiles($langcode);
-      $this->assertTrue(count($files_found) == count($files_expected), new FormattableMarkup('@count installer languages found.', ['@count' => count($files_expected)]));
+      $this->assertSame(count($files_expected), count($files_found), FormattableMarkup('@count installer languages found.', ['@count' => count($files_expected)]));
       foreach ($files_found as $file) {
         $this->assertContains($file->filename, $files_expected, new FormattableMarkup('@file found.', ['@file' => $file->filename]));
       }
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
index e9cc096355..c537bef407 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
@@ -77,12 +77,10 @@ public function testCRUDWithExpiration() {
     // Verify that all items in a collection can be retrieved.
     // Ensure that an item with the same name exists in the other collection.
     $stores[1]->set('foo', $this->objects[5]);
-    $result = $stores[0]->getAll();
+
     // Not using assertSame(), since the order is not defined for getAll().
-    $this->assertEqual(count($result), count($values));
-    foreach ($result as $key => $value) {
-      $this->assertEqual($values[$key], $value);
-    }
+    $this->assertEquals($values, $stores[0]->getAll());
+
     // Verify that all items in the other collection are different.
     $result = $stores[1]->getAll();
     $this->assertEqual($result, ['foo' => $this->objects[5]]);
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
index fe75d7a428..1055daefd1 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
@@ -101,12 +101,10 @@ public function testCRUD() {
     // Verify that all items in a collection can be retrieved.
     // Ensure that an item with the same name exists in the other collection.
     $stores[1]->set('foo', $this->objects[5]);
-    $result = $stores[0]->getAll();
+
     // Not using assertSame(), since the order is not defined for getAll().
-    $this->assertEqual(count($result), count($values));
-    foreach ($result as $key => $value) {
-      $this->assertEqual($values[$key], $value);
-    }
+    $this->assertEquals($values, $stores[0]->getAll());
+
     // Verify that all items in the other collection are different.
     $result = $stores[1]->getAll();
     $this->assertEqual($result, ['foo' => $this->objects[5]]);
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
index 14e6171aa9..fd005b6ed2 100644
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
@@ -426,8 +426,8 @@ protected function assertMenuLink($id, array $expected_properties, array $parent
     $query->condition('id', $parents, 'IN');
     $found_parents = $query->execute()->fetchAllKeyed(0, 1);
 
-    $this->assertEqual(count($parents), count($found_parents), 'Found expected number of parents');
-    $this->assertEqual($raw['depth'], count($found_parents), 'Number of parents is the same as the depth');
+    $this->assertSame(count($parents), count($found_parents), 'Found expected number of parents');
+    $this->assertCount($raw['depth'], $found_parents, 'Number of parents is the same as the depth');
 
     $materialized_path = $this->treeStorage->getRootPathIds($id);
     $this->assertEqual(array_values($materialized_path), array_values($parents), 'Parents match the materialized path');
@@ -446,7 +446,7 @@ protected function assertMenuLink($id, array $expected_properties, array $parent
     $found_children = array_keys($this->treeStorage->loadAllChildren($id));
     // We need both these checks since the 2nd will pass if there are extra
     // IDs loaded in $found_children.
-    $this->assertEqual(count($children), count($found_children), "Found expected number of children for $id");
+    $this->assertSame(count($children), count($found_children), "Found expected number of children for $id");
     $this->assertEqual(array_intersect($children, $found_children), $children, 'Child IDs match');
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
index 0d4252944d..7281e83402 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
@@ -284,7 +284,7 @@ public function testDuplicateRoutePaths($path, $number, $expected_route_name = N
 
     $request = Request::create($path);
     $routes = $provider->getRouteCollectionForRequest($request);
-    $this->assertEquals($number, count($routes), 'The correct number of routes was found.');
+    $this->assertCount($number, $routes, 'The correct number of routes was found.');
     if ($expected_route_name) {
       $route_name = key(current($routes));
       $this->assertEquals($expected_route_name, $route_name, 'The expected route name was found.');
diff --git a/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php
index 1c7290b1bd..6202f3f4fe 100644
--- a/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php
@@ -54,7 +54,7 @@ public function testDiscovery() {
     $discovery = new YamlDiscovery('test', $directories);
     $data = $discovery->findAll();
 
-    $this->assertEquals(count($data), count($directories));
+    $this->assertCount(4, $data);
     $this->assertArrayHasKey('test_1', $data);
     $this->assertArrayHasKey('test_2', $data);
     $this->assertArrayHasKey('test_3', $data);
diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
index ea61abc588..fa37326fd0 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
@@ -126,7 +126,7 @@ public function testRandomObject() {
     $random = new Random();
     for ($i = 0; $i <= 1; $i++) {
       $obj = $random->object($i);
-      $this->assertEquals($i, count(get_object_vars($obj)), 'Generated random object has expected number of properties');
+      $this->assertCount($i, get_object_vars($obj), 'Generated random object has expected number of properties');
     }
   }
 
