當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。