mirror of
https://github.com/Karaka-Management/Build.git
synced 2026-01-11 03:38:40 +00:00
fix demoSetup
This commit is contained in:
parent
b245e0c1b5
commit
9e4ecebbbf
File diff suppressed because it is too large
Load Diff
121
Helper/reconcileTestReportElements.php
Normal file
121
Helper/reconcileTestReportElements.php
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Helper
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
// Find missing tests
|
||||
|
||||
$report = include __DIR__ . '/../../Build/Config/reportLang.php';
|
||||
|
||||
$noTestFile = [];
|
||||
$noTestFunction = [];
|
||||
|
||||
$noReportFile = [];
|
||||
$noReportFunction = [];
|
||||
|
||||
$invalidDescription = [];
|
||||
|
||||
$lastFileName = '';
|
||||
$lastFileContent = '';
|
||||
|
||||
foreach ($report as $key => $line) {
|
||||
if (\stripos($key, '\tests\\') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (\stripos($key, ':') === false) {
|
||||
continue;
|
||||
} else {
|
||||
$parts = \explode(':', $key);
|
||||
|
||||
$file = \reset($parts);
|
||||
$function = \end($parts);
|
||||
|
||||
$file = __DIR__ . '/../../' . \str_replace('\\', '/', $file) . '.php';
|
||||
|
||||
if (!\is_file($file)) {
|
||||
$noTestFile[] = $key;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($file !== $lastFileName) {
|
||||
$lastFileName = $file;
|
||||
$lastFileContent = \file_get_contents($lastFileName);
|
||||
}
|
||||
|
||||
if (\stripos($lastFileContent, $function) === false) {
|
||||
$noTestFunction[] = $key;
|
||||
} elseif (\stripos($lastFileContent, $line['description']) === false) {
|
||||
$invalidDescription[] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$noTestFile = \array_unique($noTestFile);
|
||||
$noTestFunction = \array_unique($noTestFunction);
|
||||
|
||||
echo "\nNo test file:\n";
|
||||
foreach ($noTestFile as $file) {
|
||||
echo $file . "\n";
|
||||
}
|
||||
|
||||
echo "\nNo test function:\n";
|
||||
foreach ($noTestFunction as $function) {
|
||||
echo $function . "\n";
|
||||
}
|
||||
|
||||
echo "\nInvalid test description:\n";
|
||||
foreach ($invalidDescription as $function) {
|
||||
echo $function . "\n";
|
||||
}
|
||||
|
||||
$directories = [
|
||||
__DIR__ . '/../../phpOMS/tests/**/*Test.php',
|
||||
__DIR__ . '/../../Modules/**/tests/**/*Test.php'
|
||||
];
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
$files = \glob($directory);
|
||||
foreach($files as $file) {
|
||||
$fp = \fopen($file, 'r');
|
||||
|
||||
while (!\feof($fp)) {
|
||||
$line = \fgets($fp);
|
||||
|
||||
if ($line === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (\stripos($line, ' public function test') !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$end = \strpos($line, '(');
|
||||
$function = \substr($line, 20, $end - 20);
|
||||
|
||||
$name = \substr(\realpath($file), \strlen(\realpath(__DIR__ . '/../../')) + 1, -4);
|
||||
$name = \str_replace('/', '\\', $name);
|
||||
|
||||
$reportKey = $name . ':' . $function;
|
||||
|
||||
if (!isset($report[$reportKey])) {
|
||||
$noReportFunction[] = $reportKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "\nNo report function:\n";
|
||||
foreach ($noReportFunction as $function) {
|
||||
echo $function . "\n";
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ mkdir -p Build/test
|
|||
|
||||
# php cs + phpstan + eslint file generation
|
||||
./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" -s --report-junit=Build/test/junit_phpcs.xml
|
||||
./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon --error-format=prettyJson ./ > Build/test/phpstan.json
|
||||
./vendor/bin/phpstan analyse -l 9 -c Build/Config/phpstan.neon --error-format=prettyJson ./ > Build/test/phpstan.json
|
||||
npx eslint jsOMS/ -c Build/Config/.eslintrc.json -o Build/test/junit_eslint.xml -f junit
|
||||
|
||||
# Remove empty lines and lines with warnings which corrupt the json format
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user