Skip to content
Snippets Groups Projects
Verified Commit b3f2f8de authored by Dave Long's avatar Dave Long
Browse files

Issue #3402007 by marvil07, mstrelan, quietone, smustgrave, larowlan: Fix...

Issue #3402007 by marvil07, mstrelan, quietone, smustgrave, larowlan: Fix strict type errors in test modules

(cherry picked from commit d43e2ba8)
parent 7a9d25c6
Branches 6.x-1.x
Tags 6.x-1.1
17 merge requests!10663Issue #3495778: Update phpdoc in FileSaveHtaccessLoggingTest,!10451Issue #3472458 by watergate, smustgrave: CKEditor 5 show blocks label is not translated,!103032838547 Fix punctuation rules for inline label suffix colon with CSS only,!10150Issue #3467294 by quietone, nod_, smustgrave, catch, longwave: Change string...,!10130Resolve #3480321 "Second level menu",!9936Issue #3483087: Check the module:// prefix in the translation server path and replace it with the actual module path,!9933Issue #3394728 by ankondrat4: Undefined array key "#prefix" and deprecated function: explode() in Drupal\file\Element\ManagedFile::uploadAjaxCallback(),!9914Issue #3451136 by quietone, gapple, ghost of drupal past: Improve...,!9882Draft: Issue #3481777 In bulk_form ensure the triggering element is the bulk_form button,!9839Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9815Issue #3480025: There is no way to remove entity cache items,!9757Issue #3478869 Add "All" or overview links to parent links,!9752Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9749Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9678Issue #3465132 by catch, Spokje, nod_: Show test run time by class in run-tests.sh output,!9578Issue #3304746 by scott_euser, casey, smustgrave: BigPipe cannot handle (GET)...,!9449Issue #3344041: Allow textarea widgets to be used for text (formatted) fields
Pipeline #248687 canceled
Pipeline: drupal

#248694

    Showing
    with 21 additions and 18 deletions
    ...@@ -20,7 +20,7 @@ public function __invoke(): \Closure { ...@@ -20,7 +20,7 @@ public function __invoke(): \Closure {
    return function ($handler) { return function ($handler) {
    return function (RequestInterface $request, array $options) use ($handler): PromiseInterface { return function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
    $test_end_point = \Drupal::state()->get('announce_test_endpoint'); $test_end_point = \Drupal::state()->get('announce_test_endpoint');
    if ($test_end_point && str_contains($request->getUri(), '://www.drupal.org/announcements.json')) { if ($test_end_point && str_contains((string) $request->getUri(), '://www.drupal.org/announcements.json')) {
    // Only override $uri if it matches the advisories JSON feed to avoid // Only override $uri if it matches the advisories JSON feed to avoid
    // changing any other uses of the 'http_client' service during tests with // changing any other uses of the 'http_client' service during tests with
    // this module installed. // this module installed.
    ......
    ...@@ -22,7 +22,7 @@ public function testMultipleForms() { ...@@ -22,7 +22,7 @@ public function testMultipleForms() {
    // see if there's only one in the tests. // see if there's only one in the tests.
    $post_render_callable = function ($elements) { $post_render_callable = function ($elements) {
    $matches = []; $matches = [];
    preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', $elements, $matches); preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', (string) $elements, $matches);
    $action_values = $matches[2]; $action_values = $matches[2];
    ......
    ...@@ -18,7 +18,7 @@ public function __invoke() { ...@@ -18,7 +18,7 @@ public function __invoke() {
    return function ($handler) { return function ($handler) {
    return function (RequestInterface $request, array $options) use ($handler): PromiseInterface { return function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
    $test_end_point = \Drupal::state()->get('advisories_test_endpoint'); $test_end_point = \Drupal::state()->get('advisories_test_endpoint');
    if ($test_end_point && str_contains($request->getUri(), '://updates.drupal.org/psa.json')) { if ($test_end_point && str_contains((string) $request->getUri(), '://updates.drupal.org/psa.json')) {
    // Only override $uri if it matches the advisories JSON feed to avoid // Only override $uri if it matches the advisories JSON feed to avoid
    // changing any other uses of the 'http_client' service during tests with // changing any other uses of the 'http_client' service during tests with
    // this module installed. // this module installed.
    ......
    ...@@ -59,7 +59,7 @@ public function testMethod() { ...@@ -59,7 +59,7 @@ public function testMethod() {
    * @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
    * CSRF token. * CSRF token.
    */ */
    public function getCsrfToken($num) { public function getCsrfToken(int $num) {
    sleep($num); sleep($num);
    return new JsonResponse($this->tokenGenerator->get()); return new JsonResponse($this->tokenGenerator->get());
    } }
    ......
    ...@@ -94,7 +94,7 @@ public function response() { ...@@ -94,7 +94,7 @@ public function response() {
    public function responseEarly() { public function responseEarly() {
    $render_array = $this->earlyRenderContent(); $render_array = $this->earlyRenderContent();
    return new Response($this->renderer->render($render_array)); return new Response((string) $this->renderer->render($render_array));
    } }
    public function responseWithAttachments() { public function responseWithAttachments() {
    ...@@ -103,7 +103,7 @@ public function responseWithAttachments() { ...@@ -103,7 +103,7 @@ public function responseWithAttachments() {
    public function responseWithAttachmentsEarly() { public function responseWithAttachmentsEarly() {
    $render_array = $this->earlyRenderContent(); $render_array = $this->earlyRenderContent();
    return new AttachmentsTestResponse($this->renderer->render($render_array)); return new AttachmentsTestResponse((string) $this->renderer->render($render_array));
    } }
    public function cacheableResponse() { public function cacheableResponse() {
    ...@@ -112,7 +112,7 @@ public function cacheableResponse() { ...@@ -112,7 +112,7 @@ public function cacheableResponse() {
    public function cacheableResponseEarly() { public function cacheableResponseEarly() {
    $render_array = $this->earlyRenderContent(); $render_array = $this->earlyRenderContent();
    return new CacheableTestResponse($this->renderer->render($render_array)); return new CacheableTestResponse((string) $this->renderer->render($render_array));
    } }
    public function domainObject() { public function domainObject() {
    ......
    ...@@ -61,7 +61,7 @@ public function generateWarnings($collect_errors = FALSE) { ...@@ -61,7 +61,7 @@ public function generateWarnings($collect_errors = FALSE) {
    public function generateFatalErrors() { public function generateFatalErrors() {
    $function = function (array $test) { $function = function (array $test) {
    }; };
    // Use an incorrect parameter type, string, for testing a fatal error.
    $function("test-string"); $function("test-string");
    return []; return [];
    } }
    ......
    ...@@ -43,7 +43,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $first = ...@@ -43,7 +43,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $first =
    foreach ($args as $arg) { foreach ($args as $arg) {
    $name = 'button' . ++$i; $name = 'button' . ++$i;
    // 's', 'b', or 'i' in the argument define the button type wanted. // 's', 'b', or 'i' in the argument define the button type wanted.
    if (str_contains($arg, 's')) { if (!is_string($arg)) {
    $type = NULL;
    }
    elseif (str_contains($arg, 's')) {
    $type = 'submit'; $type = 'submit';
    } }
    elseif (str_contains($arg, 'b')) { elseif (str_contains($arg, 'b')) {
    ......
    ...@@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    * @see \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery() * @see \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
    */ */
    public static function postRender($rendered_form) { public static function postRender($rendered_form) {
    return str_replace('value="two"', 'value="FORGERY"', $rendered_form); return str_replace('value="two"', 'value="FORGERY"', (string) $rendered_form);
    } }
    /** /**
    ......
    ...@@ -11,7 +11,7 @@ class RenderArrayNonHtmlSubscriberTestController extends ControllerBase { ...@@ -11,7 +11,7 @@ class RenderArrayNonHtmlSubscriberTestController extends ControllerBase {
    * @return string * @return string
    */ */
    public function rawString() { public function rawString() {
    return new Response($this->t('Raw controller response.')); return new Response((string) $this->t('Raw controller response.'));
    } }
    /** /**
    ......
    ...@@ -111,7 +111,7 @@ public function noSet($test_value) { ...@@ -111,7 +111,7 @@ public function noSet($test_value) {
    */ */
    public function setMessage() { public function setMessage() {
    $this->messenger()->addStatus($this->t('This is a dummy message.')); $this->messenger()->addStatus($this->t('This is a dummy message.'));
    return new Response($this->t('A message was set.')); return new Response((string) $this->t('A message was set.'));
    // Do not return anything, so the current request does not result in a themed // Do not return anything, so the current request does not result in a themed
    // page with messages. The message will be displayed in the following request // page with messages. The message will be displayed in the following request
    // instead. // instead.
    ...@@ -240,8 +240,8 @@ public function hasSessionBagFlag(Request $request) { ...@@ -240,8 +240,8 @@ public function hasSessionBagFlag(Request $request) {
    /** @var \Drupal\session_test\Session\TestSessionBag */ /** @var \Drupal\session_test\Session\TestSessionBag */
    $bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME); $bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
    return new Response(empty($bag->hasFlag()) return new Response(empty($bag->hasFlag())
    ? $this->t('Flag is absent from session bag') ? (string) $this->t('Flag is absent from session bag')
    : $this->t('Flag is present in session bag') : (string) $this->t('Flag is present in session bag')
    ); );
    } }
    ......
    ...@@ -27,7 +27,7 @@ class SessionTestSubscriber implements EventSubscriberInterface { ...@@ -27,7 +27,7 @@ class SessionTestSubscriber implements EventSubscriberInterface {
    */ */
    public function onKernelRequestSessionTest(RequestEvent $event) { public function onKernelRequestSessionTest(RequestEvent $event) {
    $session = $event->getRequest()->getSession(); $session = $event->getRequest()->getSession();
    $this->emptySession = (int) !($session && $session->start()); $this->emptySession = !($session && $session->start());
    } }
    /** /**
    ...@@ -39,7 +39,7 @@ public function onKernelRequestSessionTest(RequestEvent $event) { ...@@ -39,7 +39,7 @@ public function onKernelRequestSessionTest(RequestEvent $event) {
    public function onKernelResponseSessionTest(ResponseEvent $event) { public function onKernelResponseSessionTest(ResponseEvent $event) {
    // Set header for session testing. // Set header for session testing.
    $response = $event->getResponse(); $response = $event->getResponse();
    $response->headers->set('X-Session-Empty', $this->emptySession); $response->headers->set('X-Session-Empty', $this->emptySession ? '1' : '0');
    } }
    /** /**
    ......
    ...@@ -303,7 +303,7 @@ public function setHeader(Request $request) { ...@@ -303,7 +303,7 @@ public function setHeader(Request $request) {
    $response = new CacheableResponse(); $response = new CacheableResponse();
    $response->headers->set($query['name'], $query['value']); $response->headers->set($query['name'], $query['value']);
    $response->getCacheableMetadata()->addCacheContexts(['url.query_args:name', 'url.query_args:value']); $response->getCacheableMetadata()->addCacheContexts(['url.query_args:name', 'url.query_args:value']);
    $response->setContent($this->t('The following header was set: %name: %value', ['%name' => $query['name'], '%value' => $query['value']])); $response->setContent((string) $this->t('The following header was set: %name: %value', ['%name' => $query['name'], '%value' => $query['value']]));
    return $response; return $response;
    } }
    ......
    ...@@ -85,7 +85,7 @@ public function renderPage() { ...@@ -85,7 +85,7 @@ public function renderPage() {
    * @param int $code * @param int $code
    * The status code. * The status code.
    */ */
    public function httpResponseException($code) { public function httpResponseException(int $code) {
    throw new HttpException($code); throw new HttpException($code);
    } }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment