There is a difference between the namespace structure between PHPUnit <6 and PHPUnit 6.
You may consider the following solution for backward compatibility:
// backward compatibility if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) { class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); }
Older versions of PHPUnit use \PHPUnit_Framework_TestCase , but the new one uses \PHPUnit\Framework\TestCase . When using backward compatibility, you can use a class name that is compatible with the new version of PHPUnit (i.e. \PHPUnit\Framework\TestCase ), and it will work with older versions.
Update In order to cover PHP 5.3 support, you must remove the \ character in front of the alias class, i.e.
class_alias('\PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
Robson Mar 16 '17 at 8:19 2017-03-16 08:19
source share