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
- Change the namespace and folder name
- 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