當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Configuration::testsDir方法代碼示例

本文整理匯總了PHP中Codeception\Configuration::testsDir方法的典型用法代碼示例。如果您正苦於以下問題:PHP Configuration::testsDir方法的具體用法?PHP Configuration::testsDir怎麽用?PHP Configuration::testsDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Codeception\Configuration的用法示例。


在下文中一共展示了Configuration::testsDir方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

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

示例4: getTestsDir

 public function getTestsDir()
 {
     return Config::testsDir();
 }
開發者ID:hitechdk,項目名稱:Codeception,代碼行數:4,代碼來源:Extension.php


注:本文中的Codeception\Configuration::testsDir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。