From 265a9f9bee6a01a27ad8be72dfae3d153755cbd5 Mon Sep 17 00:00:00 2001 From: David Vandemaele Date: Wed, 13 Apr 2022 14:00:05 +0200 Subject: [PATCH] Replace 'directory' for 'path' --- README.md | 8 ++++---- console/all.php | 16 +++++++++------- console/intense.php | 10 ++++++---- console/run.php | 10 ++++++---- lib/Skeleton/Test/Config.php | 11 +++++++++++ 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 46616b4..4a65b7b 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Installation via composer: ## Howto - // Set a directory where tests are located in - \Skeleton\Test\Config::$test_directory = /my_tests'; + // Set a path where tests are located in + \Skeleton\Test\Config::$test_path = /my_tests'; // For Selenium test, set the Selenium hub URL \Skeleton\Test\Config::$selenium_hub = 'http://localhost:4444/wd/hub'; @@ -28,13 +28,13 @@ Installation via composer: // To intensively (10x) run a single test skeleton test:intense My_First_Test_Class - + // To run a list of test skeleton test:run My_First_Test_Class,My_Second_Test_Class // To intensively (10x) run a list test skeleton test:intense My_First_Test_Class,My_Second_Test_Class - + // To use files in the tests (only if skeleton-file is available) skeleton test:file add identifier /var/www/mysite/my_file.txt skeleton test:file get identifier /var/www/mysite/target_file.txt diff --git a/console/all.php b/console/all.php index cd4a92b..27d87d4 100644 --- a/console/all.php +++ b/console/all.php @@ -33,14 +33,16 @@ protected function configure() { * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { - if (!file_exists(\Skeleton\Test\Config::$test_directory)) { - $output->writeln('Config::$test_directory is not set to a valid directory'); + if (\Skeleton\Test\Config::$test_directory !== null) { + \Skeleton\Test\Config::$test_path = \Skeleton\Test\Config::$test_directory; + } + + if (!file_exists(\Skeleton\Test\Config::$test_path)) { + $output->writeln('Config::$test_path is not set to a valid path'); return 1; } - $directory = \Skeleton\Test\Config::$test_directory; $phpunit = new \PHPUnit\TextUI\TestRunner; - $arguments = [ 'colors' => 'always', 'verbose' => false, @@ -60,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $declared_classes = get_declared_classes(); // Load classes inside the given folder: - $dir_iterator = new \RecursiveDirectoryIterator($directory); + $dir_iterator = new \RecursiveDirectoryIterator(\Skeleton\Test\Config::$test_path); $iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { @@ -75,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { } $scenes = array_diff(get_declared_classes(), $declared_classes); - + foreach ($scenes as $key => $scene) { if (strpos($scene, 'Scene_') !== 0) { unset($scenes[$key]); @@ -86,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $suite = new \PHPUnit\Framework\TestSuite(); foreach ($scenes as $scene) { $suite->addTestSuite($scene); - } + } $test_results = $phpunit->run($suite, $arguments); return 0; diff --git a/console/intense.php b/console/intense.php index 3305659..4c54ad4 100644 --- a/console/intense.php +++ b/console/intense.php @@ -35,14 +35,16 @@ protected function configure() { * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { - if (!file_exists(\Skeleton\Database\Migration\Config::$migration_directory)) { - $output->writeln('Config::$test_directory is not set to a valid directory'); + if (\Skeleton\Test\Config::$test_directory !== null) { + \Skeleton\Test\Config::$test_path = \Skeleton\Test\Config::$test_directory; + } + + if (!file_exists(\Skeleton\Database\Migration\Config::$test_path)) { + $output->writeln('Config::$test_path is not set to a valid directory'); return 1; } - $directory = \Skeleton\Test\Config::$test_directory; $phpunit = new \PHPUnit\TextUI\TestRunner(); - $arguments = [ 'colors' => 'always', 'verbose' => false, diff --git a/console/run.php b/console/run.php index bd4a351..665228d 100644 --- a/console/run.php +++ b/console/run.php @@ -35,14 +35,16 @@ protected function configure() { * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { - if (!file_exists(\Skeleton\Database\Migration\Config::$migration_directory)) { - $output->writeln('Config::$test_directory is not set to a valid directory'); + if (\Skeleton\Test\Config::$test_directory !== null) { + \Skeleton\Test\Config::$test_path = \Skeleton\Test\Config::$test_directory; + } + + if (!file_exists(\Skeleton\Test\Config::$test_path)) { + $output->writeln('Config::$test_path is not set to a valid path'); return 1; } - $directory = \Skeleton\Test\Config::$test_directory; $phpunit = new \PHPUnit\TextUI\TestRunner(); - $arguments = [ 'colors' => 'always', 'verbose' => false, diff --git a/lib/Skeleton/Test/Config.php b/lib/Skeleton/Test/Config.php index f703acc..da00bdc 100644 --- a/lib/Skeleton/Test/Config.php +++ b/lib/Skeleton/Test/Config.php @@ -33,10 +33,21 @@ class Config { * This folder will be used to store the tests * * @access public + * @deprecated use $test_path instead * @var string $test_directory */ public static $test_directory = null; + /** + * Test path + * + * This folder will be used to store the tests + * + * @access public + * @var string $test_path + */ + public static $test_path = null; + /** * Name of the file where the start timestamp will be stored *