/**
  * Setup test case needed properties
  * 
  * @access public
  */
 public function setUp()
 {
     $this->serviceManager = \PhpunitBootstrap::getServiceManager();
     if (empty($this->getApplicationConfig())) {
         $this->setApplicationConfig($this->serviceManager->get('ApplicationConfig'));
     }
     $this->application = $this->getApplication();
     $this->fixtureLoader = $this->serviceManager->get("Utilities\\Service\\Fixture\\FixtureLoader");
     $this->fixtureLoader->setDefaultFixtures(array("System\\Fixture\\Settings", "Users\\Fixture\\Acl", "Users\\Fixture\\Role"));
     // refresh DB structure
     if (self::$firstTestCaseFlag === true) {
         shell_exec("bin/doctrine orm:schema-tool:drop --force; " . "bin/doctrine orm:schema-tool:update --force;");
     } else {
         $this->truncateDatabase();
     }
     parent::setUp();
     self::$firstTestCaseFlag = false;
 }
 * Test bootstrap, for setting up autoloading
 */
class PhpunitBootstrap
{
    protected static $serviceManager;
    public static function init()
    {
        static::initAutoloader();
        $serviceManager = new ServiceManager(new ServiceManagerConfig());
        $serviceManager->setService('ApplicationConfig', require 'config/application.config.php');
        $serviceManager->get('ModuleManager')->loadModules();
        static::$serviceManager = $serviceManager;
    }
    public static function getServiceManager()
    {
        return static::$serviceManager;
    }
    protected static function initAutoloader()
    {
        $vendorPath = 'vendor';
        if (file_exists($vendorPath . '/autoload.php')) {
            include $vendorPath . '/autoload.php';
        }
        if (!class_exists('Zend\\Loader\\AutoloaderFactory')) {
            throw new \RuntimeException('Unable to load ZF2. Run `php composer.phar install`');
        }
        AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__))));
    }
}
PhpunitBootstrap::init();