Hi everyone!
I’m trying to write some functional tests for my application. I found this post Mezzio Example: Functional and Unit Testing - Marc Guyer which got me started somewhat, but the problem I’m having is that when I run the test, the application doesn’t have a connection to the database.
Cut down to the basics, the test has this setUp function, that initializes the app.
protected function setUp(): void
{
parent::setUp();
$this->container = require __DIR__ . '/../config/container.php';
$this->app = $this->container->get(Application::class);
$factory = $this->container->get(MiddlewareFactory::class);
(require __DIR__ . '/../config/pipeline.php')($this->app, $factory, $this->container);
(require __DIR__ . '/../config/routes.php')($this->app, $factory, $this->container);
}
How can I ensure that the application, when I instantiate classes, has a database connection?
If I need to provide more information, please let me know!
Thanks in advance, Roel