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


PHP Configuration::suiteSettings方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: runSuite

 public function runSuite($suite, $test = null)
 {
     $settings = \Codeception\Configuration::suiteSettings($suite, $this->config);
     $suiteManager = new \Codeception\SuiteManager($this->dispatcher, $suite, $settings);
     $test ? $suiteManager->loadTest($settings['path'] . $test) : $suiteManager->loadTests();
     $this->runner = $suiteManager->run($this->result, $this->options);
     return $this->result;
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:8,代码来源:Codecept.php

示例8: __construct

 public function __construct()
 {
     //grab the global config file
     $config = Configuration::config();
     //get  the unit settings
     $settings = Configuration::suiteSettings("unit", $config);
     //get the settings for the db module
     $dbConfig = (isset($settings['modules']['config']['Db'])) ? $settings['modules']['config']['Db'] : array();
     //set the config for the helper module
     $this->_setConfig($dbConfig);
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:11,代码来源:DbHelper.php

示例9: runSuite

 public function runSuite($suite, $test = null)
 {
     $settings = Configuration::suiteSettings($suite, $this->config);
     $suiteManager = new SuiteManager($this->dispatcher, $suite, $settings);
     $test ? $suiteManager->loadTest($settings['path'] . $test) : $suiteManager->loadTests();
     if (!$this->runner->getPrinter()) {
         $printer = new PHPUnit\ResultPrinter\UI($this->dispatcher, $this->options);
         $this->runner->setPrinter($printer);
     }
     $suiteManager->run($this->runner, $this->result, $this->options);
     return $this->result;
 }
开发者ID:pfz,项目名称:codeception,代码行数:12,代码来源:Codecept.php

示例10: execute

 protected function execute($args = [], $isSuite = true)
 {
     $app = new Application();
     $app->add($this->command);
     $default = \Codeception\Configuration::$defaultConfig;
     $default['paths']['tests'] = __DIR__;
     $conf = $isSuite ? \Codeception\Configuration::suiteSettings('unit', $default) : $default;
     $this->config = array_merge($conf, $this->config);
     $commandTester = new CommandTester($app->find($this->commandName));
     $args['command'] = $this->commandName;
     $commandTester->execute($args, ['interactive' => false]);
     $this->output = $commandTester->getDisplay();
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:13,代码来源:BaseCommandRunner.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $suiteconf = \Codeception\Configuration::suiteSettings($suite, $config);
     if ($input->getOption('path')) {
         $path = $input->getOption('path');
     } else {
         $path = \Codeception\Configuration::dataDir() . 'scenarios';
     }
     @mkdir($path);
     if (!is_writable($path)) {
         throw new \Codeception\Exception\Configuration("Path for logs is not writable. Please, set appropriate access mode for log path.");
     }
     $path = $path . DIRECTORY_SEPARATOR . $suite;
     if ($input->getOption('single-file')) {
         file_put_contents($path . '.txt', '');
     } else {
         @mkdir($path);
     }
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $suiteManager = new \Codeception\SuiteManager($dispatcher, $suite, $suiteconf);
     if ($suiteconf['bootstrap']) {
         if (file_exists($suiteconf['path'] . $suiteconf['bootstrap'])) {
             require_once $suiteconf['path'] . $suiteconf['bootstrap'];
         }
     }
     $suiteManager->loadTests();
     $tests = $suiteManager->getSuite()->tests();
     if ($input->getOption('format')) {
         $format = $input->getOption('format');
     } else {
         $format = 'text';
     }
     foreach ($tests as $test) {
         if (!$test instanceof \Codeception\TestCase\Cept) {
             continue;
         }
         $test->preload();
         $features = $test->getScenarioText($format);
         $name = $this->underscore(substr($test->getFileName(), 0, -8));
         if ($input->getOption('single-file')) {
             file_put_contents($path . '.txt', $features . PHP_EOL, FILE_APPEND);
             $output->writeln("* {$name} rendered");
         } else {
             file_put_contents($path . DIRECTORY_SEPARATOR . $name . '.txt', $features);
             $output->writeln("* {$name} generated");
         }
     }
 }
开发者ID:pfz,项目名称:codeception,代码行数:50,代码来源:GenerateScenarios.php

示例12: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $class = $input->getArgument('class');
     $config = \Codeception\Configuration::config();
     $suiteconf = \Codeception\Configuration::suiteSettings($suite, $config);
     $guy = $suiteconf['class_name'];
     if (isset($suiteconf['bootstrap'])) {
         if (file_exists($suiteconf['path'] . $suiteconf['bootstrap'])) {
             require_once $suiteconf['path'] . $suiteconf['bootstrap'];
         } else {
             throw new \RuntimeException($suiteconf['path'] . $suiteconf['bootstrap'] . " couldn't be loaded");
         }
     }
     if (!class_exists($class, true)) {
         throw new \Exception("Class {$class} is not loaded. Please, add autoloader to suite bootstrap");
     }
     $namespaces = explode('\\', $class);
     $classname = array_pop($namespaces);
     $use = '';
     $path = $suiteconf['path'];
     foreach ($namespaces as $namespace) {
         $path .= DIRECTORY_SEPARATOR . $namespace;
         @mkdir($path);
     }
     if (!empty($namespaces)) {
         $use = 'namespace ' . implode('\\', $namespaces) . ";\n";
     }
     $reflected = new \ReflectionClass($class);
     $filename = $path . DIRECTORY_SEPARATOR . $classname . 'Cest.php';
     if (file_exists($filename)) {
         $output->writeln("<error>Test {$filename} already exists</error>");
         exit;
     }
     $tests = array();
     $methods = $reflected->getMethods(\ReflectionMethod::IS_PUBLIC);
     foreach ($methods as $method) {
         if ($method->getDeclaringClass()->name != $class) {
             continue;
         }
         if ($method->isConstructor() or $method->isDestructor()) {
             continue;
         }
         $tests[] = sprintf($this->methodTemplate, $classname, $method->name, $method->name, $guy, '$I');
     }
     $tests = implode("\n\n", $tests);
     file_put_contents($filename, sprintf($this->template, $use, 'class', $classname, '$class', $class, $tests));
     $output->writeln("<info>Cest for {$class} was created in {$filename}</info>");
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:49,代码来源:GenerateCest.php

示例13: __construct

    public function __construct()
    {
        //grab the global config file
        $config = Configuration::config();
        //get  the unit settings
        $settings = Configuration::suiteSettings("import", $config);
        //get the settings for the db module
        $dbConfig = (isset($settings['modules']['config']['Db'])) ? $settings['modules']['config']['Db'] : array();
        $dbConfig['user'] = $_ENV['db_user'];
        $dbConfig['password'] = $_ENV['db_password'];
        $this->_reconfigure($dbConfig);

        //$this->_setConfig($dbConfig);
        //$this->_initialize();
    }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:15,代码来源:Db.php

示例14: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $filename = $input->getArgument('test');
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $suiteconf = \Codeception\Configuration::suiteSettings($suite, $config);
     $guy = $suiteconf['class_name'];
     $file = sprintf($this->template, $guy);
     $filename = $this->completeSuffix($filename, 'Cept');
     $this->buildPath($suiteconf['path'], $filename);
     $res = $this->save($suiteconf['path'] . DIRECTORY_SEPARATOR . $filename, $file);
     if (!$res) {
         $output->writeln("<error>Test {$filename} already exists</error>");
         exit;
     }
     $output->writeln("<info>Test was generated in {$filename}</info>");
 }
开发者ID:pfz,项目名称:codeception,代码行数:17,代码来源:GenerateCept.php

示例15: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $class = $input->getArgument('class');
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $suiteconf = \Codeception\Configuration::suiteSettings($suite, $config);
     $classname = $this->getClassName($class);
     $path = $this->buildPath($suiteconf['path'], $class);
     $ns = $this->getNamespaceString($class);
     $filename = $this->completeSuffix($classname, 'Test');
     $filename = $path . DIRECTORY_SEPARATOR . $filename;
     $res = $this->save($filename, sprintf($this->template, $ns, 'class', $classname));
     if (!$res) {
         $output->writeln("<error>Test {$filename} already exists</error>");
         exit;
     }
     $output->writeln("<info>Test for {$class} was created in {$filename}</info>");
 }
开发者ID:pfz,项目名称:codeception,代码行数:18,代码来源:GeneratePhpUnit.php


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