Class 'PHPUnit_Framework_TestCase' not found

This error occurs in my public build project: https://travis-ci.org/byjg/authuser/jobs/211336643

I started locally using php 7.0 and php 7.1 on my Ubuntu and this problem does not occur.

Travis successfully runs on PHP 5.6

could you help me?

+9
travis-ci
Mar 15 '17 at 13:26
source share
1 answer

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'); 
+14
Mar 16 '17 at 8:19
source share



All Articles