当前位置: 首页>>代码示例>>PHP>>正文


PHP Configuration::config方法代码示例

本文整理汇总了PHP中Codeception\Configuration::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::config方法的具体用法?PHP Configuration::config怎么用?PHP Configuration::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Codeception\Configuration的用法示例。


在下文中一共展示了Configuration::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($options)
 {
     $this->options = $options;
     $this->logDir = Configuration::outputDir();
     $this->settings = array_merge($this->settings, Configuration::config()['coverage']);
     self::$coverage = new \PHP_CodeCoverage();
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:7,代码来源:Printer.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $config = \Codeception\Configuration::config();
     $suiteconf = \Codeception\Configuration::suiteSettings($suite, $config);
     @mkdir($path = \Codeception\Configuration::dataDir() . 'scenarios');
     @mkdir($path = $path . DIRECTORY_SEPARATOR . $suite);
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $suiteManager = new \Codeception\SuiteManager($dispatcher, $suite, $suiteconf);
     if (isset($suiteconf['bootstrap'])) {
         if (file_exists($suiteconf['path'] . $suiteconf['bootstrap'])) {
             require_once $suiteconf['path'] . $suiteconf['bootstrap'];
         }
     }
     $suiteManager->loadTests();
     $tests = $suiteManager->getSuite()->tests();
     foreach ($tests as $test) {
         if (!$test instanceof \Codeception\TestCase\Cept) {
             continue;
         }
         $test->loadScenario();
         $features = $test->getScenarioText();
         $name = $this->underscore(substr($test->getFileName(), 0, -8));
         $output->writeln("* {$name} generated");
         file_put_contents($path . DIRECTORY_SEPARATOR . $name . '.txt', $features);
     }
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:27,代码来源:GenerateScenarios.php

示例3: __construct

 public function __construct()
 {
     $this->config  = Configuration::config();
     $this->logDir = Configuration::outputDir(); // prepare log dir
     $this->phpUnitOverriders();
     parent::__construct();
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:7,代码来源:Runner.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = \Codeception\Configuration::config();
     $suites = \Codeception\Configuration::suites();
     foreach ($suites as $suite) {
         $settings = \Codeception\Configuration::suiteSettings($suite, $config);
         $modules = \Codeception\Configuration::modules($settings);
         $phpdoc = array();
         $methodCounter = 0;
         foreach ($modules as $modulename => $module) {
             $class = new \ReflectionClass('\\Codeception\\Module\\' . $modulename);
             $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC);
             $phpdoc[] = '';
             $phpdoc[] = 'Methods from ' . $modulename;
             foreach ($methods as $method) {
                 if (strpos($method->name, '_') === 0) {
                     continue;
                 }
                 $params = array();
                 foreach ($method->getParameters() as $param) {
                     if ($param->isOptional()) {
                         continue;
                     }
                     $params[] = '$' . $param->name;
                 }
                 $params = implode(', ', $params);
                 $phpdoc[] = '@method ' . $settings['class_name'] . ' ' . $method->name . '(' . $params . ')';
                 $methodCounter++;
             }
         }
         $contents = sprintf($this->template, implode("\r\n * ", $phpdoc), 'class', $settings['class_name'], '\\Codeception\\AbstractGuy');
         file_put_contents($file = $settings['path'] . $settings['class_name'] . '.php', $contents);
         $output->writeln("{$file} generated sucessfully. {$methodCounter} methods added");
     }
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:35,代码来源:Build.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $output->writeln('Warning: this command may affect your Helper classes');
     $config = Configuration::config($input->getOption('config'));
     $suiteconf = Configuration::suiteSettings($suite, $config);
     $dispatcher = new EventDispatcher();
     $suiteManager = new SuiteManager($dispatcher, $suite, $suiteconf);
     if (isset($suiteconf['bootstrap'])) {
         if (file_exists($suiteconf['path'] . $suiteconf['bootstrap'])) {
             require_once $suiteconf['path'] . $suiteconf['bootstrap'];
         }
     }
     $suiteManager->loadTests();
     $tests = $suiteManager->getSuite()->tests();
     $dialog = $this->getHelperSet()->get('dialog');
     $helper = $this->matchHelper();
     if (!$helper) {
         $output->writeln("<error>No helpers for suite {$suite} is defined. Can't append new methods</error>");
         return;
     }
     if (!file_exists($helper_file = Configuration::helpersDir() . $helper . '.php')) {
         $output->writeln("<error>Helper class {$helper}.php doesn't exist</error>");
         return;
     }
     $replaced = 0;
     $analyzed = 0;
     foreach ($tests as $test) {
         if (!$test instanceof Cept) {
             continue;
         }
         $analyzed++;
         $test->testCodecept(false);
         $scenario = $test->getScenario();
         foreach ($scenario->getSteps() as $step) {
             if ($step->getName() == 'Comment') {
                 continue;
             }
             $action = $step->getAction();
             if (isset(SuiteManager::$actions[$action])) {
                 continue;
             }
             if (!$dialog->askConfirmation($output, "<question>\nAction '{$action}' is missing. Do you want to add it to helper class?\n</question>\n", false)) {
                 continue;
             }
             $example = sprintf('$I->%s(%s);', $action, $step->getArguments(true));
             $args = array_map(function ($a) {
                 return '$arg' . $a;
             }, range(1, count($step->getArguments())));
             $stub = sprintf($this->methodTemplate, $example, $action, implode(', ', $args));
             $contents = file_get_contents($helper_file);
             $contents = preg_replace('~}(?!.*})~ism', $stub, $contents);
             $this->save($helper_file, $contents, true);
             $output->writeln("Action '{$action}' added to helper {$helper}");
             $replaced++;
         }
     }
     $output->writeln("<info>Analysis finished. {$analyzed} tests analyzed. {$replaced} methods added</info>");
     $output->writeln("Run the 'build' command to finish");
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:60,代码来源:Analyze.php

示例6: 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>");
 }
开发者ID:cakephp,项目名称:codeception,代码行数:31,代码来源:GenerateSuite.php

示例7: 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>");
 }
开发者ID:pfz,项目名称:codeception,代码行数:25,代码来源:GenerateSuite.php

示例8: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suiteName = $input->getArgument('suite');
     $this->output = $output;
     $config = Configuration::config($input->getOption('config'));
     $settings = Configuration::suiteSettings($suiteName, $config);
     $options = $input->getOptions();
     $options['debug'] = true;
     $options['steps'] = true;
     $this->codecept = new Codecept($options);
     $dispatcher = $this->codecept->getDispatcher();
     $this->test = (new Cept())->configDispatcher($dispatcher)->configName('interactive')->config('file', 'interactive')->initConfig();
     $suiteManager = new SuiteManager($dispatcher, $suiteName, $settings);
     $suiteManager->initialize();
     $this->suite = $suiteManager->getSuite();
     $scenario = new Scenario($this->test);
     $actor = $settings['class_name'];
     $I = new $actor($scenario);
     $this->listenToSignals();
     $output->writeln("<info>Interactive console started for suite {$suiteName}</info>");
     $output->writeln("<info>Try Codeception commands without writing a test</info>");
     $output->writeln("<info>type 'exit' to leave console</info>");
     $output->writeln("<info>type 'actions' to see all available actions for this suite</info>");
     $suiteEvent = new SuiteEvent($this->suite, $this->codecept->getResult(), $settings);
     $dispatcher->dispatch(Events::SUITE_BEFORE, $suiteEvent);
     $dispatcher->dispatch(Events::TEST_PARSED, new TestEvent($this->test));
     $dispatcher->dispatch(Events::TEST_BEFORE, new TestEvent($this->test));
     $output->writeln("\n\n\$I = new {$settings['class_name']}(\$scenario);");
     $scenario->run();
     $this->executeCommands($output, $I, $settings['bootstrap']);
     $dispatcher->dispatch(Events::TEST_AFTER, new TestEvent($this->test));
     $dispatcher->dispatch(Events::SUITE_AFTER, new SuiteEvent($this->suite));
     $output->writeln("<info>Bye-bye!</info>");
 }
开发者ID:Eli-TW,项目名称:Codeception,代码行数:34,代码来源:Console.php

示例9: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $filename = $input->getArgument('test');
     $config = \Codeception\Configuration::config();
     $suiteconf = \Codeception\Configuration::suiteSettings($suite, $config);
     $guy = $suiteconf['class_name'];
     $file = sprintf($this->template, $guy);
     if (file_exists($suiteconf['path'] . DIRECTORY_SEPARATOR . $filename)) {
         $output->writeln("<comment>Test {$filename} already exists</comment>");
         return;
     }
     if (strpos(strrev($filename), strrev('Cept')) === 0) {
         $filename .= '.php';
     }
     if (strpos(strrev($filename), strrev('Cept.php')) !== 0) {
         $filename .= 'Cept.php';
     }
     if (strpos(strrev($filename), strrev('.php')) !== 0) {
         $filename .= '.php';
     }
     $filename = str_replace('\\', '/', $filename);
     $dirs = explode('/', $filename);
     array_pop($dirs);
     $path = $suiteconf['path'] . DIRECTORY_SEPARATOR;
     foreach ($dirs as $dir) {
         $path .= $dir . DIRECTORY_SEPARATOR;
         @mkdir($path);
     }
     file_put_contents($suiteconf['path'] . DIRECTORY_SEPARATOR . $filename, $file);
     $output->writeln("<info>Test was generated in {$filename}</info>");
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:32,代码来源:GenerateCept.php

示例10: __construct

 public function __construct()
 {
     $this->config = Configuration::config();
     $this->log_dir = Configuration::logDir();
     // prepare log dir
     parent::__construct();
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:7,代码来源:Runner.php

示例11: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suiteName = $input->getArgument('suite');
     $this->output = $output;
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $settings = \Codeception\Configuration::suiteSettings($suiteName, $config);
     $options = $input->getOptions();
     $options['debug'] = true;
     $options['steps'] = true;
     $this->codecept = new \Codeception\Codecept($options);
     $dispatcher = $this->codecept->getDispatcher();
     $suiteManager = new SuiteManager($dispatcher, $suiteName, $settings);
     $this->suite = $suiteManager->getSuite();
     $this->test = new Cept($dispatcher, array('name' => 'interactive', 'file' => 'interactive'));
     $guy = $settings['class_name'];
     $scenario = new Scenario($this->test);
     $I = new $guy($scenario);
     $this->listenToSignals();
     $output->writeln("<info>Interactive console started for suite {$suiteName}</info>");
     $output->writeln("<info>Try Codeception commands without writing a test</info>");
     $output->writeln("<info>type 'exit' to leave console</info>");
     $output->writeln("<info>type 'actions' to see all available actions for this suite</info>");
     $dispatcher->dispatch('suite.before', new Suite($this->suite, $this->codecept->getResult(), $settings));
     $dispatcher->dispatch('test.parsed', new \Codeception\Event\Test($this->test));
     $dispatcher->dispatch('test.before', new \Codeception\Event\Test($this->test));
     $output->writeln("\n\n\$I = new {$settings['class_name']}(\$scenario);");
     $scenario->run();
     $this->executeCommands($output, $I, $settings['bootstrap']);
     $dispatcher->dispatch('test.after', new \Codeception\Event\Test($this->test));
     $dispatcher->dispatch('suite.after', new Suite($this->suite));
     $output->writeln("<info>Bye-bye!</info>");
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:32,代码来源:Console.php

示例12: buildActorsForConfig

 protected function buildActorsForConfig($configFile)
 {
     $config = $this->getGlobalConfig($configFile);
     $suites = $this->getSuites($configFile);
     $path = pathinfo($configFile);
     $dir = isset($path['dirname']) ? $path['dirname'] : getcwd();
     foreach ($config['include'] as $subConfig) {
         $this->output->writeln("<comment>Included Configuration: {$subConfig}</comment>");
         $this->buildActorsForConfig($dir . DIRECTORY_SEPARATOR . $subConfig);
     }
     if (!empty($suites)) {
         $this->output->writeln("<info>Building Actor classes for suites: " . implode(', ', $suites) . '</info>');
     }
     foreach ($suites as $suite) {
         $settings = $this->getSuiteConfig($suite, $configFile);
         $actionsGenerator = new ActionsGenerator($settings);
         $contents = $actionsGenerator->produce();
         $actorGenerator = new ActorGenerator($settings);
         $file = $this->buildPath(Configuration::supportDir() . '_generated', $settings['class_name']) . $this->getClassName($settings['class_name']) . 'Actions.php';
         $this->save($file, $contents, true);
         $this->output->writeln('<info>' . Configuration::config()['namespace'] . '\\' . $actorGenerator->getActorName() . "</info> includes modules: " . implode(', ', $actorGenerator->getModules()));
         $this->output->writeln(" -> {$settings['class_name']}Actions.php generated successfully. " . $actionsGenerator->getNumMethods() . " methods added");
         $contents = $actorGenerator->produce();
         $file = $this->buildPath(Configuration::supportDir(), $settings['class_name']) . $this->getClassName($settings['class_name']) . '.php';
         if ($this->save($file, $contents)) {
             $this->output->writeln("{$settings['class_name']}.php created.");
         }
     }
 }
开发者ID:namnv609,项目名称:Codeception,代码行数:29,代码来源:Build.php

示例13: 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>");
    }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:34,代码来源:GenerateSuite.php

示例14: currentNamespace

 protected function currentNamespace()
 {
     $config = Configuration::config();
     if (!$config['namespace']) {
         throw new \RuntimeException("Can't include into runner suite without a namespace;\nUse 'refactor:add-namespace' command to fix it'");
     }
     return $config['namespace'];
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:8,代码来源:Run.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $host = $input->getOption('host');
     $user = $input->getOption('user');
     $pass = $input->getOption('pass');
     $dbName = $input->getArgument('name');
     try {
         $this->dump = $this->pdoFactory->makeDump($host, $user, $pass, $dbName);
     } catch (\PDOException $e) {
         throw new RuntimeException('Error while connecting to database [' . $dbName . ']: ' . $e->getMessage());
     }
     if (false === $this->dump) {
         $output->writeln('<error>Something went wrong with the dump component instance.</error>');
         return false;
     }
     \Codeception\Configuration::config();
     if (!empty($input->getOption('dump-file'))) {
         $dumpFile = $input->getOption('dump-file');
     } else {
         $dumpFile = codecept_data_dir($input->getArgument('snapshot') . '.sql');
     }
     $output->writeln('<info>Dump file will be written to [' . $dumpFile . ']</info>');
     if (!empty($input->getOption('dist-dump-file'))) {
         $distDumpFile = $input->getOption('dist-dump-file');
     } else {
         $distDumpFile = codecept_data_dir($input->getArgument('snapshot') . '.dist.sql');
     }
     $output->writeln('<info>Distribution version of dump file will be written to [' . $distDumpFile . ']</info>');
     $skipTables = $input->getOption('skip-tables');
     if (!empty($skipTables)) {
         $tables = explode(',', $skipTables);
         foreach ($tables as $table) {
             $this->dump->tables[$table] = \MySQLDump::NONE;
         }
     }
     $memory = fopen('php://memory', 'w');
     $this->dump->write($memory);
     rewind($memory);
     $dumpContents = stream_get_contents($memory);
     if (!$this->filesystem->file_put_contents($dumpFile, $dumpContents)) {
         $output->writeln('<error>Could not write dump to [' . $dumpFile . ']</error>');
         return false;
     }
     $output->writeln('<info>Dump file written to [' . $dumpFile . ']</info>');
     $localUrl = $input->getOption('local-url');
     $distUrl = $input->getOption('dist-url');
     $localDomain = rtrim(preg_replace('~http(s)*:\\/\\/(www\\.)*~', '', $localUrl), '/');
     $distDomain = rtrim(preg_replace('~http(s)*:\\/\\/(www\\.)*~', '', $distUrl), '/');
     $distDumpContents = str_replace($localDomain, $distDomain, $dumpContents);
     if (!$this->filesystem->file_put_contents($distDumpFile, $distDumpContents)) {
         $output->writeln('<error>Could not write dist dump to [' . $distDumpFile . ']</error>');
         return false;
     }
     $output->writeln('<info>Distribution version of dump file written to [' . $distDumpFile . ']</info>');
     $output->writeln('<comment>Any occurrence of [' . $localDomain . '] in it was replaced with [' . $distDomain . ']</comment>');
     parent::execute($input, $output);
     return true;
 }
开发者ID:lucatume,项目名称:wp-browser,代码行数:58,代码来源:DbSnapshot.php


注:本文中的Codeception\Configuration::config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。