AcceptJsPaymentMethodTest fails due to invalid permission

Created on 30 August 2024, 3 months ago
Updated 16 September 2024, 3 months ago

In the tests run with Drupal 11 and Commerce 3 the test fails due to these lines in Kernel\AcceptJsPaymentMethodTest.php
$user = $this->createUser(['mail' => $this->randomString() . '@example.com']);

The function createUser() expects permissions to be the first argument

The correct syntax is

    $user = $this->createUser([], NULL, FALSE, [
      'mail' => 'customer@example.com',
      'preferred_langcode' => 'en',
    ]);

It looks like passing values as the first parameter is depreciated in D11
https://www.drupal.org/node/3330762

  /**
   * Creates a user.
   *
   * @param array $permissions
   *   Array of permission names to assign to user. Note that the user always
   *   has the default permissions derived from the "authenticated users" role.
   * @param string $name
   *   The user name.
   * @param bool $admin
   *   (optional) Whether the user should be an administrator
   *   with all the available permissions.
   * @param array $values
   *   (optional) An array of initial user field values.
   *
   * @return \Drupal\user\Entity\User
   *   The created user entity.
   */
  protected function createUser(array $permissions = [], $name = NULL, bool $admin = FALSE, array $values = []) {
    return $this->drupalCreateUser($permissions, $name, $admin, $values);
  }
📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States rhovland Oregon

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024