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.
Problem/Motivation
Technically simpletest allows test methods to be both public and protected, but on the longrun we seem to convert stuff to
phpunit based testing, either via BrowserTestBase/KernelTestBaseNG/UnitTestCase, for which protected doens't work.
Proposed resolution
Replace all instances of protected test methods with public ones.
Here is a list of them:
Targets
Occurrences of 'protected function test' in Project
Found Occurrences (53 usages found)
Unclassified occurrence (53 usages found)
d8 (53 usages found)
core/modules/block/src/Tests/Views (1 usage found)
DisplayBlockTest.php (1 usage found)
(132: 3) protected function testDeleteBlockDisplay() {
core/modules/dblog/src/Tests (2 usages found)
DbLogTest.php (2 usages found)
(447: 3) protected function testDBLogAddAndClear() {
(482: 3) protected function testFilter() {
core/modules/search/src/Tests (1 usage found)
SearchBlockTest.php (1 usage found)
(35: 3) protected function testSearchFormBlock() {
core/modules/simpletest/src/Tests (1 usage found)
MissingCheckedRequirementsTest.php (1 usage found)
(47: 3) protected function testCheckRequirements() {
core/modules/system/src/Tests/Pager (1 usage found)
PagerTest.php (1 usage found)
(68: 3) protected function testPagerQueryParameters() {
core/modules/system/src/Tests/Session (1 usage found)
SessionHttpsTest.php (1 usage found)
(35: 3) protected function testHttpsSession() {
core/modules/user/src/Tests (2 usages found)
UserCreateFailMailTest.php (1 usage found)
(29: 3) protected function testUserAdd() {
UserCreateTest.php (1 usage found)
(30: 3) protected function testUserAdd() {
core/modules/views/src/Tests/Handler (1 usage found)
FilterDateTest.php (1 usage found)
(50: 3) protected function testDateFilter() {
core/modules/views/src/Tests/Plugin (1 usage found)
DisplayAttachmentTest.php (1 usage found)
(35: 3) protected function testAttachment() {
core/modules/views/src/Tests/Wizard (1 usage found)
BasicTest.php (1 usage found)
(175: 3) protected function testWizardForm() {
core/modules/views_ui/src/Tests (1 usage found)
PreviewTest.php (1 usage found)
(29: 3) protected function testPreviewContextual() {
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#3 | make-test-functions-public-2443381-3.patch | 7.68 KB | pjbaert |
Comments
Comment #1
pjbaertI changed all protected test methods to public.
Comment #2
dawehnerIt is looking great, beside one small case ...
Please don't change that, its part of phpunit itself, sorry.
Comment #3
pjbaertI updated my patch.
Comment #4
pjbaertComment #5
daffie CreditAttribution: daffie commentedLooks good to me.
You fixed the same 13 instances as the ones that I found.
Good work pjbaert!
Comment #6
alexpottTest code changes are permitted during beta. Committed cdfc902 and pushed to 8.0.x. Thanks!