summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules
diff options
context:
space:
mode:
authorLee Rowlands <lee.rowlands@previousnext.com.au>2025-01-03 10:31:48 +1000
committerLee Rowlands <lee.rowlands@previousnext.com.au>2025-01-03 10:31:48 +1000
commit832f6a16836d8fc0d8043eb0aa6bc7b6f579ba63 (patch)
tree44b25c2413b63452ce2ddb86ff1018b081417ddd /core/modules
parent7254d6f83082c5108cb8490d14e85597ce464320 (diff)
downloaddrupal-832f6a16836d8fc0d8043eb0aa6bc7b6f579ba63.tar.gz
drupal-832f6a16836d8fc0d8043eb0aa6bc7b6f579ba63.zip
Issue #3477156 by quietone, mstrelan, alexpott: Use DrupalPractice.CodeAnalysis.VariableAnalysis on Functional* tests
Diffstat (limited to 'core/modules')
-rw-r--r--core/modules/big_pipe/tests/src/Functional/BigPipeTest.php2
-rw-r--r--core/modules/block/tests/src/Functional/BlockTest.php2
-rw-r--r--core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php1
-rw-r--r--core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php2
-rw-r--r--core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php4
-rw-r--r--core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php6
-rw-r--r--core/modules/content_moderation/tests/src/Functional/ModerationStateTaxonomyTermTest.php2
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php4
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php2
-rw-r--r--core/modules/editor/tests/src/FunctionalJavascript/EditorAdminTest.php1
-rw-r--r--core/modules/file/tests/src/Functional/FileFieldWidgetTest.php3
-rw-r--r--core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php2
-rw-r--r--core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php4
-rw-r--r--core/modules/language/tests/src/Functional/LanguageSwitchingTest.php7
-rw-r--r--core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php3
-rw-r--r--core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php1
-rw-r--r--core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php4
-rw-r--r--core/modules/node/tests/src/Functional/PagePreviewTest.php2
-rw-r--r--core/modules/package_manager/tests/src/Functional/FailureMarkerRequirementTest.php1
-rw-r--r--core/modules/rest/tests/src/Functional/ResourceTest.php4
-rw-r--r--core/modules/rest/tests/src/Functional/ResourceTestBase.php2
-rw-r--r--core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php1
-rw-r--r--core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php14
-rw-r--r--core/modules/system/tests/src/Functional/Routing/RouterTest.php1
-rw-r--r--core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php4
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TermTest.php4
-rw-r--r--core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php1
-rw-r--r--core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php2
-rw-r--r--core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php5
-rw-r--r--core/modules/views/tests/src/Functional/BulkFormTest.php2
-rw-r--r--core/modules/views/tests/src/Functional/Plugin/PagerTest.php4
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayTest.php2
-rw-r--r--core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php2
-rw-r--r--core/modules/views_ui/tests/src/Functional/HandlerTest.php2
38 files changed, 44 insertions, 69 deletions
diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index 4229bde5185..1fac58c8115 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -475,7 +475,7 @@ class BigPipeTest extends BrowserTestBase {
* @internal
*/
protected function assertSetsEqual(array $a, array $b): void {
- $result = count($a) == count($b) && !array_diff_assoc($a, $b);
+ count($a) == count($b) && !array_diff_assoc($a, $b);
}
/**
diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php
index 5b99aa839bd..11a0ae457ca 100644
--- a/core/modules/block/tests/src/Functional/BlockTest.php
+++ b/core/modules/block/tests/src/Functional/BlockTest.php
@@ -183,7 +183,7 @@ class BlockTest extends BlockTestBase {
$this->assertSession()->elementTextEquals('xpath', $xpath, 'Place block');
$link = $this->getSession()->getPage()->find('xpath', $xpath);
- [$path, $query_string] = explode('?', $link->getAttribute('href'), 2);
+ [, $query_string] = explode('?', $link->getAttribute('href'), 2);
parse_str($query_string, $query_parts);
$this->assertEquals($weight, $query_parts['weight'], 'Found the expected weight query string.');
diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php
index fd62a633aad..c52ae83c911 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php
@@ -53,7 +53,6 @@ class CKEditor5ReadOnlyModeTest extends CKEditor5TestBase {
* Test that disabling a CKEditor 5 field results in an uneditable editor.
*/
public function testReadOnlyMode(): void {
- $page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
$this->addNewTextFormat();
diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
index 92a3c3d2fee..368fcc422e3 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
@@ -595,7 +595,7 @@ class MediaTest extends MediaTestBase {
// Ensure that by default the "Break text" alignment option is selected.
$this->click('.ck-widget.drupal-media');
$this->assertVisibleBalloon('[aria-label="Drupal Media toolbar"]');
- $this->assertTrue(($align_button = $this->getBalloonButton('Break text'))->hasClass('ck-on'));
+ $this->assertTrue($this->getBalloonButton('Break text')->hasClass('ck-on'));
$editor_dom = $this->getEditorDataAsDom();
$drupal_media_element = $editor_dom->getElementsByTagName('drupal-media')
->item(0);
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
index 7a7ca6ba12f..35356783fde 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
@@ -89,7 +89,7 @@ class ConfigTranslationOverviewTest extends BrowserTestBase {
$this->assertSession()->linkByHrefExists('admin/config/people/accounts/translate');
// Make sure there is only a single operation for each dropbutton, either
// 'List' or 'Translate'.
- foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
+ foreach ($this->cssSelect('ul.dropbutton') as $dropbutton) {
$this->assertCount(1, $dropbutton->findAll('xpath', 'li'));
$this->assertTrue(($dropbutton->getText() === 'Translate') || ($dropbutton->getText() === 'List'));
}
@@ -115,7 +115,7 @@ class ConfigTranslationOverviewTest extends BrowserTestBase {
// Make sure there is only a single 'Translate' operation for each
// dropbutton.
- foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
+ foreach ($this->cssSelect('ul.dropbutton') as $dropbutton) {
$this->assertCount(1, $dropbutton->findAll('xpath', 'li'));
$this->assertSame('Translate', $dropbutton->getText());
}
diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php
index a3b8abe1236..14bdf3ed44d 100644
--- a/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php
+++ b/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php
@@ -351,11 +351,11 @@ class ModerationLocaleTest extends ModerationStateTestBase {
foreach (range(11, 16) as $revision_id) {
/** @var \Drupal\node\NodeInterface $revision */
$revision = $storage->loadRevision($revision_id);
- foreach ($revision->getTranslationLanguages() as $langcode => $language) {
+ foreach (array_keys($revision->getTranslationLanguages()) as $langcode) {
if ($revision->isRevisionTranslationAffected()) {
- $this->drupalGet($revision->toUrl('revision'));
+ $translation = $revision->getTranslation($langcode);
+ $this->drupalGet($translation->toUrl('revision'));
$this->assertFalse($this->hasModerationForm(), 'Moderation form is not displayed correctly for revision ' . $revision_id);
- break;
}
}
}
diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateTaxonomyTermTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateTaxonomyTermTest.php
index 7b796f6242a..f71974249c4 100644
--- a/core/modules/content_moderation/tests/src/Functional/ModerationStateTaxonomyTermTest.php
+++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateTaxonomyTermTest.php
@@ -27,7 +27,7 @@ class ModerationStateTaxonomyTermTest extends ModerationStateTestBase {
parent::setUp();
// Create a "Tags" vocabulary.
- $bundle = Vocabulary::create([
+ Vocabulary::create([
'vid' => 'tags',
'name' => 'Tags',
'new_revision' => FALSE,
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php
index 80fdd9a7188..64ff8e16da0 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php
@@ -116,7 +116,7 @@ class ContentTranslationLinkTagTest extends BrowserTestBase {
// Ensure link tags for all languages are found on each language variation
// page of an entity.
- foreach ($urls as $langcode => $url) {
+ foreach ($urls as $url) {
$this->drupalGet($url);
foreach ($urls as $langcode_alternate => $url_alternate) {
$this->assertSession()->elementAttributeContains('xpath', "head/link[@rel='alternate' and @hreflang='$langcode_alternate']", 'href', $url_alternate->toString());
@@ -128,7 +128,7 @@ class ContentTranslationLinkTagTest extends BrowserTestBase {
$this->config('system.site')->set('page.front', $entity_canonical)->save();
// Tests hreflang when using entities as a front page.
- foreach ($urls as $langcode => $url) {
+ foreach ($urls as $url) {
$this->drupalGet($url);
foreach ($entity->getTranslationLanguages() as $language) {
$frontpage_path = Url::fromRoute('<front>', [], [
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
index 75aaec084a8..6afba2496d4 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
@@ -325,7 +325,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$values = [];
// Post different authoring information for each translation.
- foreach ($this->langcodes as $index => $langcode) {
+ foreach ($this->langcodes as $langcode) {
$user = $this->drupalCreateUser();
$values[$langcode] = [
'uid' => $user->id(),
diff --git a/core/modules/editor/tests/src/FunctionalJavascript/EditorAdminTest.php b/core/modules/editor/tests/src/FunctionalJavascript/EditorAdminTest.php
index c48eef11ae8..95879450d56 100644
--- a/core/modules/editor/tests/src/FunctionalJavascript/EditorAdminTest.php
+++ b/core/modules/editor/tests/src/FunctionalJavascript/EditorAdminTest.php
@@ -80,7 +80,6 @@ class EditorAdminTest extends WebDriverTestBase {
*/
public function testEditorCreation(): void {
$page = $this->getSession()->getPage();
- $assert_session = $this->assertSession();
$this->drupalGet('/admin/config/content/formats/add');
$page->fillField('name', $this->randomString());
diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
index 108cedefed9..fa1e0ca27d8 100644
--- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
@@ -320,7 +320,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$text_file = $this->getTestFile('text');
$edit = [
'files[field_' . $name . '_' . 0 . ']' => \Drupal::service('file_system')->realpath($text_file->getFileUri()),
- 'comment_body[0][value]' => $comment_body = $this->randomMachineName(),
+ 'comment_body[0][value]' => $this->randomMachineName(),
];
$this->drupalGet('node/' . $node->id());
$this->submitForm($edit, 'Save');
@@ -367,7 +367,6 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$this->createFileField($field_name, 'node', $type_name);
$this->updateFileField($field_name, $type_name, ['file_extensions' => 'txt']);
- $type = 'nojs';
// Create node and prepare files for upload.
$node = $this->drupalCreateNode(['type' => 'article']);
$nid = $node->id();
diff --git a/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php b/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php
index e2e1481617c..781c3595917 100644
--- a/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php
@@ -112,7 +112,7 @@ class InternalEntitiesTest extends BrowserTestBase {
'related' => "/jsonapi/entity_test_no_label/entity_test_no_label/{$this->internalEntity->uuid()}/field_internal",
];
$this->drupalLogin($this->testUser);
- foreach ($paths as $type => $path) {
+ foreach ($paths as $path) {
$this->drupalGet($path, ['Accept' => 'application/vnd.api+json']);
$this->assertSame(404, $this->getSession()->getStatusCode());
}
diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
index 9dd535bedd5..1395209a064 100644
--- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
+++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
@@ -2563,7 +2563,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
ksort($array);
// Then check for child arrays.
- foreach ($array as $key => &$value) {
+ foreach ($array as &$value) {
if (is_array($value)) {
static::recursiveKsort($value);
}
@@ -2758,7 +2758,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
}
}
- foreach ($field_sets as $type => $included_paths) {
+ foreach ($field_sets as $included_paths) {
$this->grantIncludedPermissions($included_paths);
$query = ['include' => implode(',', $included_paths)];
$url->setOption('query', $query);
diff --git a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
index 1691c5d4013..32ec3a2c6e5 100644
--- a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
@@ -429,11 +429,9 @@ class LanguageSwitchingTest extends BrowserTestBase {
* @see self::testLanguageLinkActiveClass()
*/
protected function doTestLanguageLinkActiveClassAuthenticated(): void {
- $function_name = '#type link';
$path = 'language_test/type-link-active-class';
// Test links generated by the link generator on an English page.
- $current_language = 'English';
$this->drupalGet($path);
// Language code 'none' link should be active.
@@ -454,7 +452,6 @@ class LanguageSwitchingTest extends BrowserTestBase {
$this->assertSame('en', $settings['path']['currentLanguage'], 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.');
// Test links generated by the link generator on a French page.
- $current_language = 'French';
$this->drupalGet('fr/language_test/type-link-active-class');
// Language code 'none' link should be active.
@@ -481,12 +478,9 @@ class LanguageSwitchingTest extends BrowserTestBase {
* @see self::testLanguageLinkActiveClass()
*/
protected function doTestLanguageLinkActiveClassAnonymous(): void {
- $function_name = '#type link';
-
$this->drupalLogout();
// Test links generated by the link generator on an English page.
- $current_language = 'English';
$this->drupalGet('language_test/type-link-active-class');
// Language code 'none' link should be active.
@@ -499,7 +493,6 @@ class LanguageSwitchingTest extends BrowserTestBase {
$this->assertSession()->elementExists('xpath', "//a[@id = 'fr_link' and not(contains(@class, 'is-active'))]");
// Test links generated by the link generator on a French page.
- $current_language = 'French';
$this->drupalGet('fr/language_test/type-link-active-class');
// Language code 'none' link should be active.
diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php
index 220a61ad1d2..bf33b3d7c78 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php
@@ -60,7 +60,6 @@ class AjaxBlockTest extends WebDriverTestBase {
*/
public function testAddAjaxBlock(): void {
$assert_session = $this->assertSession();
- $page = $this->getSession()->getPage();
// Start by creating a node.
$this->createNode([
@@ -95,7 +94,7 @@ class AjaxBlockTest extends WebDriverTestBase {
/** @var \Behat\Mink\Element\NodeElement[] $radios */
$radios = $this->assertSession()->fieldExists($name);
// Click them both a couple of times.
- foreach ([1, 2] as $rounds) {
+ for ($i = 1; $i < 3; ++$i) {
foreach ($radios as $radio) {
$radio->click();
$assert_session->assertWaitOnAjaxRequest();
diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php
index 22ef2b12705..8a13b0e070c 100644
--- a/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php
+++ b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php
@@ -106,7 +106,6 @@ class WidgetOverflowTest extends MediaLibraryTestBase {
}
$assert_session = $this->assertSession();
- $page = $this->getSession()->getPage();
$this->drupalGet('node/add/basic_page');
// Upload 5 files into a media field that only allows 2.
$this->openMediaLibraryForField('field_twin_media');
diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
index 40a1f70c987..7e0b3af57f0 100644
--- a/core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
+++ b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
@@ -301,7 +301,7 @@ class WidgetUploadTest extends MediaLibraryTestBase {
// Create a list of new files to upload.
$filenames = [];
$remote_paths = [];
- foreach (range(1, 4) as $i) {
+ for ($i = 1; $i < 5; $i++) {
$path = $file_system->copy($png_image->uri, 'public://');
$filenames[] = $file_system->basename($path);
$remote_paths[] = $driver->uploadFileAndGetRemoteFilePath($file_system->realpath($path));
@@ -680,7 +680,7 @@ class WidgetUploadTest extends MediaLibraryTestBase {
// Create a list of new files to upload.
$filenames = [];
$remote_paths = [];
- foreach (range(1, 4) as $i) {
+ for ($i = 1; $i < 5; $i++) {
$path = $file_system->copy($png_image->uri, 'public://');
$filenames[] = $file_system->basename($path);
$remote_paths[] = $driver->uploadFileAndGetRemoteFilePath($file_system->realpath($path));
diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php
index 5caa943e084..c30ebc17bc1 100644
--- a/core/modules/node/tests/src/Functional/PagePreviewTest.php
+++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php
@@ -229,7 +229,7 @@ class PagePreviewTest extends NodeTestBase {
// Get the UUID.
$url = parse_url($this->getUrl());
$paths = explode('/', $url['path']);
- $view_mode = array_pop($paths);
+ array_pop($paths);
$uuid = array_pop($paths);
// Switch view mode. We'll remove the body from the teaser view mode.
diff --git a/core/modules/package_manager/tests/src/Functional/FailureMarkerRequirementTest.php b/core/modules/package_manager/tests/src/Functional/FailureMarkerRequirementTest.php
index c0a84c83065..aac2498a937 100644
--- a/core/modules/package_manager/tests/src/Functional/FailureMarkerRequirementTest.php
+++ b/core/modules/package_manager/tests/src/Functional/FailureMarkerRequirementTest.php
@@ -51,6 +51,7 @@ class FailureMarkerRequirementTest extends PackageManagerTestBase {
/**
* {@inheritdoc}
*/
+ // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
protected string $type = 'test';
};
$failure_marker->write($stage, $message);
diff --git a/core/modules/rest/tests/src/Functional/ResourceTest.php b/core/modules/rest/tests/src/Functional/ResourceTest.php
index fc39ea210b4..dc742ed835b 100644
--- a/core/modules/rest/tests/src/Functional/ResourceTest.php
+++ b/core/modules/rest/tests/src/Functional/ResourceTest.php
@@ -155,8 +155,8 @@ class ResourceTest extends BrowserTestBase {
/** @var \Drupal\rest\Plugin\Type\ResourcePluginManager $manager */
$manager = \Drupal::service('plugin.manager.rest');
- foreach ($manager->getDefinitions() as $resource => $definition) {
- foreach ($definition['uri_paths'] as $key => $uri_path) {
+ foreach ($manager->getDefinitions() as $definition) {
+ foreach ($definition['uri_paths'] as $uri_path) {
$this->assertStringNotContainsString('//', $uri_path, 'The resource URI path does not have duplicate slashes.');
}
}
diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
index adc598f905f..73aeef3fe7b 100644
--- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
@@ -441,7 +441,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
ksort($array);
// Then check for child arrays.
- foreach ($array as $key => &$value) {
+ foreach ($array as &$value) {
if (is_array($value)) {
static::recursiveKSort($value);
}
diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
index ccf958bf18c..b30bc34ae97 100644
--- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
+++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
@@ -111,7 +111,7 @@ class StyleSerializerTest extends ViewTestBase {
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
- $this->assertSession()->statusCodeEquals(200);
+ $this->assertEquals(200, $response->getStatusCode());
}
/**
diff --git a/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php b/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php
index 4e5695141b6..4a85815ac88 100644
--- a/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php
+++ b/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php
@@ -51,7 +51,6 @@ class FrameworkTest extends BrowserTestBase {
$asset_resolver = \Drupal::service('asset.resolver');
$css_collection_renderer = \Drupal::service('asset.css.collection_renderer');
$js_collection_renderer = \Drupal::service('asset.js.collection_renderer');
- $renderer = \Drupal::service('renderer');
$build['#attached']['library'][] = 'ajax_test/order-css-command';
$assets = AttachedAssets::createFromRenderArray($build);
$css_render_array = $css_collection_renderer->render($asset_resolver->getCssAssets($assets, FALSE, \Drupal::languageManager()->getCurrentLanguage()));
diff --git a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php
index 2e5e2e947bb..274c6044c38 100644
--- a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php
+++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php
@@ -44,7 +44,7 @@ class ContentNegotiationTest extends BrowserTestBase {
'Android #1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Android #2 (2012)' => 'text/xml,text/html,application/xhtml+xml,image/png,text/plain,*/*;q=0.8',
];
- foreach ($tests as $case => $header) {
+ foreach ($tests as $header) {
$this->drupalGet('', [], ['Accept' => $header]);
$this->assertSession()->pageTextNotContains('Unsupported Media Type');
$this->assertSession()->pageTextContains('Log in');
diff --git a/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php b/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php
index 9cda40532a6..ccf0d3c4287 100644
--- a/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php
@@ -37,10 +37,9 @@ class ElementsTableSelectTest extends BrowserTestBase {
// Test for the presence of the Select all rows tableheader.
$this->assertSession()->elementExists('xpath', '//th[@class="select-all"]');
- $rows = ['row1', 'row2', 'row3'];
- foreach ($rows as $row) {
- $this->assertSession()->elementExists('xpath', '//input[@type="checkbox"]');
- }
+ $this->assertSession()->elementExists('xpath', '//input[@type="checkbox" and @value="row1"]');
+ $this->assertSession()->elementExists('xpath', '//input[@type="checkbox" and @value="row2"]');
+ $this->assertSession()->elementExists('xpath', '//input[@type="checkbox" and @value="row3"]');
}
/**
@@ -54,10 +53,9 @@ class ElementsTableSelectTest extends BrowserTestBase {
// Test for the absence of the Select all rows tableheader.
$this->assertSession()->elementNotExists('xpath', '//th[@class="select-all"]');
- $rows = ['row1', 'row2', 'row3'];
- foreach ($rows as $row) {
- $this->assertSession()->elementExists('xpath', '//input[@type="radio"]');
- }
+ $this->assertSession()->elementExists('xpath', '//input[@type="radio" and @value="row1"]');
+ $this->assertSession()->elementExists('xpath', '//input[@type="radio" and @value="row2"]');
+ $this->assertSession()->elementExists('xpath', '//input[@type="radio" and @value="row3"]');
}
/**
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
index a9f281f07d2..46f4bc7f861 100644
--- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php
+++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
@@ -53,7 +53,6 @@ class RouterTest extends BrowserTestBase {
$this->drupalGet('router_test/test2');
$this->assertSession()->pageTextContains('test2');
// Check expected headers from FinishResponseSubscriber.
- $headers = $session->getResponseHeaders();
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Contexts', implode(' ', $expected_cache_contexts));
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Tags', 'config:user.role.anonymous http_response rendered');
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Max-Age', '-1 (Permanent)');
diff --git a/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php b/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
index e599884c2d2..28a9328afc2 100644
--- a/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
+++ b/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
@@ -40,7 +40,7 @@ class DefaultMobileMetaTagsTest extends BrowserTestBase {
*/
public function testDefaultMetaTagsExist(): void {
$this->drupalGet('');
- foreach ($this->defaultMetaTags as $name => $metatag) {
+ foreach ($this->defaultMetaTags as $metatag) {
$this->assertSession()->responseContains($metatag);
}
}
@@ -51,7 +51,7 @@ class DefaultMobileMetaTagsTest extends BrowserTestBase {
public function testRemovingDefaultMetaTags(): void {
\Drupal::service('module_installer')->install(['system_module_test']);
$this->drupalGet('');
- foreach ($this->defaultMetaTags as $name => $metatag) {
+ foreach ($this->defaultMetaTags as $metatag) {
$this->assertSession()->responseNotContains($metatag);
}
}
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php
index 010f1ccb521..2e8c9176375 100644
--- a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php
@@ -297,7 +297,7 @@ class ThemeUiTest extends BrowserTestBase {
$requires_list_items = $theme_container->findAll('css', '.theme-info__requires li');
$this->assertSameSize($expected_requires_list_items, $requires_list_items);
- foreach ($requires_list_items as $key => $item) {
+ foreach ($requires_list_items as $item) {
$this->assertContains($item->getText(), $expected_requires_list_items);
}
diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php
index c232652ae3b..4947ea68994 100644
--- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php
@@ -46,9 +46,9 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
public function testTermIndentation(): void {
$assert = $this->assertSession();
// Create three taxonomy terms.
- $term1 = $this->createTerm($this->vocabulary);
+ $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary);
- $term3 = $this->createTerm($this->vocabulary);
+ $this->createTerm($this->vocabulary);
// Get the taxonomy storage.
$taxonomy_storage = $this->container->get('entity_type.manager')->getStorage('taxonomy_term');
diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/tests/src/Functional/TermTest.php
index 2078d9e2d99..9ea1ef323a3 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermTest.php
@@ -138,8 +138,6 @@ class TermTest extends TaxonomyTestBase {
$term1 = $this->createTerm($this->vocabulary);
$terms_array = [];
- $taxonomy_storage = $this->container->get('entity_type.manager')->getStorage('taxonomy_term');
-
// Create 40 terms. Terms 1-12 get parent of $term1. All others are
// individual terms.
for ($x = 1; $x <= 40; $x++) {
@@ -152,8 +150,6 @@ class TermTest extends TaxonomyTestBase {
$edit['parent'] = $term1->id();
}
$term = $this->createTerm($this->vocabulary, $edit);
- $children = $taxonomy_storage->loadChildren($term1->id());
- $parents = $taxonomy_storage->loadParents($term->id());
$terms_array[$x] = Term::load($term->id());
}
diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php
index 52e07caf7b3..0126d73a4d2 100644
--- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php
@@ -55,7 +55,6 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
* Tests token replacement in the "all terms" field handler.
*/
public function testViewsHandlerAllTermsWithTokens(): void {
- $view = Views::getView('taxonomy_all_terms_test');
$this->drupalGet('taxonomy_all_terms_token_test');
// Term itself: {{ term_node_tid }}
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
index 5bdfc88c390..7747682a42e 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
@@ -144,7 +144,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
public function testTaxonomyAdminNoVocabularies(): void {
// Delete all vocabularies.
$vocabularies = Vocabulary::loadMultiple();
- foreach ($vocabularies as $key => $vocabulary) {
+ foreach ($vocabularies as $vocabulary) {
$vocabulary->delete();
}
// Confirm that no vocabularies are found in the database.
diff --git a/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php b/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php
index 52b89b00135..c55362495b2 100644
--- a/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php
+++ b/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php
@@ -64,11 +64,6 @@ class UserFieldsAccessChangeTest extends UserTestBase {
$test_user = $this->drupalCreateUser();
$xpath = "//td/a[.='" . $test_user->getAccountName() . "']/@href[.='" . $test_user->toUrl()->toString() . "']";
- $attributes = [
- 'title' => 'View user profile.',
- ];
- $link = $test_user->toLink(NULL, 'canonical', ['attributes' => $attributes])->toString();
-
// No access, so no link.
$this->drupalGet('test_user_fields_access');
$this->assertSession()->pageTextContains($test_user->getAccountName());
diff --git a/core/modules/views/tests/src/Functional/BulkFormTest.php b/core/modules/views/tests/src/Functional/BulkFormTest.php
index c5aeba4acb3..16de73e1253 100644
--- a/core/modules/views/tests/src/Functional/BulkFormTest.php
+++ b/core/modules/views/tests/src/Functional/BulkFormTest.php
@@ -232,7 +232,7 @@ class BulkFormTest extends BrowserTestBase {
// by another user before the loaded bulk form was submitted.
$this->drupalGet('test_bulk_form');
// Call the node delete action.
- foreach ($nodes as $key => $node) {
+ foreach ($nodes as $node) {
$node->delete();
}
$edit = [
diff --git a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
index c43d3574ac5..bfa91aade6b 100644
--- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
@@ -105,7 +105,7 @@ class PagerTest extends ViewTestBase {
$this->assertSame('number', $offset->getAttribute('type'));
$this->assertEquals(0, $offset->getAttribute('min'));
- $pagerHeading = $this->assertSession()->fieldExists("pager_options[pagination_heading_level]");
+ $this->assertSession()->fieldExists("pager_options[pagination_heading_level]");
$this->assertSession()->fieldValueEquals("pager_options[pagination_heading_level]", 'h4');
$id = $this->assertSession()->fieldExists("pager_options[id]");
@@ -539,7 +539,7 @@ class PagerTest extends ViewTestBase {
'Next ›' => 'Volgende ›',
'Last »' => 'Laatste »',
];
- foreach ($labels as $label => $translation) {
+ foreach ($labels as $translation) {
// Check if we can find the translation.
$this->assertSession()->pageTextContains($translation);
}
diff --git a/core/modules/views_ui/tests/src/Functional/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
index b9cf5d43dd9..eebd1861d59 100644
--- a/core/modules/views_ui/tests/src/Functional/DisplayTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
@@ -37,7 +37,7 @@ class DisplayTest extends UITestBase {
* Tests adding a display.
*/
public function testAddDisplay(): void {
- $view = $this->randomView();
+ $this->randomView();
$this->assertSession()->elementNotExists('xpath', '//li[@data-drupal-selector="edit-displays-top-tabs-block-1"]');
$this->assertSession()->elementNotExists('xpath', '//li[@data-drupal-selector="edit-displays-top-tabs-block-2"]');
$this->assertSession()->pageTextMatchesCount(0, '/Block name:/');
diff --git a/core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php b/core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php
index 74cadc64d62..2cfc383f5c7 100644
--- a/core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php
@@ -59,7 +59,7 @@ class FilterEntityReferenceWebTest extends UITestBase {
return strnatcasecmp($a->getTitle(), $b->getTitle());
});
$i = 0;
- foreach ($this->targetEntities as $id => $entity) {
+ foreach ($this->targetEntities as $entity) {
$message = (string) new FormattableMarkup('Expected target entity label found for option :option', [':option' => $i]);
$this->assertEquals($options[$i]['label'], $entity->label(), $message);
$i++;
diff --git a/core/modules/views_ui/tests/src/Functional/HandlerTest.php b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
index affa9452272..0c1db384547 100644
--- a/core/modules/views_ui/tests/src/Functional/HandlerTest.php
+++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
@@ -232,7 +232,7 @@ class HandlerTest extends UITestBase {
// Test that the handler edit link is present.
$this->assertSession()->elementsCount('xpath', "//a[contains(@href, '{$href}')]", 1);
- $result = $this->assertSession()->elementTextEquals('xpath', "//a[contains(@href, '{$href}')]", $text);
+ $this->assertSession()->elementTextEquals('xpath', "//a[contains(@href, '{$href}')]", $text);
$this->drupalGet($href);
$this->assertSession()->elementTextContains('xpath', '//h1', $text);