Ejemplo n.º 1
0
 public function _initialize()
 {
     if (!file_exists($this->config['appPath'])) {
         throw new ModuleConfigException(__CLASS__, "Couldn't load application config file {$this->config['appPath']}\n" . "Please provide application bootstrap file configured for testing");
     }
     $this->appSettings = (include $this->config['appPath']);
     //get application settings in the entry script
     // get configuration from array or file
     if (is_array($this->appSettings['config'])) {
         $this->_appConfig = $this->appSettings['config'];
     } else {
         if (!file_exists($this->appSettings['config'])) {
             throw new ModuleConfigException(__CLASS__, "Couldn't load configuration file from Yii app file: {$this->appSettings['config']}\n" . "Please provide valid 'config' parameter");
         }
         $this->_appConfig = (include $this->appSettings['config']);
     }
     if (!defined('YII_ENABLE_EXCEPTION_HANDLER')) {
         define('YII_ENABLE_EXCEPTION_HANDLER', false);
     }
     if (!defined('YII_ENABLE_ERROR_HANDLER')) {
         define('YII_ENABLE_ERROR_HANDLER', false);
     }
     $_SERVER['SCRIPT_NAME'] = parse_url($this->config['url'], PHP_URL_PATH);
     $_SERVER['SCRIPT_FILENAME'] = $this->config['appPath'];
     if (!function_exists('launch_codeception_yii_bridge')) {
         throw new ModuleConfigException(__CLASS__, "Codeception-Yii Bridge is not launched. In order to run tests you need to install " . "https://github.com/Codeception/YiiBridge Implement function 'launch_codeception_yii_bridge' to " . "load all Codeception overrides");
     }
     launch_codeception_yii_bridge();
     Yii::$enableIncludePath = false;
     Yii::setApplication(null);
     Yii::createApplication($this->appSettings['class'], $this->_appConfig);
 }
Ejemplo n.º 2
0
<?php

use Codeception\Util\Autoload;
// no utf without this
setlocale(LC_ALL, 'en_US.UTF8');
// This is global bootstrap for autoloading
$ds = DIRECTORY_SEPARATOR;
Autoload::registerSuffix('Page', implode($ds, array(__DIR__, '_pages')));
Autoload::registerSuffix('Helper', implode($ds, array(__DIR__, '_support', 'helpers')));
// this shit sucks
// Yii isn't found by standard composer autoload
require_once dirname(__DIR__) . '/boot/testing-console.php';
require_once __DIR__ . '/_data/YiiBridge/yiit.php';
launch_codeception_yii_bridge();
#require_once dirname(__DIR__).'/vendor/codeception/codeception/Platform/RunFailed.php';
$helper = new \Codeception\Module\BootstrapHelper();
$helper->bootstrap();