1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

436: bit of test and more useful exception message

This commit is contained in:
James Titcumb
2026-02-09 16:46:47 +00:00
parent 55f9985c48
commit 1a13937bcb
2 changed files with 32 additions and 2 deletions

View File

@@ -36,7 +36,8 @@ final class UnixBuild implements Build
IOInterface $io,
PhpizePath|null $phpizePath,
): BinaryFile {
switch (DownloadUrlMethod::fromDownloadedPackage($downloadedPackage)) {
$selectedDownloadMethod = DownloadUrlMethod::fromDownloadedPackage($downloadedPackage);
switch ($selectedDownloadMethod) {
case DownloadUrlMethod::PrePackagedBinary:
return $this->prePackagedBinary($downloadedPackage, $io);
@@ -45,7 +46,7 @@ final class UnixBuild implements Build
return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io, $phpizePath);
default:
throw new LogicException('Unknown download method');
throw new LogicException('Unsupported download method: ' . $selectedDownloadMethod->value);
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Php\PieUnitTest\Building;
use Php\Pie\Building\ExtensionBinaryNotFound;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(ExtensionBinaryNotFound::class)]
final class ExtensionBinaryNotFoundTest extends TestCase
{
public function testFromPrePackagedBinary(): void
{
self::assertSame(
'Expected pre-packaged binary does not exist: /foo/bar',
ExtensionBinaryNotFound::fromPrePackagedBinary('/foo/bar')->getMessage(),
);
}
public function testFromExpectedBinary(): void
{
self::assertSame(
'Build complete, but expected /foo/bar does not exist.',
ExtensionBinaryNotFound::fromExpectedBinary('/foo/bar')->getMessage(),
);
}
}