本文整理汇总了PHP中Codeception\Configuration::projectDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::projectDir方法的具体用法?PHP Configuration::projectDir怎么用?PHP Configuration::projectDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codeception\Configuration
的用法示例。
在下文中一共展示了Configuration::projectDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$suite = $input->getArgument('suite');
$guy = $input->getArgument('guy');
$config = \Codeception\Configuration::config($input->getOption('config'));
$dir = \Codeception\Configuration::projectDir() . $config['paths']['tests'] . DIRECTORY_SEPARATOR;
if (file_exists($dir . DIRECTORY_SEPARATOR . $suite)) {
throw new \Exception("Directory {$suite} already exists.");
}
if (file_exists($dir . $suite . '.suite.yml')) {
throw new \Exception("Suite configuration file '{$suite}.suite.yml' already exists.");
}
@mkdir($dir . DIRECTORY_SEPARATOR . $suite);
// generate bootstrap
file_put_contents($dir . DIRECTORY_SEPARATOR . $suite . '/_bootstrap.php', "<?php\n// Here you can initialize variables that will for your tests\n");
if (strpos(strrev($guy), 'yuG') !== 0) {
$guy = $guy . 'Guy';
}
$guyname = substr($guy, 0, -3);
// generate helper
file_put_contents(\Codeception\Configuration::projectDir() . $config['paths']['helpers'] . DIRECTORY_SEPARATOR . $guyname . 'Helper.php', "<?php\nnamespace Codeception\\Module;\n\n// here you can define custom functions for {$guy} \n\nclass {$guyname}Helper extends \\Codeception\\Module\n{\n}\n");
$conf = array('class_name' => $guy, 'modules' => array('enabled' => array($guyname . 'Helper')));
file_put_contents($dir . $suite . '.suite.yml', Yaml::dump($conf, 2));
$output->writeln("<info>Suite {$suite} generated</info>");
}
示例2: _before
public function _before(\Codeception\TestCase $test)
{
require_once \Codeception\Configuration::projectDir() . 'src/includes/autoload.php';
require_once \Codeception\Configuration::projectDir() . 'src/includes/classmap.php';
require_once \Codeception\Configuration::projectDir() . 'src/Vendor/autoload.php';
spl_autoload_register('autoloadlitpi');
include_once \Codeception\Configuration::projectDir() . 'src/libs/smarty/Smarty.class.php';
//Overwrite remoteaddr
$_SERVER['REMOTE_ADDR'] = $this->config['remoteaddr'];
//INIT REGISTRY VARIABLE - MAIN STORAGE OF APPLICATION
$registry = \Litpi\Registry::getInstance();
$request = \Litpi\Request::createFromGlobals();
$response = new \Litpi\Response();
$session = new \Litpi\Session();
$registry->set('request', $request);
$registry->set('response', $response);
$registry->set('session', $session);
require_once \Codeception\Configuration::projectDir() . 'src/includes/conf.php';
require_once \Codeception\Configuration::projectDir() . 'src/includes/config.php';
require_once \Codeception\Configuration::projectDir() . 'src/includes/setting.php';
$registry->set('conf', $conf);
$registry->set('setting', $setting);
$registry->set('https', PROTOCOL == 'https' ? true : false);
require_once \Codeception\Configuration::projectDir() . 'src/includes/permission.php';
$registry->set('groupPermisson', $groupPermisson);
require_once \Codeception\Configuration::projectDir() . 'src/includes/rewriterule.php';
require_once \Codeception\Configuration::projectDir() . 'src/includes/startup.php';
$this->registry = $registry;
$this->client = new \Codeception\Lib\Connector\LitpiConnectorHelper();
$this->client->setRegistry($this->registry);
}
示例3: pathToGlobalPageObject
protected function pathToGlobalPageObject($config, $class)
{
$path = $this->buildPath(Configuration::projectDir() . $config['paths']['tests'] . '/_pages/', $class);
$filename = $this->completeSuffix($class, 'Page');
$this->introduceAutoloader(Configuration::projectDir() . $config['paths']['tests'] . DIRECTORY_SEPARATOR . $config['settings']['bootstrap'], 'Page', '_pages');
return $path . $filename;
}
示例4: loadConfiguredGroupSettings
protected function loadConfiguredGroupSettings()
{
foreach ($this->configuredGroups as $group => $tests) {
$this->testsInGroups[$group] = [];
if (is_array($tests)) {
foreach ($tests as $test) {
$file = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $test);
$this->testsInGroups[$group][] = Configuration::projectDir() . $file;
}
} elseif (is_file(Configuration::projectDir() . $tests)) {
$handle = @fopen(Configuration::projectDir() . $tests, "r");
if ($handle) {
while (($test = fgets($handle, 4096)) !== false) {
// if the current line is blank then we need to move to the next line
// otherwise the current codeception directory becomes part of the group
// which causes every single test to run
if (trim($test) === '') {
continue;
}
$file = trim(Configuration::projectDir() . $test);
$file = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $file);
$this->testsInGroups[$group][] = $file;
}
fclose($handle);
}
}
}
}
示例5: _initialize
/**
* @inheritdoc
*/
public function _initialize()
{
// compute datbase info
$match = preg_match("/host=(.*);dbname=(.*)/", env("DB_DSN"), $matches);
if (!$match) {
return;
}
$host = $matches[1];
$name = $matches[2] . "_test";
$user = env("DB_USER");
$pass = env("DB_PASS");
// compute dump file
$dumpFile = $this->config['dump'] ?: "tests/_data/dump.sql";
$dumpFile = Configuration::projectDir() . $dumpFile;
if (!file_exists($dumpFile)) {
throw new ModuleException(__CLASS__, "Dump file does not exist [ {$dumpFile} ]");
}
// dump
$cmd = "mysql -h {$host} -u {$user} -p{$pass} {$name} < {$dumpFile}";
$start = microtime(true);
$output = shell_exec($cmd);
$end = microtime(true);
$diff = round(($end - $start) * 1000, 2);
// output debug info
$className = get_called_class();
codecept_debug("{$className} - Importing db [ {$name} ] [ {$diff} ms ]");
// check for error
if ($output) {
throw new ModuleException(__CLASS__, "Failed to import db [ {$cmd} ]");
}
}
示例6: _initialize
public function _initialize()
{
if ($this->config['dump'] && ($this->config['cleanup'] or $this->config['populate'])) {
if (!file_exists(Configuration::projectDir() . $this->config['dump'])) {
throw new \Codeception\Exception\ModuleConfig(__CLASS__, "\n File with dump doesn't exist.\n\n Please, check path for dump file: " . $this->config['dump']);
}
$this->dumpFile = Configuration::projectDir() . $this->config['dump'];
$this->isDumpFileEmpty = false;
$content = file_get_contents($this->dumpFile);
$content = trim(preg_replace('%/\\*(?:(?!\\*/).)*\\*/%s', "", $content));
if (!sizeof(explode("\n", $content))) {
$this->isDumpFileEmpty = true;
}
}
try {
$this->driver = MongoDbDriver::create($this->config['dsn'], $this->config['user'], $this->config['password']);
} catch (\MongoConnectionException $e) {
throw new \Codeception\Exception\Module(__CLASS__, $e->getMessage() . ' while creating Mongo connection');
}
// starting with loading dump
if ($this->config['populate']) {
$this->cleanup();
$this->loadDump();
$this->populated = true;
}
}
示例7: __construct
/**
* Constructor.
*
* @param ModuleContainer $container
* @param $config
*/
public function __construct(ModuleContainer $container, $config = null)
{
$this->config = array_merge(['bootstrap' => 'bootstrap.php', 'application_dir' => 'application', 'modules_dir' => 'modules', 'system_dir' => 'system', 'custom_config_reader' => null], (array) $config);
$projectDir = \Codeception\Configuration::projectDir();
if (!defined('EXT')) {
define('EXT', '.php');
}
if (!defined('DOCROOT')) {
define('DOCROOT', realpath($projectDir) . DIRECTORY_SEPARATOR);
}
if (!defined('APPPATH')) {
define('APPPATH', realpath(DOCROOT . $this->config['application_dir']) . DIRECTORY_SEPARATOR);
}
if (!defined('MODPATH')) {
define('MODPATH', realpath(DOCROOT . $this->config['modules_dir']) . DIRECTORY_SEPARATOR);
}
if (!defined('SYSPATH')) {
define('SYSPATH', realpath(DOCROOT . $this->config['system_dir']) . DIRECTORY_SEPARATOR);
}
if (!defined('KOHANA_START_TIME')) {
define('KOHANA_START_TIME', microtime(TRUE));
}
if (!defined('KOHANA_START_MEMORY')) {
define('KOHANA_START_MEMORY', memory_get_usage());
}
if (!defined('API_MODE')) {
define('API_MODE', true);
}
$this->config['bootstrap_file'] = APPPATH . $this->config['bootstrap'];
parent::__construct($container);
}
示例8: getBundleTransferSchemas
/**
* @return \Symfony\Component\Finder\Finder|\Symfony\Component\Finder\SplFileInfo[]
*/
private function getBundleTransferSchemas()
{
$testBundleSchemaDirectory = Configuration::projectDir() . DIRECTORY_SEPARATOR . 'src';
$finder = new Finder();
$finder->files()->in($testBundleSchemaDirectory)->name('*.transfer.xml');
return $finder;
}
示例9: _initialize
public function _initialize()
{
$cwd = getcwd();
chdir(Configuration::projectDir());
$this->container = (require Configuration::projectDir() . $this->config['container']);
chdir($cwd);
$this->application = $this->container->get('Zend\\Expressive\\Application');
$this->initResponseCollector();
}
示例10: _before
public function _before(\Codeception\TestCase $test)
{
$this->client = new \Codeception\Lib\Connector\Yii2();
$this->client->configFile = \Codeception\Configuration::projectDir() . $this->config['configFile'];
$this->app = $this->client->startApp();
if ($this->config['cleanup'] and isset($this->app->db)) {
$this->transaction = $this->app->db->beginTransaction();
}
}
示例11: _initialize
public function _initialize()
{
require Configuration::projectDir() . 'init_autoloader.php';
$this->applicationConfig = (require Configuration::projectDir() . $this->config['config']);
if (isset($applicationConfig['module_listener_options']['config_cache_enabled'])) {
$applicationConfig['module_listener_options']['config_cache_enabled'] = false;
}
Console::overrideIsConsole(false);
}
示例12: __construct
/**
* Constructor.
*
* @param ModuleContainer $container
* @param null $config
*/
public function __construct(ModuleContainer $container, $config = null)
{
$this->config = array_merge(['cleanup' => true, 'unit' => true, 'environment' => 'testing', 'start' => 'bootstrap' . DIRECTORY_SEPARATOR . 'start.php', 'root' => '', 'filters' => false], (array) $config);
$projectDir = explode('workbench', Configuration::projectDir())[0];
$projectDir .= $this->config['root'];
$this->config['project_dir'] = $projectDir;
$this->config['start_file'] = $projectDir . $this->config['start'];
parent::__construct($container, null);
}
示例13: __construct
/**
* Constructor.
*
* @param ModuleContainer $container
* @param array|null $config
*/
public function __construct(ModuleContainer $container, $config = null)
{
$this->config = array_merge(['cleanup' => true, 'environment_file' => '.env', 'bootstrap' => 'bootstrap' . DIRECTORY_SEPARATOR . 'app.php', 'root' => '', 'packages' => 'workbench', 'disable_middleware' => false, 'disable_events' => false], (array) $config);
$projectDir = explode($this->config['packages'], \Codeception\Configuration::projectDir())[0];
$projectDir .= $this->config['root'];
$this->config['project_dir'] = $projectDir;
$this->config['bootstrap_file'] = $projectDir . $this->config['bootstrap'];
parent::__construct($container);
}
示例14: __construct
/**
* Constructor.
*
* @param $config
*/
public function __construct($config = null)
{
$this->config = array_merge(array('cleanup' => true, 'environment_file' => '.env', 'bootstrap' => 'bootstrap' . DIRECTORY_SEPARATOR . 'app.php', 'root' => '', 'packages' => 'workbench'), (array) $config);
$projectDir = explode($this->config['packages'], \Codeception\Configuration::projectDir())[0];
$projectDir .= $this->config['root'];
$this->config['project_dir'] = $projectDir;
$this->config['bootstrap_file'] = $projectDir . $this->config['bootstrap'];
parent::__construct();
}
示例15: _before
public function _before(TestCase $test)
{
$index = \Codeception\Configuration::projectDir() . $this->config['index'];
$this->client = new UniversalRunkitConnector();
$this->client->setIndex($index);
$this->client->setEnvModifier(function ($sandbox) use($index) {
$sandbox->eval('function is_cli() { return false; }');
$sandbox->chdir(dirname($index));
});
}