antecedent/patchwork

The file that defines <Namespace::method> was included earlier than Patchwork. This is likely a result of an improper setup; see readme for details.

Closed this issue · 1 comments

Yes, it's this infamous error:
The file that defines Namespace::method was included earlier than Patchwork. This is likely a result of an improper setup; see readme for details.

Everything is fine when I run the test on a single file. But running All Tests results in multiple instances of this error.

My current project is using Laravel + PHPUnit and I cannot figure out for the life of me where to place the appropriate use, import or require_once statement to get rid of this error. Do I have to modify the phpunit bootstrap file, add something in composer.json's autoload-dev, or pray to the pagan gods for deliverance?

I'm a veritable novice when it comes to testing + backend configuration and any assistance would be appreciated.

Thanks in advance.

I solved it by making a custom bootstrap file for phpunit, and added the require_once for Patchwork before running the autoloader. Increased the memory limit also because PHP couldn't run Patchwork because it hit the limit.

ini_set('memory_limit', '256M');

require_once __DIR__ . '/../vendor/antecedent/patchwork/Patchwork.php';
require __DIR__ .'/../vendor/autoload.php';