Skip to content

Instantly share code, notes, and snippets.

@icqparty
Created October 26, 2014 01:43
Show Gist options
  • Save icqparty/b9eca6a016f4a8df0cb3 to your computer and use it in GitHub Desktop.
Save icqparty/b9eca6a016f4a8df0cb3 to your computer and use it in GitHub Desktop.
tests/phpunit.xml and Bootstrap.php
<?php
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\ServiceManager\ServiceManager;
error_reporting(E_ALL | E_STRICT);
chdir(dirname(__DIR__));
include __DIR__ . '/../init_autoloader.php';
class Bootstrap
{
protected static $serviceManager;
public static $config;
public static function init()
{
$testConfig = include 'config/application.config.php';
if (isset($testConfig['module_listener_options']['config_cache_enabled'])) {
$testConfig['module_listener_options']['config_cache_enabled'] = false;
}
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $testConfig);
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
static::$config = $testConfig;
}
}
Bootstrap::init();
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="ApplicationTest">
<directory suffix=".php">./ApplicationTest</directory>
</testsuite>
</testsuites>
</phpunit>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment