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


PHP Configuration::helpersDir方法代码示例

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


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

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

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

示例3: updateHelpers

 protected function updateHelpers()
 {
     $helpers = Finder::create()->files()->name('*Helper.php')->in(\Codeception\Configuration::helpersDir());
     foreach ($helpers as $helper_file) {
         $helper_body = file_get_contents($helper_file);
         $helper_body = preg_replace('~namespace Codeception\\\\Module;~', "namespace {$this->namespace}\\Codeception\\Module;", $helper_body);
         $this->save($helper_file, $helper_body, true);
     }
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:9,代码来源:RefactorAddNamespace.php

示例4: testGuyWithSuffix

 public function testGuyWithSuffix()
 {
     $this->execute(array('suite' => 'shire', 'actor' => 'HobbitGuy'));
     $conf = \Symfony\Component\Yaml\Yaml::parse($this->content);
     $this->assertEquals('HobbitGuy', $conf['class_name']);
     $this->assertContains('HobbitHelper', $conf['modules']['enabled']);
     $helper = $this->log[1];
     $this->assertEquals(\Codeception\Configuration::helpersDir() . 'HobbitHelper.php', $helper['filename']);
     $this->assertContains('class HobbitHelper extends \\Codeception\\Module', $helper['content']);
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:10,代码来源:GenerateSuiteTest.php

示例5: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $name = ucfirst($input->getArgument('name'));
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $file = \Codeception\Configuration::helpersDir() . "{$name}Helper.php";
     $res = $this->save($file, (new Helper($name, $config['namespace']))->produce());
     if ($res) {
         $output->writeln("<info>Helper {$file} created</info>");
     } else {
         $output->writeln("<error>Error creating helper {$file}</error>");
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:12,代码来源:GenerateHelper.php

示例6: testBasic

 public function testBasic()
 {
     $this->execute(array('namespace' => 'MiddleEarth', '--force' => true));
     $this->assertContains('adds namespaces to your Helper and Guy classes and Cepts', $this->output);
     $config = $this->log[0];
     $this->assertContains('Config file updated', $this->output);
     $this->assertContains('namespace: MiddleEarth', $config['content']);
     $this->assertEquals(\Codeception\Configuration::projectDir() . 'codeception.yml', (string) $config['filename']);
     $helper = $this->log[1];
     $this->assertContains('namespace MiddleEarth\\Codeception\\Module', $helper['content']);
     $this->assertRegExp('~' . \Codeception\Configuration::helpersDir() . '.*?Helper~', (string) $helper['filename']);
     // log[2] is helper, log[3] ... are helpers too
     $cept = $this->log[7];
     $this->assertRegExp('~<?php use MiddleEarth\\\\.*Guy~', $cept['content']);
     $this->assertIsValidPhp($cept['content']);
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:16,代码来源:RefactorAddNamespaceTest.php

示例7: execute

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $suite = lcfirst($input->getArgument('suite'));
        $actor = $input->getArgument('actor');

        $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)) {
            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.");
        }

        $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 for 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()
        );

        $conf = array(
            'class_name' => $actorName.$config['actor'],
            'modules' => array(
                'enabled' => array($actorName . 'Helper')
            ),
        );

        $this->save($dir . $suite . '.suite.yml', Yaml::dump($conf, 2));

        $output->writeln("<info>Suite $suite generated</info>");
    }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:45,代码来源:GenerateSuite.php

示例8: autoloadHelpers

 protected static function autoloadHelpers()
 {
     Autoload::registerSuffix('Helper', \Codeception\Configuration::helpersDir());
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:4,代码来源:Configuration.php


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