There is a difference between namespace structure between PHPUnit
<6 and PHPUnit
6.
You may consider the following solution for backward compatibility:
// backward compatibility
if (!class_exists('PHPUnitFrameworkTestCase') &&
class_exists('PHPUnit_Framework_TestCase')) {
class_alias('PHPUnit_Framework_TestCase', 'PHPUnitFrameworkTestCase');
}
The old PHPUnit
versions use PHPUnit_Framework_TestCase
but the new one uses PHPUnitFrameworkTestCase
. With the backward compatibility applied you can use the class name that is compatible with the new version of PHPUnit
(i.e. PHPUnitFrameworkTestCase
) and it is going to work also with older versions.
Update
In order to cover support for PHP 5.3 you have to remove a
character before the alias class, i.e.
class_alias('PHPUnit_Framework_TestCase', 'PHPUnitFrameworkTestCase');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…