I'm using the PHP-DI library and it works great for my code by using a bootstrap and config file, as recommended by the PHP-DI documentation.
Then, in my app, I'm getting the container and kicking things off by calling the bootstrap:
$container = require __DIR__ . '/Container/bootstrap.php';
$main = $container->get( Main::class );
So now I'm trying to set up unit testing with PHPUnit.
I'd like to get ahold of the $container in each Test class so that I can inject all of the dependencies of each test by using $container->injectOn($this) as suggested in the PHP-DI documentation.
I stumbled on this open issue [which is mostly over my head], but it is still open and doesn't seem to have any recommendations.
https://github.com/PHP-DI/PHP-DI/issues/125
My only thoughts are that I could just call bootstrap in setUp() the same way as my main app?
$container = require __DIR__ . '/Container/bootstrap.php';
Is this what I should be doing? Is there a more elegant or recommended way to do this?
Thanks!