Skip to content

Commit 1a13937

Browse files
committed
436: bit of test and more useful exception message
1 parent 55f9985 commit 1a13937

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/Building/UnixBuild.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public function __invoke(
3636
IOInterface $io,
3737
PhpizePath|null $phpizePath,
3838
): BinaryFile {
39-
switch (DownloadUrlMethod::fromDownloadedPackage($downloadedPackage)) {
39+
$selectedDownloadMethod = DownloadUrlMethod::fromDownloadedPackage($downloadedPackage);
40+
switch ($selectedDownloadMethod) {
4041
case DownloadUrlMethod::PrePackagedBinary:
4142
return $this->prePackagedBinary($downloadedPackage, $io);
4243

@@ -45,7 +46,7 @@ public function __invoke(
4546
return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io, $phpizePath);
4647

4748
default:
48-
throw new LogicException('Unknown download method');
49+
throw new LogicException('Unsupported download method: ' . $selectedDownloadMethod->value);
4950
}
5051
}
5152

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Php\PieUnitTest\Building;
6+
7+
use Php\Pie\Building\ExtensionBinaryNotFound;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\TestCase;
10+
11+
#[CoversClass(ExtensionBinaryNotFound::class)]
12+
final class ExtensionBinaryNotFoundTest extends TestCase
13+
{
14+
public function testFromPrePackagedBinary(): void
15+
{
16+
self::assertSame(
17+
'Expected pre-packaged binary does not exist: /foo/bar',
18+
ExtensionBinaryNotFound::fromPrePackagedBinary('/foo/bar')->getMessage(),
19+
);
20+
}
21+
22+
public function testFromExpectedBinary(): void
23+
{
24+
self::assertSame(
25+
'Build complete, but expected /foo/bar does not exist.',
26+
ExtensionBinaryNotFound::fromExpectedBinary('/foo/bar')->getMessage(),
27+
);
28+
}
29+
}

0 commit comments

Comments
 (0)