Files
admin/module/Application/src/Command/UnitTestCommand.php
2025-09-13 01:22:15 +08:00

60 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
*
* @authorllbjj
* @DateTime2022/5/9 12:25
* @Description
*
*/
namespace Application\Command;
use Application\Service\Extension\Helper\ArrayHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use function Co\run;
class UnitTestCommand extends BasicCommand
{
/**
* 脚本描述.
* @var string
*/
protected static $defaultDescription = '运行单元测试实例。';
protected function configure()
{
$this
->addArgument(
'files',
InputArgument::IS_ARRAY
)
;
}
public function execute(InputInterface $input, OutputInterface $output)
{
$updateFiles = $input->getArguments();
run(function() use ($updateFiles) {
// $ret = \Swoole\Coroutine\System::exec("/usr/bin/php vendor/bin/phpunit module/Application/test/model --coverage-html report");
$unitTestFiles = [
'phpunit.xml.dist',
'module/Application/test/model/BaseTestUnit.php',
'module/Application/test/model/DictionaryFormTest.php',
'module/Application/test/model/HelperTest.php',
'module/Application/test/model/PatientFormTest.php',
'module/Application/test/model/PatientModelTest.php',
];
$file = implode(' ', ArrayHelper::merge($unitTestFiles, $updateFiles['files']));
$ret = \Swoole\Coroutine\System::exec("git fetch && git checkout origin/develop {$file} && /usr/bin/php vendor/bin/phpunit");
echo $ret['output'];
});
return 0;
}
}