Created
March 9, 2014 17:01
-
-
Save AydinHassan/9450825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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