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


PHP Codeception\Configuration类代码示例

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


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

示例1: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $options = $input->getOptions();
     if ($input->getArgument('test')) {
         $options['steps'] = true;
     }
     $suite = $input->getArgument('suite');
     $test = $input->getArgument('test');
     $codecept = new \Codeception\Codecept((array) $options);
     $suites = $suite ? array($suite) : \Codeception\Configuration::suites();
     $output->writeln(\Codeception\Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString());
     if ($suite and $test) {
         $codecept->runSuite($suite, $test);
     }
     if (!$test) {
         foreach ($suites as $suite) {
             $codecept->runSuite($suite);
         }
     }
     $codecept->printResult();
     if (!$input->getOption('no-exit')) {
         if ($codecept->getResult()->failureCount() or $codecept->getResult()->errorCount()) {
             exit(1);
         }
     }
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:26,代码来源:Run.php

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

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $suites = $this->getSuites($input->getOption('config'));
     $output->writeln("<info>Building Guy classes for suites: " . implode(', ', $suites) . '</info>');
     foreach ($suites as $suite) {
         $settings = $this->getSuiteConfig($suite, $input->getOption('config'));
         $namespace = rtrim($settings['namespace'], '\\');
         $modules = \Codeception\Configuration::modules($settings);
         $code = array();
         $methodCounter = 0;
         $output->writeln('<info>' . $settings['class_name'] . "</info> includes modules: " . implode(', ', array_keys($modules)));
         $docblock = array();
         foreach ($modules as $module) {
             $docblock[] = "use " . get_class($module) . ";";
         }
         $methods = array();
         $actions = \Codeception\Configuration::actions($modules);
         foreach ($actions as $action => $moduleName) {
             if (in_array($action, $methods)) {
                 continue;
             }
             $module = $modules[$moduleName];
             $method = new \ReflectionMethod(get_class($module), $action);
             $code[] = $this->addMethod($method);
             $methods[] = $action;
             $methodCounter++;
         }
         $docblock = $this->prependAbstractGuyDocBlocks($docblock);
         $contents = sprintf($this->template, $namespace ? "namespace {$namespace};" : '', implode("\n", $docblock), 'class', $settings['class_name'], '\\Codeception\\AbstractGuy', implode("\n\n ", $code));
         $file = $settings['path'] . $this->getClassName($settings['class_name']) . '.php';
         $this->save($file, $contents, true);
         $output->writeln("{$settings['class_name']}.php generated successfully. {$methodCounter} methods added");
     }
 }
开发者ID:gargallo,项目名称:tfs-test,代码行数:34,代码来源:Build.php

示例4: updateActor

 public function updateActor(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     $modules = $e->getSuite()->getModules();
     $actorFile = Configuration::supportDir() . '_generated' . DIRECTORY_SEPARATOR . $settings['class_name'] . 'Actions.php';
     // load guy class to see hash
     $handle = @fopen($actorFile, "r");
     if ($handle and is_writable($actorFile)) {
         $line = @fgets($handle);
         if (preg_match('~\\[STAMP\\] ([a-f0-9]*)~', $line, $matches)) {
             $hash = $matches[1];
             $currentHash = Actions::genHash($modules, $settings);
             // regenerate guy class when hashes do not match
             if ($hash != $currentHash) {
                 codecept_debug("Rebuilding {$settings['class_name']}...");
                 $actionsGenerator = new Actions($settings);
                 @fclose($handle);
                 $generated = $actionsGenerator->produce();
                 @file_put_contents($actorFile, $generated);
                 return;
             }
         }
         @fclose($handle);
     }
 }
开发者ID:corcre,项目名称:elabftw,代码行数:25,代码来源:AutoRebuild.php

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

示例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');
     $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

示例8: _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);
 }
开发者ID:tuyenv,项目名称:litpi-framework-3,代码行数:31,代码来源:LitpiHelper.php

示例9: setUp

 public function setUp()
 {
     $this->dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
     $this->testcase = new \Codeception\TestCase\Cept();
     $this->testcase->configDispatcher($this->dispatcher)->configName('mocked test')->configFile(\Codeception\Configuration::dataDir() . 'SimpleCept.php')->initConfig();
     \Codeception\SuiteManager::$modules['EmulateModuleHelper']->assertions = 0;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:TestCaseTest.php

示例10: _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} ]");
     }
 }
开发者ID:amnah,项目名称:yii2-angular,代码行数:34,代码来源:FastDb.php

示例11: testActions

 public function testActions()
 {
     $modules = array('EmulateModuleHelper' => new \Codeception\Module\EmulateModuleHelper());
     $actions = \Codeception\Configuration::actions($modules);
     $this->assertArrayHasKey('seeEquals', $actions);
     $this->assertEquals('EmulateModuleHelper', $actions['seeEquals']);
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:7,代码来源:ConfigurationTest.php

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

示例13: testCreateInSubpath

 public function testCreateInSubpath()
 {
     $this->execute(array('suite' => 'shire', 'step' => 'User/Login', '--silent' => true));
     $generated = $this->log[0];
     $this->assertEquals(\Codeception\Configuration::supportDir() . 'Step/Shire/User/Login.php', $generated['filename']);
     $this->assertIsValidPhp($this->content);
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:7,代码来源:GenerateStepObjectTest.php

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

示例15: __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


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