Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
These are:
System/PasswordHashingTest.php
Tests that require a fully bootstrapped environment and/or the database are:
System/SettingsRewriteTest.phpSystem/SystemInitTest.php
Test that have been converted already:
System/ExceptionControllerTest.php
Comment | File | Size | Author |
---|---|---|---|
#38 | 2008566-pwhash-test-38.patch | 8.05 KB | kim.pepper |
#33 | interdiff.txt | 1.62 KB | kim.pepper |
#33 | 2008566-system-phpunit-33.patch | 8.2 KB | kim.pepper |
#27 | interdiff.txt | 509 bytes | kim.pepper |
#27 | 2008566-system-phpunit-27.patch | 8.24 KB | kim.pepper |
Comments
Comment #1
jhedstromOf the 4 classes listed in summary, only 2 are easy conversions, here in this patch.
The other 2 require either a database connection, or writing out of files and expect a bootstrapped system.
Comment #2
ParisLiakos CreditAttribution: ParisLiakos commentedcool!
Should be
Contains \Drupal\Tests\Core\Controller\ExceptionControllerTest
lets rename it to test405Html() since we are here:)
same as above with Contains \...
lets add public visibility to this method
Comment #3
jhedstromThis should cover #2.
Comment #5
jhedstrom#3: system-system-phpunit-2008566-03.patch queued for re-testing.
Comment #6
Berdir#3: system-system-phpunit-2008566-03.patch queued for re-testing.
Comment #7
BerdirPasswordHashingTest was converted to a DUBT test because the Password class now type hints on UserInterface and uses methods.
It's still possible to convert it, but now you need to mock the user objects.
Comment #8
BerdirHm, that wasn't trivial.
Comment #9
jhedstromComment #10
ParisLiakos CreditAttribution: ParisLiakos commentedseems this test got already converted to PHPunit in another issue
here we need a
@group Drupal
in the class docblock
Comment #11
ParisLiakos CreditAttribution: ParisLiakos commentedComment #12
kim.pepperRe-roll.
Comment #15
kim.pepperI've tried to clean up this unit test class a bit. Changes include:
Comment #18
kim.pepperComment #19
kim.pepperThis splits out the rehashing to another test, and fixes the issue with using UserInterface.
Comment #20
larowlannitpick, needs to start with a capital letter and end with a .
Was expecting to see conversion of
System/SettingsRewriteTest.php
System/ExceptionControllerTest.php
System/SystemInitTest.php
as well, as per issue summary
Comment #21
kim.pepperThanks for the review.
PasswordHashingTest is the only one that can be converted.
ExceptionControllerTest got converted already. See comment #10
System/SettingsRewriteTest.php and System/SystemInitTest.php either require a fully bootstrapped system, or access to the database.
K
Comment #22
kim.pepperComment #23
kim.pepperComment #24
dawehnerDrupal core now even uses @inheritdoc for getInfo
This could use assertNotEquals
Should be contains.
Comment #25
kim.pepperThanks dawehner!
Fixes issues in #24
Comment #26
kim.pepperMissed one!
Comment #27
kim.pepperFixed "Contains of ... "
Comment #29
dawehnerThank you!
Comment #30
steeloctopus CreditAttribution: steeloctopus commentedI have applied the patch and all the PHPUnit test still work.
Comment #31
steeloctopus CreditAttribution: steeloctopus commented27: 2008566-system-phpunit-27.patch queued for re-testing.
Comment #32
alexpottWe're in a PHPUnit test - this is not needed :)
The doc blocks should be like this:
The @var for the user object should be
@var \PHPUnit_Framework_MockObject_MockObject|\Drupal\user\UserInterface
Comment #33
kim.pepperFixes for #32
Comment #34
Berdir33: 2008566-system-phpunit-33.patch queued for re-testing.
Comment #37
kim.pepperComment #38
kim.pepperRe-rolled #33 plus modernised test meta info.
Comment #39
dawehnerAwesome! I think it is fine to mark some methods as public.
Comment #40
alexpottCommitted 6c5130d and pushed to 8.x. Thanks!