Introduce AttributeMapper for managing extensions and doctor attributes

This commit is contained in:
crazywhalecc
2025-08-06 20:35:52 +08:00
committed by Jerry Ma
parent e28580de00
commit 722bb31815
14 changed files with 338 additions and 265 deletions

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace SPC\Tests\builder;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SPC\builder\BuilderBase;
use SPC\builder\BuilderProvider;
@@ -14,7 +13,7 @@ use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\store\LockFile;
use SPC\util\CustomExt;
use SPC\util\AttributeMapper;
use SPC\util\DependencyUtil;
use Symfony\Component\Console\Input\ArgvInput;
@@ -36,9 +35,8 @@ class BuilderTest extends TestCase
$this->builder = BuilderProvider::makeBuilderByInput(new ArgvInput());
[$extensions, $libs] = DependencyUtil::getExtsAndLibs(['mbregex']);
$this->builder->proveLibs($libs);
CustomExt::loadCustomExt();
foreach ($extensions as $extension) {
$class = CustomExt::getExtClass($extension);
$class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
$ext = new $class($extension, $this->builder);
$this->builder->addExt($ext);
}

View File

@@ -7,7 +7,7 @@ namespace SPC\Tests\builder;
use PHPUnit\Framework\TestCase;
use SPC\builder\BuilderProvider;
use SPC\builder\Extension;
use SPC\util\CustomExt;
use SPC\util\AttributeMapper;
use SPC\util\DependencyUtil;
use Symfony\Component\Console\Input\ArgvInput;
@@ -23,9 +23,8 @@ class ExtensionTest extends TestCase
$builder = BuilderProvider::makeBuilderByInput(new ArgvInput());
[$extensions, $libs] = DependencyUtil::getExtsAndLibs(['mbregex']);
$builder->proveLibs($libs);
CustomExt::loadCustomExt();
foreach ($extensions as $extension) {
$class = CustomExt::getExtClass($extension);
$class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
$ext = new $class($extension, $builder);
$builder->addExt($ext);
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\Tests\doctor;
use PHPUnit\Framework\TestCase;
use SPC\doctor\CheckListHandler;
use SPC\doctor\DoctorHandler;
/**
* @internal
@@ -14,9 +14,9 @@ final class CheckListHandlerTest extends TestCase
{
public function testRunChecksReturnsListOfCheck(): void
{
$list = new CheckListHandler();
$list = new DoctorHandler();
$id = $list->runChecks();
$id = $list->getValidCheckList();
foreach ($id as $item) {
$this->assertInstanceOf('SPC\doctor\AsCheckItem', $item);
}

View File

@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace SPC\Tests\store;
use PHPUnit\Framework\TestCase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
/**