From db5736651c0625fd47085df96bcd3fd9d882ab90 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Thu, 19 Dec 2024 13:00:32 +1000 Subject: [PATCH] Issue #3477205 by quietone, smustgrave, alexpott: Use DrupalPractice.CodeAnalysis.VariableAnalysis in core/tests --- core/phpcs.xml.dist | 1 - .../FunctionalJavascriptTests/Ajax/MultiFormTest.php | 2 +- .../FunctionalJavascriptTests/WebDriverCurlService.php | 2 +- .../Drupal/KernelTests/Core/Database/ConnectionTest.php | 4 ++-- .../KernelTests/Core/Database/DeleteTruncateTest.php | 3 +++ .../Core/Database/DriverSpecificTransactionTestBase.php | 9 ++++++++- .../tests/Drupal/KernelTests/Core/Database/QueryTest.php | 2 +- .../Drupal/KernelTests/Core/Database/StatementTest.php | 4 +++- .../Core/Datetime/DatelistElementFormTest.php | 2 +- .../KernelTests/Core/Datetime/Element/TimezoneTest.php | 2 +- .../Core/DependencyInjection/AutowireTest.php | 3 +-- .../KernelTests/Core/DrupalKernel/DrupalKernelTest.php | 2 +- .../Drupal/KernelTests/Core/Entity/BundleClassTest.php | 6 +++--- .../Drupal/KernelTests/Core/Entity/EntityFieldTest.php | 2 +- .../KernelTests/Core/Entity/EntityTranslationTest.php | 2 +- .../Core/Entity/FieldableEntityDefinitionUpdateTest.php | 2 +- .../ImmutablePropertiesConstraintValidatorTest.php | 2 +- .../KernelTests/Core/File/FileUrlGeneratorTest.php | 6 +++--- .../Drupal/KernelTests/Core/File/StreamWrapperTest.php | 2 -- .../Core/Theme/Stable9TemplateOverrideTest.php | 2 +- core/tests/Drupal/KernelTests/KernelTestBase.php | 1 - .../KernelTests/Scripts/TestSiteApplicationTest.php | 5 ----- .../Drupal/Tests/Component/Datetime/DateTimePlusTest.php | 2 +- .../Component/DependencyInjection/ContainerTest.php | 2 +- .../Drupal/Tests/Component/Gettext/PoHeaderTest.php | 3 +-- .../Drupal/Tests/Component/Utility/RectangleTest.php | 4 ++-- .../Tests/Core/Asset/CssCollectionRendererUnitTest.php | 2 -- core/tests/Drupal/Tests/Core/Database/ConnectionTest.php | 2 +- .../Drupal/Tests/Core/Database/UrlConversionTest.php | 2 +- .../Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php | 2 +- core/tests/Drupal/Tests/Core/DrupalTest.php | 2 +- .../Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php | 4 ---- .../Drupal/Tests/Core/Entity/EntityFieldManagerTest.php | 6 +++--- .../Core/Entity/Routing/DefaultHtmlRouteProviderTest.php | 2 +- .../Tests/Core/PathProcessor/PathProcessorTest.php | 8 -------- .../Core/Render/MetadataBubblingUrlGeneratorTest.php | 2 -- .../Tests/Core/Render/RendererPlaceholdersTest.php | 6 +++--- .../Drupal/Tests/Core/Render/RendererRecursionTest.php | 9 ++++----- .../Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php | 2 -- .../Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php | 2 +- .../Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php | 2 +- core/tests/Drupal/Tests/Core/UnroutedUrlTest.php | 2 +- core/tests/Drupal/Tests/Core/UrlTest.php | 2 +- core/tests/Drupal/Tests/PerformanceTestTrait.php | 2 +- core/tests/bootstrap.php | 2 +- 45 files changed, 60 insertions(+), 78 deletions(-) diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 37880aa56323..db70c7c6e684 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -158,7 +158,6 @@ <rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis"> <exclude-pattern>*/Functional/*</exclude-pattern> <exclude-pattern>*/FunctionalJavascript/*</exclude-pattern> - <exclude-pattern>*/core/tests/*</exclude-pattern> <exclude-pattern>*/core/profiles/*/tests/*</exclude-pattern> <!-- Do not run this sniff on API files or transliteration data. --> <exclude-pattern>*.api.php</exclude-pattern> diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php index 238474e5ae7b..6a0026976a90 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php @@ -91,7 +91,7 @@ public function testMultiForm(): void { for ($i = 0; $i < 2; $i++) { $forms = $page->findAll('xpath', $form_xpath); - foreach ($forms as $offset => $form) { + foreach ($forms as $form) { $button = $form->findButton('Add another item'); $this->assertNotNull($button, 'Add Another Item button exists'); $button->press(); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php index 6237e447f492..bae02bf2b905 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php @@ -136,7 +136,7 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions $info = curl_getinfo($curl); $info['request_method'] = $requestMethod; - if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) && $extraOptions[CURLOPT_FAILONERROR] && CURLE_GOT_NOTHING !== ($errno = curl_errno($curl)) && $error = curl_error($curl)) { + if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) && $extraOptions[CURLOPT_FAILONERROR] && CURLE_GOT_NOTHING !== curl_errno($curl) && $error = curl_error($curl)) { curl_close($curl); throw WebDriverException::factory(WebDriverException::CURL_EXEC, sprintf("Curl error thrown for http %s to %s%s\n\n%s", $requestMethod, $url, $parameters && is_array($parameters) ? ' with params: ' . json_encode($parameters) : '', $error)); diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php index ef8ce03f1c11..80a04707573e 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php @@ -128,7 +128,7 @@ public function testPerTablePrefixOption(): void { ]; Database::addConnectionInfo('default', 'foo', $new_connection_info); $this->expectException(\AssertionError::class); - $foo_connection = Database::getConnection('foo', 'default'); + Database::getConnection('foo', 'default'); } /** @@ -142,7 +142,7 @@ public function testPrefixArrayOption(): void { ]; Database::addConnectionInfo('default', 'foo', $new_connection_info); $this->expectException(\AssertionError::class); - $foo_connection = Database::getConnection('foo', 'default'); + Database::getConnection('foo', 'default'); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php index 4a40641a92b2..0c5da802929d 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php @@ -77,6 +77,7 @@ public function testTruncateInTransaction(): void { $num_records_before = $this->connection->select('test')->countQuery()->execute()->fetchField(); $this->assertGreaterThan(0, $num_records_before, 'The table is not empty.'); + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable $transaction = $this->connection->startTransaction('test_truncate_in_transaction'); $this->connection->insert('test') ->fields([ @@ -98,6 +99,7 @@ public function testTruncateInTransaction(): void { // Close the transaction, and check that there are still no records in the // table. + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable $transaction = NULL; $this->assertFalse($this->connection->inTransaction()); $num_records_after = $this->connection->select('test')->countQuery()->execute()->fetchField(); @@ -111,6 +113,7 @@ public function testTruncateTransactionRollback(): void { $num_records_before = $this->connection->select('test')->countQuery()->execute()->fetchField(); $this->assertGreaterThan(0, $num_records_before, 'The table is not empty.'); + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable $transaction = $this->connection->startTransaction('test_truncate_in_transaction'); $this->connection->insert('test') ->fields([ diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php index 50a62374099c..da331170fada 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php @@ -239,6 +239,7 @@ public function testRollbackRootAfterSavepointRollback(): void { */ public function testRollbackRootWithActiveSavepoint(): void { $transaction = $this->createRootTransaction(); + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $savepoint = $this->createFirstSavepointTransaction(); // Try to rollback root. Since a savepoint is active, this should fail. @@ -278,6 +279,7 @@ public function testRollbackSavepoint(): void { * Tests savepoint transaction duplicated rollback. */ public function testRollbackTwiceSameSavepoint(): void { + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $transaction = $this->createRootTransaction(); $savepoint = $this->createFirstSavepointTransaction(); @@ -312,11 +314,13 @@ public function testRollbackTwiceSameSavepoint(): void { * Tests savepoint transaction rollback failure when later savepoints exist. */ public function testRollbackSavepointWithLaterSavepoint(): void { + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $transaction = $this->createRootTransaction(); $savepoint1 = $this->createFirstSavepointTransaction(); // Starts another savepoint transaction. Corresponds to 'SAVEPOINT // savepoint_2' on the database. + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $savepoint2 = $this->connection->startTransaction(); $this->assertTrue($this->connection->inTransaction()); $this->assertSame(3, $this->connection->transactionManager()->stackDepth()); @@ -706,10 +710,12 @@ public function testReleaseIntermediateSavepoint(): void { $this->assertSame(3, $this->connection->transactionManager()->stackDepth()); // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_3' // on the database. + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $savepoint3 = $this->connection->startTransaction(); $this->assertSame(4, $this->connection->transactionManager()->stackDepth()); // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_4' // on the database. + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $savepoint4 = $this->connection->startTransaction(); $this->assertSame(5, $this->connection->transactionManager()->stackDepth()); @@ -736,6 +742,7 @@ public function testReleaseIntermediateSavepoint(): void { */ public function testCommitWithActiveSavepoint(): void { $transaction = $this->createRootTransaction(); + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis $savepoint1 = $this->createFirstSavepointTransaction('', FALSE); // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_2' @@ -774,7 +781,7 @@ public function testTransactionName(): void { $this->expectException(TransactionNameNonUniqueException::class); $this->expectExceptionMessage("savepoint_1 is already in use."); - $savepointFailure = $this->connection->startTransaction('savepoint_1'); + $this->connection->startTransaction('savepoint_1'); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php index 6a0f4355ca22..d21f512b542c 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php @@ -30,7 +30,7 @@ public function testArraySubstitution(): void { */ public function testScalarSubstitution(): void { try { - $names = $this->connection->query('SELECT [name] FROM {test} WHERE [age] IN ( :ages[] ) ORDER BY [age]', [':ages[]' => 25])->fetchAll(); + $this->connection->query('SELECT [name] FROM {test} WHERE [age] IN ( :ages[] ) ORDER BY [age]', [':ages[]' => 25])->fetchAll(); $this->fail('Array placeholder with scalar argument should result in an exception.'); } catch (\Exception $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php b/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php index e14f39cb30da..37a0bbf47089 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php @@ -186,9 +186,11 @@ public function testEmptyStatementRewind(): void { $count = 0; + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis foreach ($statement as $row) { $count++; } + // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis foreach ($statement as $row) { $count++; } @@ -209,7 +211,7 @@ public function testStatementCountTwice(): void { $this->expectException(DatabaseExceptionWrapper::class); $this->expectExceptionMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); - $rowCount = iterator_count($statement); + iterator_count($statement); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php index 8df18f1b4291..dc231832e2f2 100644 --- a/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php @@ -124,7 +124,7 @@ public function testDatelistElement(): void { public function testDatelistElementUntrustedCallbacks() : void { $this->expectException(UntrustedCallbackException::class); $this->expectExceptionMessage(sprintf('Datelist element #date_date_callbacks callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/3217966', Variable::callableToString([$this, 'datelistDateCallback']))); - $form = \Drupal::formBuilder()->getForm($this, 'datelistDateCallback'); + \Drupal::formBuilder()->getForm($this, 'datelistDateCallback'); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php index 491e37ae818d..a66df34d7bd3 100644 --- a/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php +++ b/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php @@ -342,7 +342,7 @@ public function assertDateTimezonePropertyProcessed(string $elementType): void { // Check the #date_timezone property on each processed test element. $wrongTimezones = []; - foreach ($form_state->getCompleteForm() as $elementName => $element) { + foreach ($form_state->getCompleteForm() as $element) { if (isset($element['#type']) && $element['#type'] === $this->elementType) { // Check the correct timezone is set on the value object. $actualTimezone = array_search($element['#date_timezone'], $this->timezones, TRUE); diff --git a/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php b/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php index 7601550d1d06..98c7479c9c11 100644 --- a/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php +++ b/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php @@ -137,7 +137,6 @@ public function testCoreServiceAliases(): void { * Tests that core controllers are autowired where possible. */ public function testCoreControllerAutowiring(): void { - $services = []; $aliases = []; $filenames = array_map(fn($module) => "core/modules/{$module[0]}/{$module[0]}.services.yml", $this->coreModuleListDataProvider()); @@ -173,7 +172,7 @@ public function testCoreControllerAutowiring(): void { continue; } $constructor = new \ReflectionMethod($controller, '__construct'); - foreach ($constructor->getParameters() as $pos => $parameter) { + foreach ($constructor->getParameters() as $parameter) { $interface = (string) $parameter->getType(); if (!isset($aliases[$interface])) { continue 2; diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index f81f5ab6a563..b51cbf26d041 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -318,7 +318,7 @@ public function testLocale(): void { // Test environment locale should be UTF-8. $this->assertSame($utf8_string, escapeshellcmd($utf8_string)); $request = Request::createFromGlobals(); - $kernel = $this->getTestKernel($request); + $this->getTestKernel($request); // Kernel environment locale should be UTF-8. $this->assertSame($utf8_string, escapeshellcmd($utf8_string)); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php b/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php index 3704d5c6478a..635eb3550a83 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php @@ -151,7 +151,7 @@ public function testEntitySubclass(): void { $entity_test_1->id(), $entity_test_2->id(), ]; - $entities = $this->storage->loadMultiple($entity_ids); + $this->storage->loadMultiple($entity_ids); // postLoad() should only have been called once more so far. $this->assertEquals(2, EntityTestBundleClass::$postLoadCount); $this->assertCount(2, EntityTestBundleClass::$postLoadEntitiesCount); @@ -165,7 +165,7 @@ public function testEntitySubclass(): void { // Reset the storage cache and try loading again. $this->storage->resetCache(); - $entities = $this->storage->loadMultiple($entity_ids); + $this->storage->loadMultiple($entity_ids); $this->assertEquals(3, EntityTestBundleClass::$postLoadCount); $this->assertCount(3, EntityTestBundleClass::$postLoadEntitiesCount); // This time, all 3 bundle_class entities should be included. @@ -244,7 +244,7 @@ public function testAmbiguousBundleClassExceptionEntityTypeRepository(): void { // Now that we have an entity bundle class that's shared by two entirely // different entity types, we expect an exception to be thrown. $this->expectException(AmbiguousBundleClassException::class); - $entity_type = $this->container->get('entity_type.repository')->getEntityTypeFromClass(EntityTestAmbiguousBundleClass::class); + $this->container->get('entity_type.repository')->getEntityTypeFromClass(EntityTestAmbiguousBundleClass::class); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php index 77c71b04baae..b6051420b4c0 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php @@ -884,7 +884,7 @@ public function testComputedFields(): void { // Test \Drupal\Core\TypedData\ComputedItemListTrait::getIterator(). $entity = EntityTestComputedField::create([]); - foreach ($entity->computed_string_field as $delta => $item) { + foreach ($entity->computed_string_field as $item) { $this->assertSame('foo computed', $item->value); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php index 375064f0d0d8..35b18ce53ca3 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php @@ -946,7 +946,7 @@ public function testTranslationStatus(): void { $entity = $storage->load($entity->id()); $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($entity->language()->getId())); - foreach ($this->langcodes as $key => $langcode) { + foreach ($this->langcodes as $langcode) { // Test that after adding a new translation it has the translation status // TRANSLATION_CREATED. $entity->addTranslation($langcode, $values); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php index 42ea0392141f..1f0f9762070d 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php @@ -229,7 +229,7 @@ protected function insertData($revisionable, $translatable): void { protected function assertEntityData(bool $revisionable, bool $translatable): void { $entities = $this->entityTypeManager->getStorage($this->entityTypeId)->loadMultiple(); $this->assertCount(3, $entities); - foreach ($entities as $entity_id => $entity) { + foreach ($entities as $entity) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $this->assertEquals("test entity - {$entity->id()} - en", $entity->label()); $this->assertEquals("bundle field - {$entity->id()} - en", $entity->new_bundle_field->value); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php index 233c9808a13a..be935baf42a7 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php @@ -56,7 +56,7 @@ public function testValidatorRejectsANonExistentProperty(): void { $this->expectException(LogicException::class); $this->expectExceptionMessage("The entity does not have a 'non_existent' property."); - $violations = $this->container->get(TypedDataManagerInterface::class) + $this->container->get(TypedDataManagerInterface::class) ->create($definition, $entity) ->validate(); } diff --git a/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php b/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php index a505e245412c..8d9064a53050 100644 --- a/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php @@ -43,7 +43,7 @@ protected function setUp(): void { */ public function testGenerateMissingStreamWrapper(): void { $this->expectException(InvalidStreamWrapperException::class); - $result = $this->fileUrlGenerator->generate("foo://bar"); + $this->fileUrlGenerator->generate("foo://bar"); } /** @@ -53,7 +53,7 @@ public function testGenerateMissingStreamWrapper(): void { */ public function testGenerateStringMissingStreamWrapper(): void { $this->expectException(InvalidStreamWrapperException::class); - $result = $this->fileUrlGenerator->generateString("foo://bar"); + $this->fileUrlGenerator->generateString("foo://bar"); } /** @@ -63,7 +63,7 @@ public function testGenerateStringMissingStreamWrapper(): void { */ public function testGenerateAbsoluteStringMissingStreamWrapper(): void { $this->expectException(InvalidStreamWrapperException::class); - $result = $this->fileUrlGenerator->generateAbsoluteString("foo://bar"); + $this->fileUrlGenerator->generateAbsoluteString("foo://bar"); } /** diff --git a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php index 9f76384d9317..b1ebb1c0936b 100644 --- a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php @@ -74,8 +74,6 @@ public function testGetInstanceByScheme(): void { * Tests the getViaUri() and getViaScheme() methods and target functions. */ public function testUriFunctions(): void { - $config = $this->config('system.file'); - /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */ $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager'); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php index aa6f76ff69c1..8bff2c9c3305 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php @@ -98,7 +98,7 @@ public function testStable9TemplateOverrides(): void { $registry_full = $registry->get(); - foreach ($registry_full as $hook => $info) { + foreach ($registry_full as $info) { if (isset($info['template'])) { // Allow skipping templates. if (in_array($info['template'], $this->templatesToSkip)) { diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 172d70bdfbee..9a78dbf58f58 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -352,7 +352,6 @@ protected function bootKernel() { // When a module is providing the database driver, then enable that module. $connection_info = Database::getConnectionInfo(); - $driver = $connection_info['default']['driver']; $namespace = $connection_info['default']['namespace'] ?? ''; $autoload = $connection_info['default']['autoload'] ?? ''; if (str_contains($autoload, 'src/Driver/Database/')) { diff --git a/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php b/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php index 4c5bf956fe08..02521bdda2f8 100644 --- a/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php +++ b/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php @@ -89,8 +89,6 @@ public function testInstallWithNonSetupClass(): void { * @coversNothing */ public function testInstallScript(): void { - $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest'; - // Install a site using the JSON output. $command_line = $this->php . ' core/scripts/test-site.php install --json --setup-file core/tests/Drupal/TestSite/TestSiteInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"'; $process = Process::fromShellCommandline($command_line, $this->root); @@ -186,8 +184,6 @@ public function testInstallScript(): void { * @coversNothing */ public function testInstallInDifferentLanguage(): void { - $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest'; - $command_line = $this->php . ' core/scripts/test-site.php install --json --langcode fr --setup-file core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"'; $process = Process::fromShellCommandline($command_line, $this->root); $process->setTimeout(500); @@ -233,7 +229,6 @@ public function testTearDownDbPrefixValidation(): void { */ public function testUserLogin(): void { $this->markTestIncomplete('Fix this test in https://www.drupal.org/project/drupal/issues/2962157.'); - $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest'; // Install a site using the JSON output. $command_line = $this->php . ' core/scripts/test-site.php install --json --setup-file core/tests/Drupal/TestSite/TestSiteInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"'; diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php index d61e5016bf5f..74ba7f14dfd2 100644 --- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php @@ -91,7 +91,7 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte public function testInvalidDateDiff($input1, $input2, $absolute): void { $this->expectException(\BadMethodCallException::class); $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object'); - $interval = $input1->diff($input2, $absolute); + $input1->diff($input2, $absolute); } /** diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php index c3370af5b305..28239c71cda1 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php @@ -72,7 +72,7 @@ public function testConstruct(): void { $container_definition = $this->getMockContainerDefinition(); $container_definition['machine_format'] = !$this->machineFormat; $this->expectException(InvalidArgumentException::class); - $container = new $this->containerClass($container_definition); + new $this->containerClass($container_definition); } /** diff --git a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php index 17c26a0b36e0..d5c97bdb8c7e 100644 --- a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php +++ b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php @@ -31,8 +31,7 @@ class PoHeaderTest extends TestCase { */ public function testPluralsFormula($plural, $expected): void { $p = new PoHeader(); - $parsed = $p->parsePluralForms($plural); - [$nplurals, $new_plural] = $parsed; + [, $new_plural] = $p->parsePluralForms($plural); foreach ($expected as $number => $plural_form) { $result = $new_plural[$number] ?? $new_plural['default']; $this->assertEquals($result, $plural_form, 'Difference found at ' . $number . ': ' . $plural_form . ' versus ' . $result); diff --git a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php index f7a77f6e7db5..5635173a6de6 100644 --- a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php @@ -20,7 +20,7 @@ class RectangleTest extends TestCase { */ public function testWrongWidth(): void { $this->expectException(\InvalidArgumentException::class); - $rect = new Rectangle(-40, 20); + new Rectangle(-40, 20); } /** @@ -30,7 +30,7 @@ public function testWrongWidth(): void { */ public function testWrongHeight(): void { $this->expectException(\InvalidArgumentException::class); - $rect = new Rectangle(40, 0); + new Rectangle(40, 0); } /** diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php index 3c38cfbac805..7a75824bef44 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php @@ -7,7 +7,6 @@ use Drupal\Core\Asset\AssetQueryStringInterface; use Drupal\Core\Asset\CssCollectionRenderer; use Drupal\Core\File\FileUrlGeneratorInterface; -use Drupal\Core\State\StateInterface; use Drupal\Tests\UnitTestCase; /** @@ -36,7 +35,6 @@ class CssCollectionRendererUnitTest extends UnitTestCase { */ protected function setUp(): void { parent::setUp(); - $state = $this->prophesize(StateInterface::class); $assetQueryString = $this->prophesize(AssetQueryStringInterface::class); $file_url_generator = $this->createMock(FileUrlGeneratorInterface::class); $file_url_generator->expects($this->any()) diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php index 7e9ae828063d..15e4cf28aa1a 100644 --- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php @@ -61,7 +61,7 @@ public function testPrefixRoundTrip($expected, $prefix_info): void { // Set the prefix data. $set_prefix->invokeArgs($connection, [$prefix_info]); // Check the round-trip. - foreach ($expected as $table => $prefix) { + foreach ($expected as $prefix) { $this->assertEquals($prefix, $connection->getPrefix()); } } diff --git a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php index c915fe5dcda5..e4ee655b3eab 100644 --- a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php +++ b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php @@ -487,7 +487,7 @@ public function testGetInvalidArgumentGetConnectionInfoAsUrl(array $connection_o Database::addConnectionInfo('default', 'default', $connection_options); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage($expected_exception_message); - $url = Database::getConnectionInfoAsUrl(); + Database::getConnectionInfoAsUrl(); } /** diff --git a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php index e2938730208a..e1ec84395f9d 100644 --- a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php +++ b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php @@ -50,7 +50,7 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte public function testInvalidDateDiff($input1, $input2, $absolute): void { $this->expectException(\BadMethodCallException::class); $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object'); - $interval = $input1->diff($input2, $absolute); + $input1->diff($input2, $absolute); } /** diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php index a7394a51d5c5..e4f566698821 100644 --- a/core/tests/Drupal/Tests/Core/DrupalTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php @@ -467,7 +467,7 @@ public function testPhpConstants(): void { * The value to return from the mocked container get() method. */ protected function setMockContainerService($service_name, $return = NULL): void { - $expects = $this->container->expects($this->once()) + $this->container->expects($this->once()) ->method('get') ->with($service_name) ->willReturn($return ?? new \stdClass()); diff --git a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php index a70c9b4c8ce2..ae2d5c22c226 100644 --- a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php @@ -215,10 +215,6 @@ public function testFieldInitialValue(): void { ]; $expected_default_value = [$default_value]; $definition->setInitialValue($default_value); - $entity = $this->getMockBuilder(ContentEntityBaseMockableClass::class) - ->disableOriginalConstructor() - ->onlyMethods([]) - ->getMock(); // Set the field item list class to be used to avoid requiring the typed // data manager to retrieve it. $definition->setClass('Drupal\Core\Field\FieldItemList'); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php index e573bf54d350..243069049c70 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php @@ -313,7 +313,7 @@ public function testGetFieldStorageDefinitions(): void { $this->moduleHandler->invokeAllWith('entity_base_field_info', Argument::any()); $this->moduleHandler->invokeAllWith('entity_field_storage_info', Argument::any()) ->will(function ($arguments) use ($definitions) { - [$hook, $callback] = $arguments; + [, $callback] = $arguments; $callback( function () use ($definitions) { return $definitions; @@ -486,7 +486,7 @@ public function testGetFieldStorageDefinitionsWithCaching(): void { $this->moduleHandler->invokeAllWith('entity_field_storage_info', Argument::any()) ->will(function ($arguments) use ($definitions) { - [$hook, $callback] = $arguments; + [, $callback] = $arguments; $callback( function () use ($definitions) { return $definitions; @@ -562,7 +562,7 @@ public function testGetFieldDefinitionsProvider(): void { $this->moduleHandler->invokeAllWith(Argument::type('string'), Argument::any()) ->will(function ($arguments) use ($field_definition, $module) { - [$hook, $callback] = $arguments; + [, $callback] = $arguments; $callback( function () use ($field_definition) { return [$field_definition->reveal()]; diff --git a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php index c66e726693df..053c05ebd97e 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php @@ -387,7 +387,7 @@ public function testGetEntityTypeIdKeyTypeNotFieldable(): void { protected static function getEntityType(?ObjectProphecy $base_entity_type = NULL) { $entity_type = (new Prophet())->prophesize(EntityTypeInterface::class); if ($base_entity_type) { - foreach ($base_entity_type->getMethodProphecies() as $method => $prophecies) { + foreach ($base_entity_type->getMethodProphecies() as $prophecies) { foreach ($prophecies as $prophecy) { $entity_type->addMethodProphecy(clone $prophecy); } diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php index b5b80a1bf0e4..a1b8d4c9c4c0 100644 --- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php @@ -51,14 +51,6 @@ protected function setUp(): void { } $this->languages = $languages; - // Create a stub configuration. - $language_prefixes = array_keys($this->languages); - $config = [ - 'url' => [ - 'prefixes' => array_combine($language_prefixes, $language_prefixes), - ], - ]; - // Create a language manager stub. $language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface') ->getMock(); diff --git a/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php index 64e0d2423188..6368b23fa4e0 100644 --- a/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php @@ -53,8 +53,6 @@ protected function setUp(): void { * @dataProvider providerUrlBubbleableMetadataBubbling */ public function testUrlBubbleableMetadataBubbling($collect_bubbleable_metadata, $invocations, array $options): void { - $self = $this; - $this->renderer->expects($this->exactly($invocations)) ->method('render') ->willReturnCallback(function ($build) { diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php index cd7205180072..3f05b89465ce 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php @@ -149,7 +149,7 @@ public static function providerPlaceholders(): array { // Note the absence of '#create_placeholder', presence of max-age=0 created // by the #lazy_builder callback. // @todo in https://www.drupal.org/node/2559847 - $base_element_a5 = []; + // $base_element_a5 = []; // Note the absence of '#create_placeholder', presence of high cardinality // cache context created by the #lazy_builder callback. // @see \Drupal\Tests\Core\Render\PlaceholdersTest::callbackPerUser() @@ -1074,8 +1074,8 @@ public function testRenderLazyBuilderPreview(): void { $element1 = $element2 = $test_element; // Render the element twice so that it is in the render cache. - $result = $this->renderer->renderRoot($element1); - $result = $this->renderer->renderRoot($element2); + $this->renderer->renderRoot($element1); + $this->renderer->renderRoot($element2); $placeholder_string = (string) $this->renderCache->placeholderElements[0]['#markup']; $this->assertSame($this->renderCache->placeholderElements[0]['#attached']['placeholders'][$placeholder_string]['#preview'], ['#markup' => 'Lazy Builder Preview']); } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php index 29b0c7b183e9..3e7981c0a3cc 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php @@ -11,7 +11,6 @@ class RendererRecursionTest extends RendererTestBase { protected function setUpRenderRecursionComplexElements(): array { - $complex_child_markup = '<p>Imagine this is a render array for an entity.</p>'; $parent_markup = '<p>Rendered!</p>'; $complex_child_template = [ @@ -24,7 +23,7 @@ protected function setUpRenderRecursionComplexElements(): array { '#create_placeholder' => TRUE, ]; - return [$complex_child_markup, $parent_markup, $complex_child_template]; + return [$parent_markup, $complex_child_template]; } /** @@ -35,7 +34,7 @@ protected function setUpRenderRecursionComplexElements(): array { * @covers ::doRender */ public function testRenderRecursionWithNestedRenderRoot(): void { - [$complex_child_markup, $parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements(); + [$parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); @@ -67,7 +66,7 @@ public function testRenderRecursionWithNestedRenderRoot(): void { * @covers ::doRender */ public function testRenderRecursionWithNestedRender(): void { - [$complex_child_markup, $parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements(); + [$parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); @@ -101,7 +100,7 @@ public function testRenderRecursionWithNestedRender(): void { * @covers ::renderInIsolation */ public function testRenderRecursionWithNestedRenderInIsolation(): void { - [$complex_child_markup, $parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements(); + [$parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); diff --git a/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php b/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php index 6e310ea4dea7..6c584864ba0f 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php @@ -222,8 +222,6 @@ public function testCreateIconHumanize(string $icon_id, string $expected): void * Test the IconDefinition::getRenderable method. */ public function testGetRenderable(): void { - $icon = IconDefinition::create('foo', 'bar', '_template_'); - $expected = [ '#type' => 'icon', '#pack_id' => 'foo', diff --git a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php index 3c13329d228f..32f89e340d6f 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php @@ -125,7 +125,7 @@ public function testDiscoverIconsPath(array $files, bool $expected_empty = FALSE // Result expected is keyed by icon_id with values 'source' and 'group'. $expected_result = []; - foreach ($files as $index => $icon) { + foreach ($files as $icon) { $expected_id = $this->pluginId . IconDefinition::ICON_SEPARATOR . $icon['icon_id']; if (!isset($icon['group'])) { $icon['group'] = NULL; diff --git a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php index 96c1a4425db4..0f1146f84d89 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php @@ -129,7 +129,7 @@ public function testDiscoverIconsSvg(array $files, bool $expected_empty = FALSE) } $expected_result = []; - foreach ($files as $index => $icon) { + foreach ($files as $icon) { $expected_id = $this->pluginId . IconDefinition::ICON_SEPARATOR . $icon['icon_id']; $expected_result[$expected_id] = [ 'source' => $icon['source'], diff --git a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php index 46fb739c7e12..d27e22c74a15 100644 --- a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php +++ b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php @@ -106,7 +106,7 @@ public static function providerFromUri() { */ public function testFromInvalidUri($uri): void { $this->expectException(\InvalidArgumentException::class); - $url = Url::fromUri($uri); + Url::fromUri($uri); } /** diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php index 840b570db8a1..09e54efb1c18 100644 --- a/core/tests/Drupal/Tests/Core/UrlTest.php +++ b/core/tests/Drupal/Tests/Core/UrlTest.php @@ -193,7 +193,7 @@ public function testFromUserInput($path): void { */ public function testFromInvalidUserInput($path): void { $this->expectException(\InvalidArgumentException::class); - $url = Url::fromUserInput($path); + Url::fromUserInput($path); } /** diff --git a/core/tests/Drupal/Tests/PerformanceTestTrait.php b/core/tests/Drupal/Tests/PerformanceTestTrait.php index b722ebde8d76..50d0ce5ed625 100644 --- a/core/tests/Drupal/Tests/PerformanceTestTrait.php +++ b/core/tests/Drupal/Tests/PerformanceTestTrait.php @@ -503,7 +503,7 @@ private function openTelemetryTracing(array $messages, string $service_name): vo $collection = \Drupal::keyValue('performance_test'); $performance_test_data = $collection->get('performance_test_data'); $query_events = $performance_test_data['database_events'] ?? []; - foreach ($query_events as $key => $event) { + foreach ($query_events as $event) { if (static::isDatabaseCache($event)) { continue; } diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index 60c0f6916871..1467313b6ff8 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -144,7 +144,7 @@ function drupal_phpunit_populate_class_loader() { } // Do class loader population. -$loader = drupal_phpunit_populate_class_loader(); +drupal_phpunit_populate_class_loader(); class_alias('\Drupal\Tests\DocumentElement', '\Behat\Mink\Element\DocumentElement', TRUE); // Set sane locale settings, to ensure consistent string, dates, times and -- GitLab