Issue #3458422 by mstrelan, smustgrave: Add string return typehints to protected test helper methods

(cherry picked from commit 22e2a1285a)
merge-requests/9339/head
Dave Long 2024-08-22 18:27:50 +01:00
parent a4f5580c86
commit 67b91bcb42
No known key found for this signature in database
GPG Key ID: ED52AE211E142771
85 changed files with 94 additions and 94 deletions

View File

@ -48,7 +48,7 @@ class ConfigTranslationInstallTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -36,7 +36,7 @@ class DateTimeFieldTest extends DateTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getTestFieldType() { protected function getTestFieldType(): string {
return 'datetime'; return 'datetime';
} }

View File

@ -29,7 +29,7 @@ class DateTimeWidgetTest extends DateTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getTestFieldType() { protected function getTestFieldType(): string {
return 'datetime'; return 'datetime';
} }

View File

@ -49,7 +49,7 @@ class DateRangeFieldTest extends DateTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getTestFieldType() { protected function getTestFieldType(): string {
return 'daterange'; return 'daterange';
} }

View File

@ -108,7 +108,7 @@ class HelpTestTwigNodeVisitor implements NodeVisitorInterface {
* @return string * @return string
* Text in the node. * Text in the node.
*/ */
protected function extractText(TwigNodeTrans $node) { protected function extractText(TwigNodeTrans $node): string {
// Extract the singular/body and optional plural text from the // Extract the singular/body and optional plural text from the
// TwigNodeTrans object. // TwigNodeTrans object.
$bodies = $node->getNode('body'); $bodies = $node->getNode('body');

View File

@ -335,7 +335,7 @@ class HelpTopicsSyntaxTest extends BrowserTestBase {
* @return string * @return string
* The rendered topic. * The rendered topic.
*/ */
protected function renderHelpTopic(string $content, string $manner) { protected function renderHelpTopic(string $content, string $manner): string {
// Set up the special state variables for rendering. // Set up the special state variables for rendering.
HelpTestTwigNodeVisitor::setStateValue('manner', $manner); HelpTestTwigNodeVisitor::setStateValue('manner', $manner);
HelpTestTwigNodeVisitor::setStateValue('max_chunk', -1); HelpTestTwigNodeVisitor::setStateValue('max_chunk', -1);

View File

@ -305,7 +305,7 @@ class ImageDimensionsTest extends BrowserTestBase {
* method and pass each time a fresh array so that $variables won't get * method and pass each time a fresh array so that $variables won't get
* altered and the element is re-rendered each time. * altered and the element is re-rendered each time.
*/ */
protected function getImageTag($variables) { protected function getImageTag($variables): string {
return str_replace("\n", '', (string) \Drupal::service('renderer')->renderRoot($variables)); return str_replace("\n", '', (string) \Drupal::service('renderer')->renderRoot($variables));
} }

View File

@ -133,7 +133,7 @@ class BaseFieldOverrideTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer node fields' permission is required."; return "The 'administer node fields' permission is required.";
} }

View File

@ -121,7 +121,7 @@ class ContactFormTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'access site-wide contact form' permission is required."; return "The 'access site-wide contact form' permission is required.";
} }

View File

@ -165,7 +165,7 @@ class EditorTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer filters' permission is required."; return "The 'administer filters' permission is required.";
} }

View File

@ -182,7 +182,7 @@ class EntityFormDisplayTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer node form display' permission is required."; return "The 'administer node form display' permission is required.";
} }

View File

@ -155,7 +155,7 @@ class EntityTestMapFieldTest extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer entity_test content' permission is required."; return "The 'administer entity_test content' permission is required.";
} }

View File

@ -135,7 +135,7 @@ class EntityViewDisplayTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer node display' permission is required."; return "The 'administer node display' permission is required.";
} }

View File

@ -142,7 +142,7 @@ class FieldConfigTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer node fields' permission is required."; return "The 'administer node fields' permission is required.";
} }

View File

@ -121,7 +121,7 @@ class FieldStorageConfigTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'administer node fields' permission is required."; return "The 'administer node fields' permission is required.";
} }

View File

@ -722,7 +722,7 @@ class FileUploadTest extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
switch ($method) { switch ($method) {
case 'GET': case 'GET':
return "The current user is not allowed to view this relationship. The 'view test entity' permission is required."; return "The current user is not allowed to view this relationship. The 'view test entity' permission is required.";

View File

@ -262,7 +262,7 @@ class NodeTest extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
switch ($method) { switch ($method) {
case 'GET': case 'GET':
case 'POST': case 'POST':

View File

@ -115,7 +115,7 @@ class NodeTypeTest extends ConfigEntityResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The 'access content' permission is required."; return "The 'access content' permission is required.";
} }

View File

@ -398,7 +398,7 @@ trait ResourceResponseTestTrait {
* @return string * @return string
* The relationship link. * The relationship link.
*/ */
protected static function getRelationshipLink(array $resource_identifier, $relationship_field_name) { protected static function getRelationshipLink(array $resource_identifier, $relationship_field_name): string {
return static::getResourceLink($resource_identifier) . "/relationships/$relationship_field_name"; return static::getResourceLink($resource_identifier) . "/relationships/$relationship_field_name";
} }
@ -413,7 +413,7 @@ trait ResourceResponseTestTrait {
* @return string * @return string
* The related resource link. * The related resource link.
*/ */
protected static function getRelatedLink(array $resource_identifier, $relationship_field_name) { protected static function getRelatedLink(array $resource_identifier, $relationship_field_name): string {
return static::getResourceLink($resource_identifier) . "/$relationship_field_name"; return static::getResourceLink($resource_identifier) . "/$relationship_field_name";
} }

View File

@ -118,7 +118,7 @@ class RestJsonApiUnsupported extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return ''; return '';
} }

View File

@ -152,7 +152,7 @@ class ShortcutTest extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return "The shortcut set must be the currently displayed set for the user and the user must have 'access shortcuts' AND 'customize shortcut links' permissions."; return "The shortcut set must be the currently displayed set for the user and the user must have 'access shortcuts' AND 'customize shortcut links' permissions.";
} }

View File

@ -95,7 +95,7 @@ class SimpleConfigSectionStorage extends PluginBase implements SectionStorageInt
/** /**
* Returns the name to be used to store in the config system. * Returns the name to be used to store in the config system.
*/ */
protected function getConfigName() { protected function getConfigName(): string {
return 'layout_builder_test.' . $this->getStorageType() . '.' . $this->getStorageId(); return 'layout_builder_test.' . $this->getStorageType() . '.' . $this->getStorageId();
} }

View File

@ -258,7 +258,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
* @return string * @return string
* The text secret. * The text secret.
*/ */
protected function getFileSecret(FileInterface $file) { protected function getFileSecret(FileInterface $file): string {
return "The secret in {$file->label()}"; return "The secret in {$file->label()}";
} }

View File

@ -172,7 +172,7 @@ class LayoutBuilderOptInTest extends WebDriverTestBase {
* @return string * @return string
* The path. * The path.
*/ */
protected function getPathForFieldBlock($entity_type_id, $bundle, $view_mode, $field_name) { protected function getPathForFieldBlock($entity_type_id, $bundle, $view_mode, $field_name): string {
$delta = 0; $delta = 0;
/** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $display */ /** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $display */
$display = $this->container->get('entity_type.manager')->getStorage('entity_view_display')->load("$entity_type_id.$bundle.$view_mode"); $display = $this->container->get('entity_type.manager')->getStorage('entity_view_display')->load("$entity_type_id.$bundle.$view_mode");

View File

@ -1056,7 +1056,7 @@ class LinkFieldTest extends BrowserTestBase {
* @return string * @return string
* The rendered HTML output. * The rendered HTML output.
*/ */
protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) { protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE): string {
if ($reset) { if ($reset) {
$this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]); $this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]);
} }

View File

@ -19,7 +19,7 @@ class LocaleNonInteractiveDevInstallTest extends LocaleNonInteractiveInstallTest
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getVersionStringToTest() { protected function getVersionStringToTest(): string {
include_once $this->root . '/core/includes/install.core.inc'; include_once $this->root . '/core/includes/install.core.inc';
$version = _install_get_version_info(\Drupal::VERSION); $version = _install_get_version_info(\Drupal::VERSION);
return $version['major'] . '.' . $version['minor'] . '.x'; return $version['major'] . '.' . $version['minor'] . '.x';

View File

@ -32,7 +32,7 @@ class LocaleNonInteractiveInstallTest extends BrowserTestBase {
* @return string * @return string
* The version string to test, for example, '8.0.0' or '8.6.x'. * The version string to test, for example, '8.0.0' or '8.6.x'.
*/ */
protected function getVersionStringToTest() { protected function getVersionStringToTest(): string {
include_once $this->root . '/core/includes/install.core.inc'; include_once $this->root . '/core/includes/install.core.inc';
$version = _install_get_version_info(\Drupal::VERSION); $version = _install_get_version_info(\Drupal::VERSION);
return $version['major'] . '.0.0'; return $version['major'] . '.0.0';

View File

@ -18,7 +18,7 @@ trait OEmbedTestTrait {
* *
* @return string * @return string
*/ */
protected function getFixturesDirectory() { protected function getFixturesDirectory(): string {
return \Drupal::service('extension.list.module')->getPath('media') . '/tests/fixtures/oembed'; return \Drupal::service('extension.list.module')->getPath('media') . '/tests/fixtures/oembed';
} }
@ -27,7 +27,7 @@ trait OEmbedTestTrait {
* *
* @return string * @return string
*/ */
protected function getFixturesUrl() { protected function getFixturesUrl(): string {
return $this->baseUrl . '/' . $this->getFixturesDirectory(); return $this->baseUrl . '/' . $this->getFixturesDirectory();
} }

View File

@ -102,7 +102,7 @@ class CredentialFormTest extends MigrateUpgradeTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
$version = $this->getLegacyDrupalVersion($this->sourceDatabase); $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
return __DIR__ . '/d' . $version . '/files'; return __DIR__ . '/d' . $version . '/files';
} }

View File

@ -41,7 +41,7 @@ class MigrateUpgradeFormStepsTest extends BrowserTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -71,7 +71,7 @@ class SourceProviderTest extends MigrateUpgradeTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return ''; return '';
} }

View File

@ -35,7 +35,7 @@ class IdConflictTest extends MigrateUpgradeExecuteTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -47,7 +47,7 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -43,7 +43,7 @@ class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -42,7 +42,7 @@ class NodeClassicTest extends MigrateUpgradeExecuteTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -64,7 +64,7 @@ class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -82,7 +82,7 @@ class DoubleSlashTest extends MigrateUpgradeExecuteTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -317,7 +317,7 @@ class FilePathTest extends MigrateUpgradeTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return ''; return '';
} }

View File

@ -35,7 +35,7 @@ class IdConflictTest extends MigrateUpgradeExecuteTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -44,7 +44,7 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -41,7 +41,7 @@ class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -67,7 +67,7 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getSourceBasePath() { protected function getSourceBasePath(): string {
return __DIR__ . '/files'; return __DIR__ . '/files';
} }

View File

@ -457,7 +457,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getFormSubmitSuffix(EntityInterface $entity, $langcode) { protected function getFormSubmitSuffix(EntityInterface $entity, $langcode): string {
if (!$entity->isNew() && $entity->isTranslatable()) { if (!$entity->isNew() && $entity->isTranslatable()) {
$translations = $entity->getTranslationLanguages(); $translations = $entity->getTranslationLanguages();
if ((count($translations) > 1 || !isset($translations[$langcode])) && ($field = $entity->getFieldDefinition('status'))) { if ((count($translations) > 1 || !isset($translations[$langcode])) && ($field = $entity->getFieldDefinition('status'))) {

View File

@ -15,7 +15,7 @@ class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getPluginId() { protected function getPluginId(): string {
return 'path'; return 'path';
} }

View File

@ -36,7 +36,7 @@ class SettingsTrayTest extends BrowserTestBase {
* @return string * @return string
* The CSS selector. * The CSS selector.
*/ */
protected function getBlockSelector(Block $block) { protected function getBlockSelector(Block $block): string {
return '#block-' . $block->id(); return '#block-' . $block->id();
} }

View File

@ -37,7 +37,7 @@ class FormStoragePageCacheTest extends BrowserTestBase {
/** /**
* Return the build id of the current form. * Return the build id of the current form.
*/ */
protected function getFormBuildId() { protected function getFormBuildId(): string {
// Ensure the hidden 'form_build_id' field is unique. // Ensure the hidden 'form_build_id' field is unique.
$this->assertSession()->elementsCount('xpath', '//input[@name="form_build_id"]', 1); $this->assertSession()->elementsCount('xpath', '//input[@name="form_build_id"]', 1);
return (string) $this->assertSession()->hiddenFieldExists('form_build_id')->getAttribute('value'); return (string) $this->assertSession()->hiddenFieldExists('form_build_id')->getAttribute('value');

View File

@ -232,7 +232,7 @@ class SessionHttpsTest extends BrowserTestBase {
* @return string * @return string
* The internal path from the location header on the response. * The internal path from the location header on the response.
*/ */
protected function getPathFromLocationHeader(ResponseInterface $response, $https = FALSE) { protected function getPathFromLocationHeader(ResponseInterface $response, $https = FALSE): string {
if ($https) { if ($https) {
$base_url = str_replace('http://', 'https://', $this->baseUrl); $base_url = str_replace('http://', 'https://', $this->baseUrl);
} }
@ -276,7 +276,7 @@ class SessionHttpsTest extends BrowserTestBase {
* @return string * @return string
* URL prepared for the https.php mock front controller. * URL prepared for the https.php mock front controller.
*/ */
protected function httpsUrl($url) { protected function httpsUrl($url): string {
return 'core/modules/system/tests/https.php/' . $url; return 'core/modules/system/tests/https.php/' . $url;
} }
@ -289,7 +289,7 @@ class SessionHttpsTest extends BrowserTestBase {
* @return string * @return string
* URL prepared for the http.php mock front controller. * URL prepared for the http.php mock front controller.
*/ */
protected function httpUrl($url) { protected function httpUrl($url): string {
return 'core/modules/system/tests/http.php/' . $url; return 'core/modules/system/tests/http.php/' . $url;
} }
@ -314,7 +314,7 @@ class SessionHttpsTest extends BrowserTestBase {
* @return string * @return string
* The form build ID for the user login form. * The form build ID for the user login form.
*/ */
protected function getUserLoginFormBuildId() { protected function getUserLoginFormBuildId(): string {
$this->drupalGet('user/login'); $this->drupalGet('user/login');
return (string) $this->getSession()->getPage()->findField('form_build_id'); return (string) $this->getSession()->getPage()->findField('form_build_id');
} }

View File

@ -115,7 +115,7 @@ class SitesDirectoryHardeningTest extends BrowserTestBase {
* @return string * @return string
* The path to settings.php. * The path to settings.php.
*/ */
protected function settingsFile($site_path) { protected function settingsFile($site_path): string {
$settings_file = $site_path . '/settings.php'; $settings_file = $site_path . '/settings.php';
return $settings_file; return $settings_file;
} }

View File

@ -258,7 +258,7 @@ class UserRegistrationRestTest extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getExpectedUnauthorizedAccessMessage($method) { protected function getExpectedUnauthorizedAccessMessage($method): string {
return ''; return '';
} }

View File

@ -47,7 +47,7 @@ class StyleMappingTest extends StyleTestBase {
* @return string * @return string
* The view rendered as HTML. * The view rendered as HTML.
*/ */
protected function mappedOutputHelper(ViewExecutable $view) { protected function mappedOutputHelper(ViewExecutable $view): string {
$output = $view->preview(); $output = $view->preview();
$rendered_output = (string) \Drupal::service('renderer')->renderRoot($output); $rendered_output = (string) \Drupal::service('renderer')->renderRoot($output);
$this->storeViewPreview($rendered_output); $this->storeViewPreview($rendered_output);

View File

@ -53,7 +53,7 @@ class UmamiMultilingualInstallTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -536,7 +536,7 @@ JS;
* *
* @see Drupal\Component\Utility\Html::escape() * @see Drupal\Component\Utility\Html::escape()
*/ */
protected function escapeHtml($raw) { protected function escapeHtml($raw): string {
return htmlspecialchars($raw, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8'); return htmlspecialchars($raw, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8');
} }

View File

@ -52,7 +52,7 @@ class PerformanceTestBase extends WebDriverTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getMinkDriverArgs() { protected function getMinkDriverArgs(): string {
return $this->doGetMinkDriverArgs(); return $this->doGetMinkDriverArgs();
} }

View File

@ -133,7 +133,7 @@ class DistributionProfileTranslationQueryTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -123,7 +123,7 @@ class DistributionProfileTranslationTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -21,7 +21,7 @@ class InstallerExistingConfigMultilingualTest extends InstallerConfigDirectoryTe
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/multilingual'; return __DIR__ . '/../../../fixtures/config_install/multilingual';
} }

View File

@ -28,7 +28,7 @@ class InstallerExistingConfigNoConfigTest extends InstallerConfigDirectoryTestBa
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config'; return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config';
} }

View File

@ -44,7 +44,7 @@ class InstallerExistingConfigNoSystemSiteTest extends InstallerConfigDirectoryTe
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/testing_config_install'; return __DIR__ . '/../../../fixtures/config_install/testing_config_install';
} }

View File

@ -55,7 +55,7 @@ EOF;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
// We're not going to get to the config import stage so this does not // We're not going to get to the config import stage so this does not
// matter. // matter.
return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config'; return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config';

View File

@ -43,7 +43,7 @@ class InstallerExistingConfigSyncDirectoryMultilingualTest extends InstallerConf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/multilingual'; return __DIR__ . '/../../../fixtures/config_install/multilingual';
} }
@ -195,7 +195,7 @@ PO;
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -74,7 +74,7 @@ EOF;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/multilingual'; return __DIR__ . '/../../../fixtures/config_install/multilingual';
} }

View File

@ -29,7 +29,7 @@ class InstallerExistingConfigSyncDirectoryProfileMismatchTest extends InstallerC
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/multilingual'; return __DIR__ . '/../../../fixtures/config_install/multilingual';
} }

View File

@ -37,7 +37,7 @@ class InstallerExistingConfigTest extends InstallerConfigDirectoryTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getConfigLocation() { protected function getConfigLocation(): string {
return __DIR__ . '/../../../fixtures/config_install/testing_config_install'; return __DIR__ . '/../../../fixtures/config_install/testing_config_install';
} }

View File

@ -47,7 +47,7 @@ class InstallerTranslationMultipleLanguageNonInteractiveTest extends BrowserTest
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -44,7 +44,7 @@ class InstallerTranslationMultipleLanguageTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -76,7 +76,7 @@ class InstallerTranslationQueryTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -154,7 +154,7 @@ class InstallerTranslationTest extends InstallerTestBase {
* @return string * @return string
* Contents for the test .po file. * Contents for the test .po file.
*/ */
protected function getPo($langcode) { protected function getPo($langcode): string {
return <<<PO return <<<PO
msgid "" msgid ""
msgstr "" msgstr ""

View File

@ -469,7 +469,7 @@ class EntityDecoupledTranslationRevisionsTest extends EntityKernelTestBase {
* @return string * @return string
* A revision label. * A revision label.
*/ */
protected function generateNewEntityLabel(ContentEntityInterface $revision, $previous_revision_id, $next = FALSE) { protected function generateNewEntityLabel(ContentEntityInterface $revision, $previous_revision_id, $next = FALSE): string {
$language_label = $revision->language()->getName(); $language_label = $revision->language()->getName();
$revision_type = $revision->isDefaultRevision() ? 'Default' : 'Pending'; $revision_type = $revision->isDefaultRevision() ? 'Default' : 'Pending';
$revision_id = $next ? $this->storage->getLatestRevisionId($revision->id()) + 1 : $revision->getLoadedRevisionId(); $revision_id = $next ? $this->storage->getLatestRevisionId($revision->id()) + 1 : $revision->getLoadedRevisionId();

View File

@ -83,7 +83,7 @@ trait BrowserHtmlDebugTrait {
* @return string * @return string
* The formatted HTML string. * The formatted HTML string.
*/ */
protected function formatHtmlOutputHeaders(array $headers) { protected function formatHtmlOutputHeaders(array $headers): string {
$flattened_headers = array_map(function ($header) { $flattened_headers = array_map(function ($header) {
if (is_array($header)) { if (is_array($header)) {
return implode(';', array_map('trim', $header)); return implode(';', array_map('trim', $header));

View File

@ -31,7 +31,7 @@ class PhpArrayDumperTest extends OptimizedPhpArrayDumperTest {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected static function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { protected static function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): string {
if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
return sprintf('@?%s', $id); return sprintf('@?%s', $id);
} }
@ -42,7 +42,7 @@ class PhpArrayDumperTest extends OptimizedPhpArrayDumperTest {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected static function getParameterCall($name) { protected static function getParameterCall($name): string {
return '%' . $name . '%'; return '%' . $name . '%';
} }

View File

@ -27,7 +27,7 @@ class PhpArrayContainerTest extends ContainerTest {
/** /**
* Helper function to return a service definition. * Helper function to return a service definition.
*/ */
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): string {
if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
return sprintf('@?%s', $id); return sprintf('@?%s', $id);
} }
@ -38,7 +38,7 @@ class PhpArrayContainerTest extends ContainerTest {
/** /**
* Helper function to return a service definition. * Helper function to return a service definition.
*/ */
protected function getParameterCall($name) { protected function getParameterCall($name): string {
return '%' . $name . '%'; return '%' . $name . '%';
} }

View File

@ -191,7 +191,7 @@ class GraphTest extends TestCase {
* @param $keys * @param $keys
* (optional) Whether to output the keys of $paths instead of the values. * (optional) Whether to output the keys of $paths instead of the values.
*/ */
protected function displayArray($paths, $keys = FALSE) { protected function displayArray($paths, $keys = FALSE): string {
if (!empty($paths)) { if (!empty($paths)) {
return implode(', ', $keys ? array_keys($paths) : $paths); return implode(', ', $keys ? array_keys($paths) : $paths);
} }

View File

@ -24,7 +24,7 @@ trait ExecTrait {
* @return string * @return string
* Standard output from the command * Standard output from the command
*/ */
protected function mustExec($cmd, $cwd, array $env = []) { protected function mustExec($cmd, $cwd, array $env = []): string {
$process = Process::fromShellCommandline($cmd, $cwd, $env + ['PATH' => getenv('PATH'), 'HOME' => getenv('HOME')]); $process = Process::fromShellCommandline($cmd, $cwd, $env + ['PATH' => getenv('PATH'), 'HOME' => getenv('HOME')]);
$process->setTimeout(300)->setIdleTimeout(300)->run(); $process->setTimeout(300)->setIdleTimeout(300)->run();
$exitCode = $process->getExitCode(); $exitCode = $process->getExitCode();

View File

@ -84,7 +84,7 @@ class ManageGitIgnoreTest extends TestCase {
* @return string * @return string
* The path to the fixture directory. * The path to the fixture directory.
*/ */
protected function createSutWithGit($fixture_name) { protected function createSutWithGit($fixture_name): string {
$this->fixturesDir = $this->fixtures->tmpDir($this->name()); $this->fixturesDir = $this->fixtures->tmpDir($this->name());
$sut = $this->fixturesDir . '/' . $fixture_name; $sut = $this->fixturesDir . '/' . $fixture_name;
$replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->projectRoot]; $replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->projectRoot];

View File

@ -92,7 +92,7 @@ class ScaffoldTest extends TestCase {
* @return string * @return string
* The path to the created System-Under-Test. * The path to the created System-Under-Test.
*/ */
protected function createSut($fixture_name, array $replacements = []) { protected function createSut($fixture_name, array $replacements = []): string {
$sut = $this->fixturesDir . '/' . $fixture_name; $sut = $this->fixturesDir . '/' . $fixture_name;
// Erase just our sut, to ensure it is clean. Recopy all of the fixtures. // Erase just our sut, to ensure it is clean. Recopy all of the fixtures.
$this->fileSystem->remove($sut); $this->fileSystem->remove($sut);

View File

@ -116,7 +116,7 @@ class ScaffoldUpgradeTest extends TestCase {
* @return string * @return string
* Path to temporary git repository. * Path to temporary git repository.
*/ */
protected function createTmpRepo($source, $destParent, $version) { protected function createTmpRepo($source, $destParent, $version): string {
$target = $destParent . '/' . basename($source); $target = $destParent . '/' . basename($source);
$filesystem = new Filesystem(); $filesystem = new Filesystem();
$filesystem->copy($source, $target); $filesystem->copy($source, $target);

View File

@ -218,7 +218,7 @@ class ComposerIntegrationTest extends UnitTestCase {
* *
* @return string * @return string
*/ */
protected static function getContentHash($composerFileContents) protected static function getContentHash($composerFileContents): string
{ {
$content = json_decode($composerFileContents, true); $content = json_decode($composerFileContents, true);

View File

@ -434,7 +434,7 @@ class VariationCacheTest extends UnitTestCase {
* @return string * @return string
* The correct cache ID. * The correct cache ID.
*/ */
protected function getSortedCacheId($cache_id_parts) { protected function getSortedCacheId($cache_id_parts): string {
sort($cache_id_parts); sort($cache_id_parts);
array_unshift($cache_id_parts, $this->cacheIdBase); array_unshift($cache_id_parts, $this->cacheIdBase);
return implode(':', $cache_id_parts); return implode(':', $cache_id_parts);

View File

@ -452,7 +452,7 @@ class EntityTypeManagerTest extends UnitTestCase {
* @return string * @return string
* A mock controller class name. * A mock controller class name.
*/ */
protected function getTestHandlerClass() { protected function getTestHandlerClass(): string {
return get_class($this->getMockForAbstractClass(EntityHandlerBase::class)); return get_class($this->getMockForAbstractClass(EntityHandlerBase::class));
} }

View File

@ -446,7 +446,7 @@ class EntityTypeTest extends UnitTestCase {
* @return string * @return string
* A mock controller class name. * A mock controller class name.
*/ */
protected function getTestHandlerClass() { protected function getTestHandlerClass(): string {
return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase')); return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase'));
} }

View File

@ -112,7 +112,7 @@ class TestFilteredPluginManager extends PluginManagerBase implements FilteredPlu
return $this->themeManager; return $this->themeManager;
} }
protected function getType() { protected function getType(): string {
return 'the_type'; return 'the_type';
} }

View File

@ -69,7 +69,7 @@ trait RandomGeneratorTrait {
* *
* @see \Drupal\Component\Utility\Random::name() * @see \Drupal\Component\Utility\Random::name()
*/ */
protected function randomMachineName($length = 8) { protected function randomMachineName($length = 8): string {
return Random::machineName($length); return Random::machineName($length);
} }

View File

@ -299,7 +299,7 @@ class TestSiteApplicationTest extends UnitTestCase {
* @return string * @return string
* The database key of the added connection. * The database key of the added connection.
*/ */
protected function addTestDatabase($db_prefix) { protected function addTestDatabase($db_prefix): string {
$database = Database::convertDbUrlToConnectionInfo(getenv('SIMPLETEST_DB'), $this->root); $database = Database::convertDbUrlToConnectionInfo(getenv('SIMPLETEST_DB'), $this->root);
$database['prefix'] = $db_prefix; $database['prefix'] = $db_prefix;
$target = __CLASS__ . $db_prefix; $target = __CLASS__ . $db_prefix;
@ -316,7 +316,7 @@ class TestSiteApplicationTest extends UnitTestCase {
* @return string * @return string
* The lock file path. * The lock file path.
*/ */
protected function getTestLockFile($db_prefix) { protected function getTestLockFile($db_prefix): string {
$lock_id = str_replace('test', '', $db_prefix); $lock_id = str_replace('test', '', $db_prefix);
return FileSystem::getOsTemporaryDirectory() . '/test_' . $lock_id; return FileSystem::getOsTemporaryDirectory() . '/test_' . $lock_id;
} }

View File

@ -22,7 +22,7 @@ trait TestRequirementsTrait {
* *
* @return string * @return string
*/ */
protected static function getDrupalRoot() { protected static function getDrupalRoot(): string {
return dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2); return dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
} }

View File

@ -511,7 +511,7 @@ trait UiHelperTrait {
* @return string * @return string
* The equivalent XPath of a CSS expression. * The equivalent XPath of a CSS expression.
*/ */
protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descendant-or-self::') { protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descendant-or-self::'): string {
return (new CssSelectorConverter($html))->toXPath($selector, $prefix); return (new CssSelectorConverter($html))->toXPath($selector, $prefix);
} }