Skip to content
Snippets Groups Projects
Verified Commit 50496b5e 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 dfbd247c
Branches
Tags
10 merge requests!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #248686 failed
Pipeline: drupal

#248692

    Showing
    with 21 additions and 18 deletions
    ......@@ -20,7 +20,7 @@ public function __invoke(): \Closure {
    return function ($handler) {
    return function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
    $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
    // changing any other uses of the 'http_client' service during tests with
    // this module installed.
    ......
    ......@@ -22,7 +22,7 @@ public function testMultipleForms() {
    // see if there's only one in the tests.
    $post_render_callable = function ($elements) {
    $matches = [];
    preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', $elements, $matches);
    preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', (string) $elements, $matches);
    $action_values = $matches[2];
    ......
    ......@@ -18,7 +18,7 @@ public function __invoke() {
    return function ($handler) {
    return function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
    $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
    // changing any other uses of the 'http_client' service during tests with
    // this module installed.
    ......
    ......@@ -59,7 +59,7 @@ public function testMethod() {
    * @return \Symfony\Component\HttpFoundation\Response
    * CSRF token.
    */
    public function getCsrfToken($num) {
    public function getCsrfToken(int $num) {
    sleep($num);
    return new JsonResponse($this->tokenGenerator->get());
    }
    ......
    ......@@ -94,7 +94,7 @@ public function response() {
    public function responseEarly() {
    $render_array = $this->earlyRenderContent();
    return new Response($this->renderer->render($render_array));
    return new Response((string) $this->renderer->render($render_array));
    }
    public function responseWithAttachments() {
    ......@@ -103,7 +103,7 @@ public function responseWithAttachments() {
    public function responseWithAttachmentsEarly() {
    $render_array = $this->earlyRenderContent();
    return new AttachmentsTestResponse($this->renderer->render($render_array));
    return new AttachmentsTestResponse((string) $this->renderer->render($render_array));
    }
    public function cacheableResponse() {
    ......@@ -112,7 +112,7 @@ public function cacheableResponse() {
    public function cacheableResponseEarly() {
    $render_array = $this->earlyRenderContent();
    return new CacheableTestResponse($this->renderer->render($render_array));
    return new CacheableTestResponse((string) $this->renderer->render($render_array));
    }
    public function domainObject() {
    ......
    ......@@ -61,7 +61,7 @@ public function generateWarnings($collect_errors = FALSE) {
    public function generateFatalErrors() {
    $function = function (array $test) {
    };
    // Use an incorrect parameter type, string, for testing a fatal error.
    $function("test-string");
    return [];
    }
    ......
    ......@@ -43,7 +43,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $first =
    foreach ($args as $arg) {
    $name = 'button' . ++$i;
    // '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';
    }
    elseif (str_contains($arg, 'b')) {
    ......
    ......@@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    * @see \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
    */
    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 {
    * @return string
    */
    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) {
    */
    public function setMessage() {
    $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
    // page with messages. The message will be displayed in the following request
    // instead.
    ......@@ -240,8 +240,8 @@ public function hasSessionBagFlag(Request $request) {
    /** @var \Drupal\session_test\Session\TestSessionBag */
    $bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
    return new Response(empty($bag->hasFlag())
    ? $this->t('Flag is absent from session bag')
    : $this->t('Flag is present in session bag')
    ? (string) $this->t('Flag is absent from session bag')
    : (string) $this->t('Flag is present in session bag')
    );
    }
    ......
    ......@@ -27,7 +27,7 @@ class SessionTestSubscriber implements EventSubscriberInterface {
    */
    public function onKernelRequestSessionTest(RequestEvent $event) {
    $session = $event->getRequest()->getSession();
    $this->emptySession = (int) !($session && $session->start());
    $this->emptySession = !($session && $session->start());
    }
    /**
    ......@@ -39,7 +39,7 @@ public function onKernelRequestSessionTest(RequestEvent $event) {
    public function onKernelResponseSessionTest(ResponseEvent $event) {
    // Set header for session testing.
    $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) {
    $response = new CacheableResponse();
    $response->headers->set($query['name'], $query['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;
    }
    ......
    ......@@ -85,7 +85,7 @@ public function renderPage() {
    * @param int $code
    * The status code.
    */
    public function httpResponseException($code) {
    public function httpResponseException(int $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