Ensure Unit tests in phpass run and remove unneeded LegacyPasswordHashingTest::testInvalidArguments

Created on 10 October 2023, about 1 year ago
Updated 10 February 2024, 9 months ago

Problem/Motivation

Tests in core/modules/phpass/tests/src/Tests do not run

They need to be in core/modules/phpass/tests/src/Unit and have the Unit namespace in order to run

Steps to reproduce

The following command can be used to determine the tests discovered by phpunit (note that only the functional test is listed and the unit tests are missing):

% ../vendor/bin/phpunit --list-tests | grep '\\phpass'
 - Drupal\Tests\phpass\Functional\GenericTest::testModuleGenericIssues

Proposed resolution

  1. Change the namespace and folder name
  2. Remove outdated testInvalidArguments() test.

Note on the test removal:

Constructor type hints were added in the very last commit of the original MR. Without the type hints it was necessary to cover custom logic leading to the InvalidArgumentException. That was the reason for the test. But now that there is a type hint on the constructor argument and the custom logic is removed, the test isn't necessary anymore (and in fact fails because it expects another exception type). Since tests didn't run either on the original MR, it went undetected that the constructor change failed that particular test.

In order to verify the fix, the following command can be used (note that unit tests are listed in addition to the functional test):

% ../vendor/bin/phpunit --list-tests | grep '\\phpass'
 - Drupal\Tests\phpass\Unit\LegacyPasswordHashingTest::testPasswordNeedsUpdate
 - Drupal\Tests\phpass\Unit\LegacyPasswordHashingTest::testPasswordHashing
 - Drupal\Tests\phpass\Unit\LegacyPasswordHashingTest::testPasswordRehashing
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testPasswordHash
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testPasswordNeedsRehash
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testPasswordCheckUnknownHash
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testPasswordCheckSupported
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testWithinBounds
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testLongPassword"allowed"
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testLongPassword"too_long"
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testLongPassword"utf8"
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testLongPassword"ut8_extended"
 - Drupal\Tests\phpass\Unit\PasswordVerifyTest::testLongPassword"utf8_too_long"
 - Drupal\Tests\phpass\Functional\GenericTest::testModuleGenericIssues

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

10.1 ✨

Component
OtherΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024