From cc1879777c7f3b29cb8b22f5f387c44881a0a582 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 23 Jul 2016 18:23:44 +0200 Subject: [PATCH] Added test generator --- testGenerator.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 testGenerator.php diff --git a/testGenerator.php b/testGenerator.php new file mode 100644 index 0000000..1acb5ca --- /dev/null +++ b/testGenerator.php @@ -0,0 +1,75 @@ += 0 && strpos($haystack, $needle, $temp) !== false); +} + +function listFolderFiles($dir, $extension) +{ + $files = []; + $ffs = scandir($dir); + foreach ($ffs as $ff) { + if ($ff !== '.' && $ff !== '..') { + if (is_dir($dir . '/' . $ff)) { + $files += listFolderFiles($dir . '/' . $ff, $extension); + } else { + if (endsWith($ff, $extension)) { + $files[] = $dir . '/' . $ff; + } + } + } + } + + return $files; +} + +// PHP tests +$base = __DIR__ . '/../phpOMS'; +$files = listFolderFiles($base, '.php'); +$testBase = __DIR__ . '/../Tests/PHPUnit/Framework'; + +foreach ($files as $file) { + $file = str_replace($base, '', $file); + $subdir = trim($file, '/'); + $split = explode('.', $file); + $testPath = $testBase . '/'. $split[0] . 'Test.' . $split[1]; + + if (strpos($subdir, 'Status.php') === false + && strpos($subdir, 'Type.php') === false + && strpos($subdir, 'Status') === false + && strpos($subdir, 'Enum') === false + && strpos($subdir, 'Null') === false + && strpos($subdir, 'Interface') === false + && strpos($subdir, 'Abstract') === false) { + if(!file_exists($testPath)) { + mkdir(dirname($testPath), 0777, true); + file_put_contents($testPath, '