protected function setUp() { global $CONFIG, $DB, $EXTENSIONHOOKRUNNER, $app; $CONFIG = new \Config(); require APP_ROOT_DIR . "config.test.php"; $CONFIG->isDebug = true; $this->setConfig($CONFIG); $EXTENSIONHOOKRUNNER = new ExtensionHookRunner(); /** @var PDO * */ if (!$DB) { $DB = new PDO('pgsql:host=' . $CONFIG->databaseHost . ';dbname=' . $CONFIG->databaseName, $CONFIG->databaseUser, $CONFIG->databasePassword); $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $DB->exec("SET CLIENT_ENCODING TO 'utf8'"); $DB->exec("SET NAMES 'utf8'"); } $this->app = new Silex\Application(); $app = $this->app; $this->app['debug'] = true; $this->app['extensions'] = new ExtensionManager($this->app); foreach ($CONFIG->extensions as $extensionName) { require APP_ROOT_DIR . '/extension/' . $extensionName . '/extension.php'; } $this->app['appconfig'] = new appconfiguration\AppConfigurationManager($DB, $CONFIG); $this->app['config'] = $CONFIG; $this->app['db'] = $DB; $this->app['timesource'] = new TimeSource(); foreach ($CONFIG->extensions as $extensionName) { $file = APP_ROOT_DIR . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . $extensionName . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'destroy.sql'; if (file_exists($file)) { foreach (explode(";", file_get_contents($file)) as $line) { if (trim($line)) { $DB->query($line . ';'); } } } } foreach (explode(";", file_get_contents(__DIR__ . "/../sql/destroy.sql")) as $line) { if (trim($line)) { $DB->query($line . ';'); } } db\migrations\MigrationManager::upgrade(false); }
<?php define('APP_ROOT_DIR', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR); require_once (defined('COMPOSER_ROOT_DIR') ? COMPOSER_ROOT_DIR : APP_ROOT_DIR) . '/vendor/autoload.php'; require_once APP_ROOT_DIR . '/core/php/autoload.php'; require_once APP_ROOT_DIR . '/core/php/autoloadCLI.php'; /** * * @package Core * @link http://ican.openacalendar.org/ OpenACalendar Open Source Software * @license http://ican.openacalendar.org/license.html 3-clause BSD * @copyright (c) 2013-2014, JMB Technology Limited, http://jmbtechnology.co.uk/ * @author James Baster <*****@*****.**> */ db\migrations\MigrationManager::upgrade(true);