![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/codeception/codeception/src/Codeception/Lib/Generator/ |
<?php declare(strict_types=1); namespace Codeception\Lib\Generator; use Codeception\Configuration; use Codeception\Lib\Generator\Shared\Classname; use Codeception\Util\Shared\Namespaces; use Codeception\Util\Template; class Test { use Namespaces; use Classname; protected string $template = <<<EOF <?php {{namespace}} class {{name}}Test extends \Codeception\Test\Unit { {{tester}} protected function _before() { } // tests public function testSomeFeature() { } } EOF; protected string $testerTemplate = <<<EOF protected {{actorClass}} \${{actor}}; EOF; protected string $name; public function __construct(protected array $settings, string $name) { $this->name = $this->removeSuffix($name, 'Test'); } public function produce(): string { $actor = $this->settings['actor']; $ns = $this->getNamespaceHeader($this->settings['namespace'] . '\\' . ucfirst($this->settings['suite']) . '\\' . $this->name); if ($ns) { $ns .= "\nuse " . $this->supportNamespace() . $actor . ";"; } $tester = ''; if ($this->settings['actor']) { $tester = (new Template($this->testerTemplate)) ->place('actorClass', $actor) ->place('actor', lcfirst(Configuration::config()['actor_suffix'])) ->produce(); } return (new Template($this->template)) ->place('namespace', $ns) ->place('name', $this->getShortClassName($this->name)) ->place('tester', $tester) ->produce(); } }