init
This commit is contained in:
66
vendor/codeception/base/src/Codeception/Command/Shared/Config.php
vendored
Normal file
66
vendor/codeception/base/src/Codeception/Command/Shared/Config.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace Codeception\Command\Shared;
|
||||
|
||||
use Codeception\Configuration;
|
||||
use Symfony\Component\Console\Exception\InvalidOptionException;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
trait Config
|
||||
{
|
||||
protected function getSuiteConfig($suite)
|
||||
{
|
||||
return Configuration::suiteSettings($suite, $this->getGlobalConfig());
|
||||
}
|
||||
|
||||
protected function getGlobalConfig($conf = null)
|
||||
{
|
||||
return Configuration::config($conf);
|
||||
}
|
||||
|
||||
protected function getSuites($conf = null)
|
||||
{
|
||||
return Configuration::suites();
|
||||
}
|
||||
|
||||
protected function overrideConfig($configOptions)
|
||||
{
|
||||
$updatedConfig = [];
|
||||
foreach ($configOptions as $option) {
|
||||
$keys = explode(': ', $option);
|
||||
if (count($keys) < 2) {
|
||||
throw new \InvalidArgumentException('--config-option should have config passed as "key:value"');
|
||||
}
|
||||
$value = array_pop($keys);
|
||||
$yaml = '';
|
||||
for ($ind = 0; count($keys); $ind += 2) {
|
||||
$yaml .= "\n" . str_repeat(' ', $ind) . array_shift($keys) . ': ';
|
||||
}
|
||||
$yaml .= $value;
|
||||
try {
|
||||
$config = Yaml::parse($yaml);
|
||||
} catch (ParseException $e) {
|
||||
throw new \Codeception\Exception\ParseException("Overridden config can't be parsed: \n$yaml\n" . $e->getParsedLine());
|
||||
}
|
||||
$updatedConfig = array_merge_recursive($updatedConfig, $config);
|
||||
}
|
||||
return Configuration::append($updatedConfig);
|
||||
}
|
||||
|
||||
protected function enableExtensions($extensions)
|
||||
{
|
||||
$config = ['extensions' => ['enabled' => []]];
|
||||
foreach ($extensions as $name) {
|
||||
if (!class_exists($name)) {
|
||||
$className = 'Codeception\\Extension\\' . ucfirst($name);
|
||||
if (!class_exists($className)) {
|
||||
throw new InvalidOptionException("Extension $name can't be loaded (tried by $name and $className)");
|
||||
}
|
||||
$config['extensions']['enabled'][] = $className;
|
||||
continue;
|
||||
}
|
||||
$config['extensions']['enabled'][] = $name;
|
||||
}
|
||||
return Configuration::append($config);
|
||||
}
|
||||
}
|
||||
54
vendor/codeception/base/src/Codeception/Command/Shared/FileSystem.php
vendored
Normal file
54
vendor/codeception/base/src/Codeception/Command/Shared/FileSystem.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace Codeception\Command\Shared;
|
||||
|
||||
use Codeception\Util\Shared\Namespaces;
|
||||
|
||||
trait FileSystem
|
||||
{
|
||||
use Namespaces;
|
||||
|
||||
protected function createDirectoryFor($basePath, $className = '')
|
||||
{
|
||||
$basePath = rtrim($basePath, DIRECTORY_SEPARATOR);
|
||||
if ($className) {
|
||||
$className = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $className);
|
||||
$path = $basePath . DIRECTORY_SEPARATOR . $className;
|
||||
$basePath = pathinfo($path, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
if (!file_exists($basePath)) {
|
||||
// Second argument should be mode. Well, umask() doesn't seem to return any if not set. Config may fix this.
|
||||
mkdir($basePath, 0775, true); // Third parameter commands to create directories recursively
|
||||
}
|
||||
return $basePath;
|
||||
}
|
||||
|
||||
protected function completeSuffix($filename, $suffix)
|
||||
{
|
||||
if (strpos(strrev($filename), strrev($suffix)) === 0) {
|
||||
$filename .= '.php';
|
||||
}
|
||||
if (strpos(strrev($filename), strrev($suffix . '.php')) !== 0) {
|
||||
$filename .= $suffix . '.php';
|
||||
}
|
||||
if (strpos(strrev($filename), strrev('.php')) !== 0) {
|
||||
$filename .= '.php';
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
protected function removeSuffix($classname, $suffix)
|
||||
{
|
||||
$classname = preg_replace('~\.php$~', '', $classname);
|
||||
return preg_replace("~$suffix$~", '', $classname);
|
||||
}
|
||||
|
||||
protected function createFile($filename, $contents, $force = false, $flags = null)
|
||||
{
|
||||
if (file_exists($filename) && !$force) {
|
||||
return false;
|
||||
}
|
||||
file_put_contents($filename, $contents, $flags);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
16
vendor/codeception/base/src/Codeception/Command/Shared/Style.php
vendored
Normal file
16
vendor/codeception/base/src/Codeception/Command/Shared/Style.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Codeception\Command\Shared;
|
||||
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
trait Style
|
||||
{
|
||||
public function addStyles(OutputInterface $output)
|
||||
{
|
||||
$output->getFormatter()->setStyle('notice', new OutputFormatterStyle('white', 'green', ['bold']));
|
||||
$output->getFormatter()->setStyle('bold', new OutputFormatterStyle(null, null, ['bold']));
|
||||
$output->getFormatter()->setStyle('warning', new OutputFormatterStyle(null, 'yellow', ['bold']));
|
||||
$output->getFormatter()->setStyle('debug', new OutputFormatterStyle('cyan'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user