I'm writing functional / controller tests for a ZF3 application (driven by PHPUnit and zendframework/zend-test
). Like this:
public function testWhatEver()
{
$this->dispatch('/');
$this->assertResponseStatusCode(Response::STATUS_CODE_200);
}
It's working pretty well. But now I got a case, where I need to test the application with multiple mutually exclusive configs.
E.g., the case "authentication": The application provides multiple authentication methods (let's say: AuthA
, AuthB
,AuthC
). (That is configurable via setting of the auth.type
's value in the config file.) I want to test each of them. That means, it's not enough to have special test configs in the /config/autoload/test/*{local|global}.php
. I need to be able to manipulate them for every test (before I call the dispatch(...)
method).
How to manipulate the application configs for / from controller tests (on the fly)?
If no better solution can be found, a possible workaround might be to edit the config file (by using file_put_contents(...)
or something like this) before every test. But it's a bit ugly (and slow).