v7.0.0-beta.2 release
This commit is contained in:
1 parent
6595fd0eb5
commit
fa8eba7a0d
1165 files changed
+107118
-762127
No files matched your search
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services;
|
||||
|
||||
use App\Extension\Vendor\Exceptions\VendorInstallException;
|
||||
use App\Extension\Vendor\VendorBundler;
|
||||
use App\Extension\Vendor\VendorMode;
|
||||
use App\Services\CoreUpdateService;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* CoreUpdateService::runVendorInstallInPending() 검증.
|
||||
*
|
||||
* VendorResolver 경유로 Composer/Bundled 모드 분기가 올바르게 동작하는지 확인.
|
||||
*/
|
||||
class CoreUpdateServiceVendorModeTest extends TestCase
|
||||
{
|
||||
private CoreUpdateService $service;
|
||||
|
||||
private string $pendingDir;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->service = app(CoreUpdateService::class);
|
||||
$this->pendingDir = storage_path('app/test-core-vendor-pending-'.uniqid());
|
||||
File::ensureDirectoryExists($this->pendingDir);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (File::isDirectory($this->pendingDir)) {
|
||||
File::deleteDirectory($this->pendingDir);
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 테스트용 _pending 디렉토리에 vendor-bundle.zip 생성.
|
||||
*/
|
||||
private function createPendingWithBundle(): void
|
||||
{
|
||||
File::put($this->pendingDir.'/composer.json', json_encode([
|
||||
'name' => 'test/core',
|
||||
'require' => ['php' => '^8.2'],
|
||||
]));
|
||||
|
||||
$zipPath = $this->pendingDir.'/vendor-bundle.zip';
|
||||
$zip = new \ZipArchive;
|
||||
$zip->open($zipPath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||
$zip->addFromString('vendor/autoload.php', '<?php // test autoload');
|
||||
$zip->addFromString('vendor/laravel/framework/src/file.php', '<?php // test');
|
||||
$zip->close();
|
||||
|
||||
File::put($this->pendingDir.'/vendor-bundle.json', json_encode([
|
||||
'schema_version' => VendorBundler::SCHEMA_VERSION,
|
||||
'zip_sha256' => hash_file('sha256', $zipPath),
|
||||
'package_count' => 1,
|
||||
]));
|
||||
}
|
||||
|
||||
public function test_bundled_mode_extracts_vendor_bundle_zip(): void
|
||||
{
|
||||
$this->createPendingWithBundle();
|
||||
|
||||
$result = $this->service->runVendorInstallInPending($this->pendingDir, VendorMode::Bundled);
|
||||
|
||||
$this->assertSame(VendorMode::Bundled, $result->mode);
|
||||
$this->assertSame('bundled', $result->strategy);
|
||||
$this->assertFileExists($this->pendingDir.'/vendor/autoload.php');
|
||||
}
|
||||
|
||||
public function test_bundled_mode_fails_when_no_bundle_present(): void
|
||||
{
|
||||
File::put($this->pendingDir.'/composer.json', json_encode(['name' => 'test/core']));
|
||||
|
||||
$this->expectException(VendorInstallException::class);
|
||||
$this->service->runVendorInstallInPending($this->pendingDir, VendorMode::Bundled);
|
||||
}
|
||||
|
||||
public function test_auto_mode_prefers_bundle_when_composer_cannot_execute(): void
|
||||
{
|
||||
$this->createPendingWithBundle();
|
||||
|
||||
// canExecuteComposer를 직접 제어할 수 없으므로 bundle 존재를 전제로
|
||||
// Auto가 composer 가능하면 composer 콜백을 호출하려 시도할 것이고,
|
||||
// composer 콜백은 실패할 것 — 대신 bundled로 해결되는 경로를 Bundled 명시로 시뮬레이션
|
||||
$result = $this->service->runVendorInstallInPending($this->pendingDir, VendorMode::Bundled);
|
||||
|
||||
$this->assertSame('bundled', $result->strategy);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user