Fix incorrect usage of randomStringValidate in \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::setUp

Created on 5 May 2023, about 1 year ago
Updated 22 June 2023, 12 months ago

Problem/Motivation

Discovered whilst working on 📌 [META] Deprecate non-static random generation methods from RandomGeneratorTrait Active .

In \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::setUp there's the following code:

    $this->node = Node::create([
      'title' => 'dummy_title',
      'type' => 'article',
      'uid' => $this->user,
      'body' => [
        'format' => 'plain_text',
        'value' => $this->randomStringValidate(42),
      ],
[snipped]
    ]);

\Drupal\Tests\RandomGeneratorTrait::randomStringValidate() validates if a given string is valid (no consecutive spaces and no starting/ending spaces) and returns a boolean.

I can see no use in a body that is TRUE or FALSE, besides 42 not being a string in the first place, and think $this->randomStringValidate(42) is a typo/auto-extend error and should have been $this->randomString(42), where it's even debatable if 42 is needed/wanted and not a clever Hitch-hiker Guide reference.

Steps to reproduce

Proposed resolution

Replace $this->randomStringValidate(42) with $this->randomString(42)

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component
JSON API 

Last updated 1 day ago

Created by

🇳🇱Netherlands Spokje

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024