diff --git a/src/ncc/Classes/PhpExtension/Templates/PhpUnitTemplate.php b/src/ncc/Classes/PhpExtension/Templates/PhpUnitTemplate.php new file mode 100644 index 0000000..b09a154 --- /dev/null +++ b/src/ncc/Classes/PhpExtension/Templates/PhpUnitTemplate.php @@ -0,0 +1,76 @@ +getProjectPath() . DIRECTORY_SEPARATOR . 'phpunit.xml', + ConstantCompiler::compileConstants($project_manager->getProjectConfiguration(), + IO::fread(__DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.tpl') + ) + ); + + if(!file_exists($project_manager->getProjectPath() . DIRECTORY_SEPARATOR . 'tests')) + { + mkdir($project_manager->getProjectPath() . DIRECTORY_SEPARATOR . 'tests'); + } + } + + private static function createPhpUnitBootstrapTemplate(ProjectManager $project_manager): void + { + IO::fwrite( + $project_manager->getProjectPath() . DIRECTORY_SEPARATOR . 'bootstrap.php', + ConstantCompiler::compileConstants($project_manager->getProjectConfiguration(), + IO::fread(__DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php.tpl') + ) + ); + } + } \ No newline at end of file diff --git a/src/ncc/Classes/PhpExtension/Templates/bootstrap.php.tpl b/src/ncc/Classes/PhpExtension/Templates/bootstrap.php.tpl new file mode 100644 index 0000000..0e65aed --- /dev/null +++ b/src/ncc/Classes/PhpExtension/Templates/bootstrap.php.tpl @@ -0,0 +1,3 @@ + + + + tests + + + + + + + diff --git a/src/ncc/Enums/ProjectTemplates.php b/src/ncc/Enums/ProjectTemplates.php index cea4608..43107a1 100644 --- a/src/ncc/Enums/ProjectTemplates.php +++ b/src/ncc/Enums/ProjectTemplates.php @@ -33,4 +33,6 @@ * A template that is used to create a PHP CLI application project */ case PHP_CLI = 'phpcli'; + + case PHP_UNIT = 'phpunit'; } \ No newline at end of file diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 01408c1..97924d1 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -30,8 +30,8 @@ use ncc\Classes\PhpExtension\NccCompiler; use ncc\Classes\PhpExtension\Templates\CliTemplate; use ncc\Classes\PhpExtension\Templates\LibraryTemplate; + use ncc\Classes\PhpExtension\Templates\PhpUnitTemplate; use ncc\Enums\CompilerExtensions; - use ncc\Enums\ComponentFileExtensions; use ncc\Enums\Options\BuildConfigurationOptions; use ncc\Enums\Options\BuildConfigurationValues; use ncc\Enums\Options\InitializeProjectOptions; @@ -199,6 +199,10 @@ LibraryTemplate::applyTemplate($this); break; + case ProjectTemplates::PHP_UNIT->value: + PhpUnitTemplate::applyTemplate($this); + break; + default: throw new NotSupportedException('The given template \'' . $template_name . '\' is not supported'); } diff --git a/src/ncc/Utilities/ConsoleProgressBar.php b/src/ncc/Utilities/ConsoleProgressBar.php index bced3c1..b02ea48 100644 --- a/src/ncc/Utilities/ConsoleProgressBar.php +++ b/src/ncc/Utilities/ConsoleProgressBar.php @@ -289,7 +289,7 @@ */ public function update(): void { - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { return; }