本文整理汇总了PHP中Codeception\Configuration::testsDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::testsDir方法的具体用法?PHP Configuration::testsDir怎么用?PHP Configuration::testsDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codeception\Configuration
的用法示例。
在下文中一共展示了Configuration::testsDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$suite = lcfirst($input->getArgument('suite'));
$actor = $input->getArgument('actor');
if ($this->containsInvalidCharacters($suite)) {
$output->writeln("<error>Suite name '{$suite}' contains invalid characters. ([A-Za-z0-9_]).</error>");
return;
}
$config = \Codeception\Configuration::config($input->getOption('config'));
if (!$actor) {
$actor = ucfirst($suite) . $config['actor'];
}
$config['class_name'] = $actor;
$dir = \Codeception\Configuration::testsDir();
if (file_exists($dir . $suite . '.suite.yml')) {
throw new \Exception("Suite configuration file '{$suite}.suite.yml' already exists.");
}
$this->buildPath($dir . $suite . DIRECTORY_SEPARATOR, $config['settings']['bootstrap']);
// generate bootstrap
$this->save($dir . $suite . DIRECTORY_SEPARATOR . $config['settings']['bootstrap'], "<?php\n// Here you can initialize variables that will be available to your tests\n", true);
$actorName = $this->removeSuffix($actor, $config['actor']);
$file = $this->buildPath(\Codeception\Configuration::supportDir() . "Helper", "{$actorName}.php") . "{$actorName}.php";
$gen = new Helper($actorName, $config['namespace']);
// generate helper
$this->save($file, $gen->produce());
$conf = <<<EOF
class_name: {{actor}}
modules:
enabled:
- {{helper}}
EOF;
$this->save($dir . $suite . '.suite.yml', (new Template($conf))->place('actor', $actorName . $config['actor'])->place('helper', $gen->getHelperName())->produce());
$output->writeln("<info>Suite {$suite} generated</info>");
}
示例2: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$suite = ucfirst($input->getArgument('suite'));
$actor = $input->getArgument('actor');
if ($this->containsInvalidCharacters($suite)) {
$output->writeln("<error>Suite name '{$suite}' contains invalid characters. ([A-Za-z0-9_]).</error>");
return;
}
$config = \Codeception\Configuration::config($input->getOption('config'));
if (!$actor) {
$actor = $suite . $config['actor'];
}
$config['class_name'] = $actor;
$dir = \Codeception\Configuration::testsDir();
if (file_exists($dir . $suite . '.suite.yml')) {
throw new \Exception("Suite configuration file '{$suite}.suite.yml' already exists.");
}
$this->buildPath($dir . $suite . DIRECTORY_SEPARATOR, 'bootstrap.php');
// generate bootstrap
$this->save($dir . $suite . DIRECTORY_SEPARATOR . 'bootstrap.php', "<?php\n// Here you can initialize variables that will be available to your tests\n", true);
$actorName = $this->removeSuffix($actor, $config['actor']);
// generate helper
$this->save(\Codeception\Configuration::helpersDir() . $actorName . 'Helper.php', (new Helper($actorName, $config['namespace']))->produce());
$enabledModules = ['Cake\\Codeception\\Helper', 'App\\TestSuite\\Codeception\\' . $actorName . 'Helper'];
if ('Unit' === $suite) {
array_shift($enabledModules);
}
$conf = ['class_name' => $actorName . $config['actor'], 'modules' => ['enabled' => $enabledModules]];
$this->save($dir . $suite . '.suite.yml', Yaml::dump($conf, 2));
$output->writeln("<info>Suite {$suite} generated</info>");
}
示例3: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$suite = lcfirst($input->getArgument('suite'));
$actor = $input->getArgument('actor');
$config = \Codeception\Configuration::config($input->getOption('config'));
if (!$actor) {
$actor = ucfirst($suite) . $config['actor'];
}
$config['class_name'] = $actor;
$dir = \Codeception\Configuration::testsDir();
if (file_exists($dir . $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.");
}
$this->buildPath($dir . $suite . DIRECTORY_SEPARATOR, '_bootstrap.php');
// generate bootstrap
$this->save($dir . $suite . DIRECTORY_SEPARATOR . '_bootstrap.php',
"<?php\n// Here you can initialize variables that will for your tests\n",
true
);
$actorName = $this->removeSuffix($actor, $config['actor']);
// generate helper
$this->save(
\Codeception\Configuration::helpersDir() . $actorName . 'Helper.php',
(new Helper($actorName, $config['namespace']))->produce()
);
$conf = array(
'class_name' => $actorName.$config['actor'],
'modules' => array(
'enabled' => array($actorName . 'Helper')
),
);
$this->save($dir . $suite . '.suite.yml', Yaml::dump($conf, 2));
$output->writeln("<info>Suite $suite generated</info>");
}
示例4: getTestsDir
public function getTestsDir()
{
return Config::testsDir();
}