/**
  * Initializes test environment
  * @param string $moduleName
  * @param array $modulesToBeLoaded (only used if > 1 module to be loaded)
  */
 public static function init($moduleName, $modulesToBeLoaded = NULL)
 {
     // assign module name
     self::$moduleName = $moduleName;
     // load main app config file
     $testConfig = (require __DIR__ . '/config/application.config.php');
     // override 'modules' key
     unset($testConfig['modules']);
     // load other modules (if defined)
     if ($modulesToBeLoaded) {
         foreach ($modulesToBeLoaded as $item) {
             $testConfig['modules'][] = $item;
         }
     } else {
         // just load one module
         $testConfig['modules'] = array(self::$moduleName);
     }
     // load the module and set up test autoloading
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $config = $serviceManager->get('Config');
     //var_dump($config); exit;
     static::$serviceManager = $serviceManager;
     static::$config = $config;
 }