Skip to content

Instantly share code, notes, and snippets.

@joshribakoff
Created June 1, 2013 05:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshribakoff/5689343 to your computer and use it in GitHub Desktop.
Save joshribakoff/5689343 to your computer and use it in GitHub Desktop.
phpunit bootstrap /zf2 service manager
<?php
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
class phpunit_bootstrap
{
static $serviceManager;
static function go()
{
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(__DIR__);
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
$config = require 'config/application.config.php';
Zend\Mvc\Application::init($config);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
self::$serviceManager = $serviceManager;
}
static public function getServiceManager()
{
return self::$serviceManager;
}
}
phpunit_bootstrap::go();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment