Skip to content

Commit 0b09dcb

Browse files
committed
Accept any _testcase as valid
Historically we had a blur between `_test` and `_testcase`, but in recent versions we have largely solved this. We now expect: - every test class name to be suffixed with `_test` - every test class to be final - every test class to extend a testcase with class name suffixed `_testcase` - every testcase class to be abstract Given these parameters, which have been in place for some time and are checked with phpcs, we can move away from a hardcoded list of accepted testcases, and move towards a regular expression based on the name.
1 parent 87c1bf8 commit 0b09dcb

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

verify_phpunit_xml/verify_phpunit_xml.sh

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,17 @@ existingtests=$(cd ${gitdir} && find . -name tests | sed 's/^\.\/\(.*\)$/\1/g')
4444
ignoretests=""
4545

4646
# Unit test classes to look for with each file (must be 1 and only 1). MDLSITE-2096
47-
# TODO: Some day replace this with the list of abstract classes, using some classmap going up to phpunit top class.
47+
# TODO: When we stop supporting these class names, we can remove them.
4848
unittestclasses="
49-
advanced_testcase
5049
area_test_base
5150
badgeslib_test
52-
base_testcase
53-
basic_testcase
5451
cachestore_tests
55-
core_backup_backup_restore_base_testcase
56-
core_reportbuilder_testcase
5752
data_loading_method_test_base
58-
data_privacy_testcase
59-
database_driver_testcase
60-
externallib_advanced_testcase
61-
googledocs_content_testcase
62-
grade_base_testcase
63-
lti_advantage_testcase
6453
manage_category_test_base
6554
messagelib_test
66-
mod_assign\\\\externallib_advanced_testcase
67-
mod_lti_testcase
68-
mod_quiz_attempt_walkthrough_from_csv_testcase
6955
mod_quiz\\\\attempt_walkthrough_from_csv_test
70-
provider_testcase
7156
qbehaviour_walkthrough_test_base
7257
question_attempt_upgrader_test_base
73-
question_testcase
74-
repository_googledocs_testcase
75-
restore_date_testcase
76-
route_testcase
7758
"
7859

7960
# Verify that each existing test is covered by some defined test
@@ -105,8 +86,12 @@ do
10586
echo "ERROR: ${existing} is not matched/covered by any definition in phpunit.xml !"
10687
exitstatus=1
10788
fi
89+
10890
# Look inside all the test files, counting occurrences of $unittestclasses
10991
unittestclassesregex=$(echo ${unittestclasses} | sed 's/ /|/g')
92+
93+
# Also allow any testcase.
94+
unittestclassesregex="|_testcase"
11095
for testfile in $(ls ${existing} | grep "_test.php$")
11196
do
11297
# This is not the best (more accurate) regexp, but should be ok 99.99% of times.

0 commit comments

Comments
 (0)