[dev] PHPUnit 9.5 compat

Ralf Lang lang at b1-systems.de
Tue Mar 2 20:07:02 UTC 2021


Hello,

I added some changes to make Horde_Test compatible with phpunit 9.5.

This will not magically make all test suites run though.

StoryTestCases (used at least by horde components' integration/ tests)
are broken as the underlying library has been abandoned and the last
available version won't run with current phpunit. Sebastian suggests
looking into behat/behat to replace them.

setUp / tearDown methods: need changed signature :void

assertRegExp() is deprecated. Use assertMatchesRegularExpression() instead.

require_once lines in alltests.php and bootstrap.php must be made
conditional, checking if the class is loaded already


if (!class_exists('Horde_Test_AllTests')) {
    require_once 'Horde/Test/AllTests.php';
}

TestCase must be derived from \PHPUnit\Framework\TestCase rather than
PHPUnit_Framework_TestCase (or from Horde_Test_Case)

PHPUnit 9.5 generally seems to dislike PSR-0 for test classnames.


See a simple case: Horde_Data
https://github.com/maintaina-com/Data/commit/40c1455e636c45304196f9f557fe2b872b63add5


------------------------------
[   OK   ] Running PHPUnit testsuite on Data

PHP Notice:  Undefined index: extensions in
/srv/www/horde/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 1084
PHP Warning:  Invalid argument supplied for foreach() in
/srv/www/horde/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 1084
PHPUnit 9.5.2 by Sebastian Bergmann and contributors.


Warning:       Test case class not matching filename is deprecated
               in
/srv/www/horde/vendor/horde/data/test/Horde/Data/CsvTest.php
               Class name was 'Horde_Data_CsvTest', expected 'CsvTest'
Warning:       Test case class not matching filename is deprecated
               in
/srv/www/horde/vendor/horde/data/test/Horde/Data/GetCsvTest.php
               Class name was 'Horde_Data_GetCsvTest', expected 'GetCsvTest'

.............                                                     13 /
13 (100%)

Time: 00:00.008, Memory: 6.00 MB

OK (13 tests, 27 assertions)

[   OK   ] No problems found.
------------------------------

Changing to namespaced tests eliminates the warnings
https://github.com/maintaina-com/Data/commit/3da66225f5b7c003f97d0f07f9f769718c086efb


-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537



More information about the dev mailing list