mirror of
https://github.com/Karaka-Management/Build.git
synced 2026-01-26 18:18:40 +00:00
Added test generator
This commit is contained in:
parent
cfe15807af
commit
cc1879777c
75
testGenerator.php
Normal file
75
testGenerator.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
function endsWith($haystack, $needle)
|
||||
{
|
||||
return $needle === '' || (($temp = strlen($haystack) - strlen($needle)) >= 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, '<?php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PHP tests
|
||||
$base = __DIR__ . '/../jsOMS';
|
||||
$files = listFolderFiles($base, '.php');
|
||||
$testBase = __DIR__ . '/../Tests/JS/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, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user