Skip to content

Instantly share code, notes, and snippets.

@AydinHassan
Created March 9, 2014 17:01
Show Gist options
  • Save AydinHassan/9450825 to your computer and use it in GitHub Desktop.
Save AydinHassan/9450825 to your computer and use it in GitHub Desktop.
<?php
/**
* @author Marco Pivetta <[email protected]>
*/
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
use DoctrineORMModuleTest\Framework\TestCase;
use JhTimeTest\Util\ServiceManagerFactory;
use Zend\Loader\StandardAutoloader;
chdir(__DIR__);
ini_set('display_errors', 1);
error_reporting(E_ALL);
$previousDir = '.';
while (!file_exists('config/application.config.php')) {
$dir = dirname(getcwd());
if ($previousDir === $dir) {
throw new RuntimeException(
'Unable to locate "config/application.config.php":'
. ' is the Content module in a sub-directory of your application skeleton?'
);
}
$previousDir = $dir;
chdir($dir);
}
$dir = __DIR__;
$previousDir = '.';
while (!is_dir($dir . '/' . 'vendor')) {
$dir = dirname($dir);
if ($previousDir === $dir) {
return false;
}
$previousDir = $dir;
}
$vendorPath= $dir . '/' . 'vendor';
$zf2Path = $vendorPath . '/zendframework/zendframework/library';
if (!$zf2Path) {
throw new RuntimeException(
'Unable to load ZF2. Run `php composer.phar install` or'
. ' define a ZF2_PATH environment variable.'
);
}
if (file_exists($vendorPath . '/autoload.php')) {
include $vendorPath . '/autoload.php';
}
if (!$config = @include __DIR__ . '/TestConfiguration.php') {
$config = require __DIR__ . '/TestConfiguration.php.dist';
}
$loader = new StandardAutoloader();
$loader->registerNamespace('JhTimeTest', __DIR__ . '/JhTimeTest');
$loader->register();
$serviceManager = new ServiceManager(new ServiceManagerConfig(
isset($config['service_manager']) ? $config['service_manager'] : array()
));
$serviceManager->setService('ApplicationConfig', $config);
/** @var $moduleManager \Zend\ModuleManager\ModuleManager */
$moduleManager = $serviceManager->get('ModuleManager');
$moduleManager->loadModules();
ServiceManagerFactory::setApplicationConfig($config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment