title: overriding zf2 modules configuration in phpunit test
body: <p>I'm trying to write a test for a module that requires a specific configuration change during a test run, overwriting the default configuration provided by the module's own <code>module.config.php</code>.</p>
  
  <p>In a normal application run, configuration is merged in order and I can use <code>config/autoload/*.local.php</code> to supersede module's config. But during a phpunit run those files aren't loaded, and I can't find a way to modify it during testing runtime.</p>
  
  <p>I tried modifying the config in my Bootstrap file, to no avail; and even in the test controller setup directly:</p>
  
  <pre><code>public function setUp()
  {
  
      $app_config = include(Bootstrap::getRootPath() . '/config/application.config.php');
      $test_config = Bootstrap::getTestConfig();
  
      $new_config = ArrayUtils::merge($app_config, $test_config);
  
      $this-&gt;setApplicationConfig($new_config);
  
  }
  </code></pre>
  
  <p>But by the time one of the factories is running I check the values for the config during a debug session, and my injected values are nowhere to be found.</p>
  
  <p>Also tried hooking to <code>EVENT_MERGE_CONFIG</code> and modify it there:</p>
  
  <pre><code>public static function onMergeConfig(ModuleEvent $e)
  {
      $configListener = $e-&gt;getConfigListener();
      $config = $configListener-&gt;getMergedConfig(false);
  
      $new_config = ArrayUtils::merge($config, $this-&gt;getTestConfig(static::$zf2ModulePaths));
  
      // Pass the changed configuration back to the listener:
      $configListener-&gt;setMergedConfig($new_config);
  }
  </code></pre>
  
  <p>What's the proper way to accomplish this?</p>