Skip to content

Commit

Permalink
Replace 'directory' for 'path'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Vandemaele committed Apr 13, 2022
1 parent 4d48556 commit 265a9f9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions console/all.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<error>Config::$test_directory is not set to a valid directory</error>');
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('<error>Config::$test_path is not set to a valid path</error>');
return 1;
}

$directory = \Skeleton\Test\Config::$test_directory;
$phpunit = new \PHPUnit\TextUI\TestRunner;

$arguments = [
'colors' => 'always',
'verbose' => false,
Expand All @@ -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) {
Expand All @@ -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]);
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions console/intense.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<error>Config::$test_directory is not set to a valid directory</error>');
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('<error>Config::$test_path is not set to a valid directory</error>');
return 1;
}

$directory = \Skeleton\Test\Config::$test_directory;
$phpunit = new \PHPUnit\TextUI\TestRunner();

$arguments = [
'colors' => 'always',
'verbose' => false,
Expand Down
10 changes: 6 additions & 4 deletions console/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<error>Config::$test_directory is not set to a valid directory</error>');
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('<error>Config::$test_path is not set to a valid path</error>');
return 1;
}

$directory = \Skeleton\Test\Config::$test_directory;
$phpunit = new \PHPUnit\TextUI\TestRunner();

$arguments = [
'colors' => 'always',
'verbose' => false,
Expand Down
11 changes: 11 additions & 0 deletions lib/Skeleton/Test/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 265a9f9

Please sign in to comment.