Created
March 25, 2014 18:46
-
-
Save ppeiris/9768506 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 | |
namespace AccountServiceTest; | |
use Zend\Loader\AutoloaderFactory; | |
use Zend\Mvc\Service\ServiceManagerConfig; | |
use Zend\ServiceManager\ServiceManager; | |
use RuntimeException; | |
error_reporting(E_ALL | E_STRICT); | |
chdir(__DIR__); | |
/** | |
* Test bootstrap, for setting up autoloading | |
*/ | |
class Bootstrap | |
{ | |
protected static $serviceManager; | |
public static function init() | |
{ | |
static::initAutoloader(); | |
$zf2ModulePaths[] = '/var/www/oapp/vendor'; | |
$zf2ModulePaths[] = '/var/www/oapp/ServiceLayer'; | |
$zf2ModulePaths[] = '/var/www/oapp/PresentationApi'; | |
$zf2ModulePaths[] = '/var/www/oapp/PresentationLayer'; | |
$zf2ModulePaths[] = '/var/www/oapp/DataLayer'; | |
$zf2ModulePaths[] = '/var/www/oapp/Oapplib'; | |
$config = array( | |
'module_listener_options' => array( | |
'module_paths' => $zf2ModulePaths, | |
), | |
'modules' => array( | |
'OcraServiceManager', | |
'DoctrineModule', | |
'DoctrineORMModule', | |
'PDODblibModule', | |
'AssetsBundle', | |
'SimpleSamlAuth', | |
'OappAccessControl', | |
'Oapp', | |
'OappValidationListener', | |
'OappLogger', | |
'weblayout', | |
'uiHome', | |
'AccountsApi', | |
'uiAccounts', | |
'AccountService', | |
// 'Products', | |
'OappCacheManager', | |
'ErrorApi', | |
'UsersApi', | |
'UserService', | |
'ProductsApi', | |
'ProductService', | |
'Notification', | |
'UnitTestAuth' | |
) | |
); | |
$serviceManager = new ServiceManager(new ServiceManagerConfig()); | |
$serviceManager->setService('ApplicationConfig', $config); | |
$serviceManager->get('ModuleManager')->loadModules(); | |
static::$serviceManager = $serviceManager; | |
} | |
public static function getServiceManager() | |
{ | |
return static::$serviceManager; | |
} | |
protected static function initAutoloader() | |
{ | |
$vendorPath = static::findParentPath('vendor'); | |
if (is_readable($vendorPath . '/autoload.php')) { | |
$loader = include $vendorPath . '/autoload.php'; | |
return; | |
} | |
} | |
protected static function findParentPath($path) | |
{ | |
$dir = __DIR__; | |
$previousDir = '.'; | |
while (!is_dir($dir . '/' . $path)) { | |
$dir = dirname($dir); | |
if ($previousDir === $dir) { | |
return false; | |
} | |
$previousDir = $dir; | |
} | |
return $dir . '/' . $path; | |
} | |
} | |
Bootstrap::init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment