mirror of
https://github.com/php-win-ext/pie.git
synced 2026-03-23 20:52:07 +01:00
Rework PhpizePath to be passed to TargetPlatform
This commit is contained in:
@@ -12,12 +12,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Command/CommandHelper.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to string\.$#'
|
||||
identifier: cast.string
|
||||
count: 1
|
||||
path: src/Command/CommandHelper.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to string\.$#'
|
||||
identifier: cast.string
|
||||
@@ -480,6 +474,12 @@ parameters:
|
||||
count: 1
|
||||
path: test/unit/Installing/InstallForPhpProject/InstallSelectedPackageTest.php
|
||||
|
||||
-
|
||||
message: '#^Access to an undefined property Php\\PieUnitTest\\SelfManage\\BuildTools\\PhpizeBuildToolFinderTest\:\:\$phpBinaryPath\.$#'
|
||||
identifier: property.notFound
|
||||
count: 3
|
||||
path: test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php
|
||||
|
||||
-
|
||||
message: '#^Method Php\\PieUnitTest\\SelfManage\\Verify\\FallbackVerificationUsingOpenSslTest\:\:prepareCertificateAndSignature\(\) should return array\{string, string\} but returns array\{mixed, mixed\}\.$#'
|
||||
identifier: return.type
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Php\Pie\Building;
|
||||
use Composer\IO\IOInterface;
|
||||
use Php\Pie\Downloading\DownloadedPackage;
|
||||
use Php\Pie\File\BinaryFile;
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
use Php\Pie\Platform\TargetPlatform;
|
||||
|
||||
/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
|
||||
@@ -19,6 +18,5 @@ interface Build
|
||||
TargetPlatform $targetPlatform,
|
||||
array $configureOptions,
|
||||
IOInterface $io,
|
||||
PhpizePath|null $phpizePath,
|
||||
): BinaryFile;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ final class UnixBuild implements Build
|
||||
TargetPlatform $targetPlatform,
|
||||
array $configureOptions,
|
||||
IOInterface $io,
|
||||
PhpizePath|null $phpizePath,
|
||||
): BinaryFile {
|
||||
$selectedDownloadMethod = DownloadUrlMethod::fromDownloadedPackage($downloadedPackage);
|
||||
switch ($selectedDownloadMethod) {
|
||||
@@ -43,7 +42,7 @@ final class UnixBuild implements Build
|
||||
|
||||
case DownloadUrlMethod::ComposerDefaultDownload:
|
||||
case DownloadUrlMethod::PrePackagedSourceDownload:
|
||||
return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io, $phpizePath);
|
||||
return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io);
|
||||
|
||||
default:
|
||||
throw new LogicException('Unsupported download method: ' . $selectedDownloadMethod->value);
|
||||
@@ -74,7 +73,6 @@ final class UnixBuild implements Build
|
||||
TargetPlatform $targetPlatform,
|
||||
array $configureOptions,
|
||||
IOInterface $io,
|
||||
PhpizePath|null $phpizePath,
|
||||
): BinaryFile {
|
||||
$outputCallback = null;
|
||||
if ($io->isVerbose()) {
|
||||
@@ -88,7 +86,7 @@ final class UnixBuild implements Build
|
||||
};
|
||||
}
|
||||
|
||||
$phpizePath ??= PhpizePath::guessFrom($targetPlatform->phpBinaryPath);
|
||||
$phpizePath = $targetPlatform->phpizePath ?? PhpizePath::guessFrom($targetPlatform->phpBinaryPath);
|
||||
|
||||
/**
|
||||
* Call a cleanup first; most of the time, we expect to be changing a
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Php\Pie\Building;
|
||||
use Composer\IO\IOInterface;
|
||||
use Php\Pie\Downloading\DownloadedPackage;
|
||||
use Php\Pie\File\BinaryFile;
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
use Php\Pie\Platform\TargetPlatform;
|
||||
use Php\Pie\Platform\WindowsExtensionAssetName;
|
||||
|
||||
@@ -22,7 +21,6 @@ final class WindowsBuild implements Build
|
||||
TargetPlatform $targetPlatform,
|
||||
array $configureOptions,
|
||||
IOInterface $io,
|
||||
PhpizePath|null $phpizePath,
|
||||
): BinaryFile {
|
||||
$prebuiltDll = WindowsExtensionAssetName::determineDllName($targetPlatform, $downloadedPackage);
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ final class BuildCommand extends Command
|
||||
$requestedNameAndVersion,
|
||||
PieOperation::Resolve,
|
||||
[], // Configure options are not needed for resolve only
|
||||
null,
|
||||
false, // setting up INI not needed for build
|
||||
),
|
||||
);
|
||||
@@ -126,7 +125,6 @@ final class BuildCommand extends Command
|
||||
$requestedNameAndVersion,
|
||||
PieOperation::Build,
|
||||
$configureOptionsValues,
|
||||
CommandHelper::determinePhpizePathFromInputs($input),
|
||||
false, // setting up INI not needed for build
|
||||
),
|
||||
);
|
||||
|
||||
@@ -185,15 +185,6 @@ final class CommandHelper
|
||||
throw new InvalidArgumentException('The --with-php-path=/path/to/php cannot be used on non-Windows, use --with-php-config=/path/to/php-config instead.');
|
||||
}
|
||||
|
||||
if (Platform::isWindows() && $input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) {
|
||||
/** @var mixed $withPhpizePath */
|
||||
$withPhpizePath = $input->getOption(self::OPTION_WITH_PHPIZE_PATH);
|
||||
|
||||
if (is_string($withPhpizePath) && trim($withPhpizePath) !== '') {
|
||||
throw new InvalidArgumentException('The --with-phpize-path=/path/to/phpize cannot be used on Windows.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($specifiedWithPhpConfig) {
|
||||
$phpBinaryPath = PhpBinaryPath::fromPhpConfigExecutable($withPhpConfig);
|
||||
}
|
||||
@@ -210,7 +201,19 @@ final class CommandHelper
|
||||
}
|
||||
}
|
||||
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs);
|
||||
$phpizePath = null;
|
||||
if ($input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) {
|
||||
$phpizePathOption = $input->getOption(self::OPTION_WITH_PHPIZE_PATH);
|
||||
if (is_string($phpizePathOption) && trim($phpizePathOption) !== '') {
|
||||
if (Platform::isWindows()) {
|
||||
throw new InvalidArgumentException('The --with-phpize-path=/path/to/phpize cannot be used on Windows.');
|
||||
}
|
||||
|
||||
$phpizePath = new PhpizePath($phpizePathOption);
|
||||
}
|
||||
}
|
||||
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs, $phpizePath);
|
||||
|
||||
if (PiePlatform::isRunningStaticPhp()) {
|
||||
$io->write(sprintf('<info>You are running a PIE Static PHP %s build</info>', PHP_VERSION));
|
||||
@@ -264,18 +267,6 @@ final class CommandHelper
|
||||
|| ! $input->getOption(self::OPTION_SUPPRESS_BUILD_TOOLS_CHECK);
|
||||
}
|
||||
|
||||
public static function determinePhpizePathFromInputs(InputInterface $input): PhpizePath|null
|
||||
{
|
||||
if ($input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) {
|
||||
$phpizePathOption = (string) $input->getOption(self::OPTION_WITH_PHPIZE_PATH);
|
||||
if (trim($phpizePathOption) !== '') {
|
||||
return new PhpizePath($phpizePathOption);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function requestedNameAndVersionPair(InputInterface $input): RequestedPackageAndVersion
|
||||
{
|
||||
$requestedPackageString = $input->getArgument(self::ARG_REQUESTED_PACKAGE_AND_VERSION);
|
||||
|
||||
@@ -74,7 +74,6 @@ final class DownloadCommand extends Command
|
||||
$requestedNameAndVersion,
|
||||
PieOperation::Download,
|
||||
[], // Configure options are not needed for download only
|
||||
null,
|
||||
false, // setting up INI not needed for download
|
||||
),
|
||||
);
|
||||
|
||||
@@ -79,7 +79,6 @@ final class InfoCommand extends Command
|
||||
$requestedNameAndVersion,
|
||||
PieOperation::Resolve,
|
||||
[], // Configure options are not needed for resolve only
|
||||
null,
|
||||
false, // setting up INI not needed for info
|
||||
),
|
||||
);
|
||||
|
||||
@@ -98,7 +98,6 @@ final class InstallCommand extends Command
|
||||
$requestedNameAndVersion,
|
||||
PieOperation::Resolve,
|
||||
[], // Configure options are not needed for resolve only
|
||||
null,
|
||||
false, // setting up INI not needed for resolve step
|
||||
),
|
||||
);
|
||||
@@ -140,7 +139,6 @@ final class InstallCommand extends Command
|
||||
$requestedNameAndVersion,
|
||||
PieOperation::Install,
|
||||
$configureOptionsValues,
|
||||
CommandHelper::determinePhpizePathFromInputs($input),
|
||||
CommandHelper::determineAttemptToSetupIniFile($input),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -91,7 +91,6 @@ final class UninstallCommand extends Command
|
||||
$requestedPackageAndVersionToRemove,
|
||||
PieOperation::Uninstall,
|
||||
[], // Configure options are not needed for uninstall
|
||||
null,
|
||||
true,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -55,7 +55,6 @@ class InstallAndBuildProcess
|
||||
$composerRequest->targetPlatform,
|
||||
$composerRequest->configureOptions,
|
||||
$io,
|
||||
$composerRequest->phpizePath,
|
||||
);
|
||||
|
||||
$this->installedJsonMetadata->addBuildMetadata(
|
||||
|
||||
@@ -76,7 +76,7 @@ class InstalledJsonMetadata
|
||||
$composer,
|
||||
$composerPackage,
|
||||
MetadataKey::PhpizeBinary,
|
||||
$composerRequest->phpizePath->phpizeBinaryPath ?? null,
|
||||
$composerRequest->targetPlatform->phpizePath->phpizeBinaryPath ?? null,
|
||||
);
|
||||
|
||||
$this->addPieMetadata(
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace Php\Pie\ComposerIntegration;
|
||||
|
||||
use Composer\IO\IOInterface;
|
||||
use Php\Pie\DependencyResolver\RequestedPackageAndVersion;
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
use Php\Pie\Platform\TargetPlatform;
|
||||
|
||||
/**
|
||||
@@ -23,7 +22,6 @@ final class PieComposerRequest
|
||||
public readonly RequestedPackageAndVersion $requestedPackage,
|
||||
public readonly PieOperation $operation,
|
||||
public readonly array $configureOptions,
|
||||
public readonly PhpizePath|null $phpizePath,
|
||||
public readonly bool $attemptToSetupIniFile,
|
||||
) {
|
||||
}
|
||||
@@ -42,7 +40,6 @@ final class PieComposerRequest
|
||||
new RequestedPackageAndVersion('null/null', null),
|
||||
PieOperation::Resolve,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Php\Pie\Platform;
|
||||
|
||||
use Fidry\CpuCoreCounter\CpuCoreCounter;
|
||||
use Php\Pie\Platform\TargetPhp\PhpBinaryPath;
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
|
||||
use function array_key_exists;
|
||||
use function explode;
|
||||
@@ -31,6 +32,7 @@ class TargetPlatform
|
||||
public readonly ThreadSafetyMode $threadSafety,
|
||||
public readonly int $makeParallelJobs,
|
||||
public readonly WindowsCompiler|null $windowsCompiler,
|
||||
public readonly PhpizePath|null $phpizePath,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -48,7 +50,7 @@ class TargetPlatform
|
||||
return function_exists('posix_getuid') && posix_getuid() === 0;
|
||||
}
|
||||
|
||||
public static function fromPhpBinaryPath(PhpBinaryPath $phpBinaryPath, int|null $makeParallelJobs): self
|
||||
public static function fromPhpBinaryPath(PhpBinaryPath $phpBinaryPath, int|null $makeParallelJobs, PhpizePath|null $phpizePath): self
|
||||
{
|
||||
$os = $phpBinaryPath->operatingSystem();
|
||||
$osFamily = $phpBinaryPath->operatingSystemFamily();
|
||||
@@ -133,6 +135,7 @@ class TargetPlatform
|
||||
$threadSafety,
|
||||
$makeParallelJobs,
|
||||
$windowsCompiler,
|
||||
$phpizePath,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class BinaryBuildToolFinder
|
||||
return is_array($this->tool) ? implode('/', $this->tool) : $this->tool;
|
||||
}
|
||||
|
||||
public function check(): bool
|
||||
public function check(TargetPlatform $targetPlatform): bool
|
||||
{
|
||||
$tools = is_array($this->tool) ? $this->tool : [$this->tool];
|
||||
|
||||
|
||||
@@ -90,7 +90,6 @@ class CheckAllBuildTools
|
||||
],
|
||||
),
|
||||
new PhpizeBuildToolFinder(
|
||||
'phpize',
|
||||
[
|
||||
PackageManager::Apt->value => 'php-dev',
|
||||
PackageManager::Apk->value => 'php{major}{minor}-dev',
|
||||
@@ -117,7 +116,7 @@ class CheckAllBuildTools
|
||||
$allFound = true;
|
||||
|
||||
foreach ($this->buildTools as $buildTool) {
|
||||
if ($buildTool->check() !== false) {
|
||||
if ($buildTool->check($targetPlatform) !== false) {
|
||||
$io->write('Build tool ' . $buildTool->toolNames() . ' is installed.', verbosity: IOInterface::VERY_VERBOSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5,18 +5,43 @@ declare(strict_types=1);
|
||||
namespace Php\Pie\SelfManage\BuildTools;
|
||||
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
use Php\Pie\Platform\TargetPlatform;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
use function file_exists;
|
||||
use function is_array;
|
||||
use function is_executable;
|
||||
|
||||
/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
|
||||
class PhpizeBuildToolFinder extends BinaryBuildToolFinder
|
||||
{
|
||||
public function check(): bool
|
||||
/** @param array<PackageManager::*, non-empty-string|null> $packageManagerPackages */
|
||||
public function __construct(
|
||||
array $packageManagerPackages,
|
||||
) {
|
||||
parent::__construct('phpize', $packageManagerPackages);
|
||||
}
|
||||
|
||||
public function check(TargetPlatform $targetPlatform): bool
|
||||
{
|
||||
$tools = is_array($this->tool) ? $this->tool : [$this->tool];
|
||||
|
||||
if ($targetPlatform->phpizePath !== null) {
|
||||
$tools[] = $targetPlatform->phpizePath->phpizeBinaryPath;
|
||||
}
|
||||
|
||||
try {
|
||||
$tools[] = PhpizePath::guessFrom($targetPlatform->phpBinaryPath)->phpizeBinaryPath;
|
||||
} catch (RuntimeException) {
|
||||
// intentionally ignored - just don't try to use the guessed phpize path
|
||||
}
|
||||
|
||||
foreach ($tools as $tool) {
|
||||
if (file_exists($tool) && is_executable($tool) && PhpizePath::looksLikeValidPhpize($tool)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$foundTool = (new ExecutableFinder())->find($tool);
|
||||
|
||||
if ($foundTool !== null && PhpizePath::looksLikeValidPhpize($foundTool)) {
|
||||
|
||||
3
test/assets/phpize/bad/phpize
Executable file
3
test/assets/phpize/bad/phpize
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "Haha! I am not really phpize."
|
||||
5
test/assets/phpize/good/php
Executable file
5
test/assets/phpize/good/php
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "PHP"
|
||||
|
||||
exit 0
|
||||
9
test/assets/phpize/good/phpize
Executable file
9
test/assets/phpize/good/phpize
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "Configuring for:"
|
||||
echo "PHP Version: 8.4"
|
||||
echo "PHP Api Version: 20240924"
|
||||
echo "Zend Module Api No: 20240924"
|
||||
echo "Zend Extension Api No: 420240924"
|
||||
|
||||
exit 0
|
||||
@@ -28,6 +28,7 @@ $packageNames = array_map(
|
||||
TargetPlatform::fromPhpBinaryPath(
|
||||
$phpBinaryPath,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
)
|
||||
->getPackages(),
|
||||
|
||||
@@ -59,10 +59,9 @@ final class UnixBuildTest extends TestCase
|
||||
$unixBuilder = new UnixBuild();
|
||||
$builtBinary = $unixBuilder->__invoke(
|
||||
$downloadedPackage,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
self::assertNotEmpty($builtBinary);
|
||||
@@ -116,10 +115,9 @@ final class UnixBuildTest extends TestCase
|
||||
try {
|
||||
$unixBuilder->__invoke(
|
||||
$downloadedPackage,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
} finally {
|
||||
(new Process(['make', 'clean'], $downloadedPackage->extractedSourcePath))->mustRun();
|
||||
@@ -152,10 +150,9 @@ final class UnixBuildTest extends TestCase
|
||||
$unixBuilder = new UnixBuild();
|
||||
$builtBinary = $unixBuilder->__invoke(
|
||||
$downloadedPackage,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
self::assertNotEmpty($builtBinary);
|
||||
@@ -199,7 +196,7 @@ final class UnixBuildTest extends TestCase
|
||||
self::TEST_PREBUILT_PATH_INVALID,
|
||||
);
|
||||
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null);
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null);
|
||||
$unixBuilder = new UnixBuild();
|
||||
|
||||
$this->expectException(ExtensionBinaryNotFound::class);
|
||||
@@ -209,7 +206,6 @@ final class UnixBuildTest extends TestCase
|
||||
$targetPlatform,
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -234,7 +230,7 @@ final class UnixBuildTest extends TestCase
|
||||
self::TEST_PREBUILT_PATH_VALID,
|
||||
);
|
||||
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null);
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null);
|
||||
$unixBuilder = new UnixBuild();
|
||||
|
||||
$binaryFile = $unixBuilder->__invoke(
|
||||
@@ -242,7 +238,6 @@ final class UnixBuildTest extends TestCase
|
||||
$targetPlatform,
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
self::assertSame('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', $binaryFile->checksum);
|
||||
@@ -280,10 +275,9 @@ final class UnixBuildTest extends TestCase
|
||||
$unixBuilder = new UnixBuild();
|
||||
$unixBuilder->__invoke(
|
||||
$downloadedPackage,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
$outputString = $output->getOutput();
|
||||
@@ -322,10 +316,9 @@ final class UnixBuildTest extends TestCase
|
||||
$unixBuilder = new UnixBuild();
|
||||
$unixBuilder->__invoke(
|
||||
$downloadedPackage,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
$outputString = $output->getOutput();
|
||||
|
||||
@@ -82,6 +82,7 @@ final class ShowCommandTest extends TestCase
|
||||
$phpConfig,
|
||||
),
|
||||
1,
|
||||
null,
|
||||
),
|
||||
)
|
||||
->addRequire(self::TEST_PACKAGE, '^2.0');
|
||||
@@ -129,6 +130,7 @@ final class ShowCommandTest extends TestCase
|
||||
$phpConfig,
|
||||
),
|
||||
1,
|
||||
null,
|
||||
),
|
||||
)
|
||||
->addRequire(self::TEST_PACKAGE, '^2.0,<=2.0.3');
|
||||
@@ -176,6 +178,7 @@ final class ShowCommandTest extends TestCase
|
||||
$phpConfig,
|
||||
),
|
||||
1,
|
||||
null,
|
||||
),
|
||||
)
|
||||
->addRequire(self::TEST_PACKAGE, '^2.0,<2.0.3');
|
||||
|
||||
@@ -71,7 +71,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
$container = Container::factory();
|
||||
$resolve = $container->get(DependencyResolver::class);
|
||||
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null);
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null);
|
||||
$requestedPackageAndVersion = new RequestedPackageAndVersion(
|
||||
'asgrim/example-pie-extension',
|
||||
$requestedVersion,
|
||||
@@ -86,7 +86,6 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
$requestedPackageAndVersion,
|
||||
PieOperation::Resolve,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -44,6 +44,7 @@ final class GithubPackageReleaseAssetsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VS16,
|
||||
null,
|
||||
);
|
||||
|
||||
$package = new Package(
|
||||
|
||||
@@ -85,7 +85,7 @@ final class UnixInstallTest extends TestCase
|
||||
}
|
||||
|
||||
$output = new BufferIO();
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null);
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null, null);
|
||||
$extensionPath = $targetPlatform->phpBinaryPath->extensionPath();
|
||||
|
||||
$composerPackage = $this->createMock(CompletePackageInterface::class);
|
||||
@@ -110,7 +110,6 @@ final class UnixInstallTest extends TestCase
|
||||
$targetPlatform,
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
$installedSharedObject = (new UnixInstall(new SetupIniFile(new PickBestSetupIniApproach([]))))->__invoke(
|
||||
@@ -147,7 +146,7 @@ final class UnixInstallTest extends TestCase
|
||||
}
|
||||
|
||||
$output = new BufferIO();
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null);
|
||||
$targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null, null);
|
||||
$extensionPath = $targetPlatform->phpBinaryPath->extensionPath();
|
||||
|
||||
// First build it (otherwise the test assets would need to have a binary for every test platform...)
|
||||
@@ -171,7 +170,6 @@ final class UnixInstallTest extends TestCase
|
||||
$targetPlatform,
|
||||
['--enable-pie_test_ext'],
|
||||
$output,
|
||||
null,
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,7 @@ final class WindowsInstallTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VS16,
|
||||
null,
|
||||
);
|
||||
$phpPath = dirname($targetPlatform->phpBinaryPath->phpBinaryPath);
|
||||
$extensionPath = $targetPlatform->phpBinaryPath->extensionPath();
|
||||
|
||||
@@ -101,6 +101,7 @@ final class BundledPhpExtensionsRepositoryTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ final class InstallAndBuildProcessTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.0'),
|
||||
PieOperation::Download,
|
||||
['--foo', '--bar="yes"'],
|
||||
null,
|
||||
false,
|
||||
);
|
||||
$composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3');
|
||||
@@ -103,11 +103,11 @@ final class InstallAndBuildProcessTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.0'),
|
||||
PieOperation::Build,
|
||||
['--foo', '--bar="yes"'],
|
||||
null,
|
||||
false,
|
||||
);
|
||||
$composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3');
|
||||
@@ -147,11 +147,11 @@ final class InstallAndBuildProcessTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.0'),
|
||||
PieOperation::Install,
|
||||
['--foo', '--bar="yes"'],
|
||||
null,
|
||||
false,
|
||||
);
|
||||
$composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3');
|
||||
|
||||
@@ -60,11 +60,11 @@ final class InstalledJsonMetadataTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.0'),
|
||||
PieOperation::Build,
|
||||
['--foo', '--bar="yes"'],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
clone $package,
|
||||
@@ -99,11 +99,11 @@ final class InstalledJsonMetadataTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
new PhpizePath('/path/to/phpize'),
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.0'),
|
||||
PieOperation::Build,
|
||||
['--foo', '--bar="yes"'],
|
||||
new PhpizePath('/path/to/phpize'),
|
||||
false,
|
||||
),
|
||||
clone $package,
|
||||
|
||||
@@ -78,11 +78,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
);
|
||||
@@ -120,11 +120,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -162,11 +162,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -204,11 +204,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -246,11 +246,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -301,11 +301,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -361,11 +361,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -422,11 +422,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -483,11 +483,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
@@ -544,11 +544,11 @@ final class OverrideDownloadUrlInstallListenerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -71,11 +71,11 @@ final class RemoveUnrelatedInstallOperationsTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('foo/bar', '^1.1'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
);
|
||||
@@ -107,11 +107,11 @@ final class RemoveUnrelatedInstallOperationsTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
),
|
||||
new RequestedPackageAndVersion('bat/baz', '^3.2'),
|
||||
PieOperation::Install,
|
||||
[],
|
||||
null,
|
||||
false,
|
||||
),
|
||||
))($installerEvent);
|
||||
|
||||
@@ -66,6 +66,7 @@ final class VersionSelectorFactoryTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$package = (new ResolveDependencyWithComposer(
|
||||
@@ -120,6 +121,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->expectException(UnableToResolveRequirement::class);
|
||||
@@ -159,6 +161,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->expectException(UnableToResolveRequirement::class);
|
||||
@@ -211,6 +214,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->expectException(IncompatibleThreadSafetyMode::class);
|
||||
@@ -260,6 +264,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->expectException(IncompatibleThreadSafetyMode::class);
|
||||
@@ -309,6 +314,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->expectException(IncompatibleOperatingSystemFamily::class);
|
||||
@@ -358,6 +364,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->expectException(IncompatibleOperatingSystemFamily::class);
|
||||
@@ -397,6 +404,7 @@ final class ResolveDependencyWithComposerTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$package = (new ResolveDependencyWithComposer(
|
||||
|
||||
@@ -52,6 +52,7 @@ final class DownloadUrlMethodTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC15,
|
||||
null,
|
||||
);
|
||||
|
||||
$downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform);
|
||||
@@ -88,6 +89,7 @@ final class DownloadUrlMethodTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform);
|
||||
@@ -133,6 +135,7 @@ final class DownloadUrlMethodTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform);
|
||||
@@ -170,6 +173,7 @@ final class DownloadUrlMethodTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform);
|
||||
@@ -208,6 +212,7 @@ final class DownloadUrlMethodTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform);
|
||||
|
||||
@@ -43,6 +43,7 @@ final class CouldNotFindReleaseAssetTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
$package,
|
||||
DownloadUrlMethod::PrePackagedSourceDownload,
|
||||
@@ -72,6 +73,7 @@ final class CouldNotFindReleaseAssetTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VS17,
|
||||
null,
|
||||
),
|
||||
$package,
|
||||
DownloadUrlMethod::WindowsBinaryDownload,
|
||||
@@ -108,6 +110,7 @@ final class CouldNotFindReleaseAssetTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
));
|
||||
|
||||
self::assertSame('Could not determine Windows Compiler for PHP ' . $phpBinary->version() . ' on NonWindows', $exception->getMessage());
|
||||
|
||||
@@ -45,6 +45,7 @@ final class GithubPackageReleaseAssetsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC14,
|
||||
null,
|
||||
);
|
||||
|
||||
$httpDownloaderResponse = $this->createMock(Response::class);
|
||||
@@ -111,6 +112,7 @@ final class GithubPackageReleaseAssetsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC14,
|
||||
null,
|
||||
);
|
||||
|
||||
$httpDownloaderResponse = $this->createMock(Response::class);
|
||||
@@ -172,6 +174,7 @@ final class GithubPackageReleaseAssetsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC14,
|
||||
null,
|
||||
);
|
||||
|
||||
$e = new TransportException('not found', 404);
|
||||
|
||||
@@ -59,6 +59,7 @@ final class CheckAndAddExtensionToIniIfNeededTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
|
||||
|
||||
@@ -57,6 +57,7 @@ final class DockerPhpExtEnableTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
|
||||
|
||||
@@ -70,6 +70,7 @@ final class OndrejPhpenmodTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
|
||||
|
||||
@@ -36,6 +36,7 @@ final class PickBestSetupIniApproachTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ final class PreCheckExtensionAlreadyLoadedTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
|
||||
|
||||
@@ -104,6 +104,7 @@ final class RemoveIniEntryWithFileGetContentsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$affectedFiles = (new RemoveIniEntryWithFileGetContents())(
|
||||
@@ -156,6 +157,7 @@ final class RemoveIniEntryWithFileGetContentsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
@@ -202,6 +204,7 @@ final class RemoveIniEntryWithFileGetContentsTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$affectedFiles = (new RemoveIniEntryWithFileGetContents())(
|
||||
|
||||
@@ -64,6 +64,7 @@ final class StandardAdditionalPhpIniDirectoryTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
|
||||
|
||||
@@ -57,6 +57,7 @@ final class StandardSinglePhpIniTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
|
||||
|
||||
@@ -36,6 +36,7 @@ final class PrePackagedBinaryAssetNameTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$libc = $targetPlatform->libcFlavour();
|
||||
@@ -74,6 +75,7 @@ final class PrePackagedBinaryAssetNameTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$libc = $targetPlatform->libcFlavour();
|
||||
@@ -110,6 +112,7 @@ final class PrePackagedBinaryAssetNameTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
|
||||
$libc = $targetPlatform->libcFlavour();
|
||||
|
||||
@@ -8,6 +8,7 @@ use Php\Pie\Platform\Architecture;
|
||||
use Php\Pie\Platform\OperatingSystem;
|
||||
use Php\Pie\Platform\OperatingSystemFamily;
|
||||
use Php\Pie\Platform\TargetPhp\PhpBinaryPath;
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
use Php\Pie\Platform\TargetPlatform;
|
||||
use Php\Pie\Platform\ThreadSafetyMode;
|
||||
use Php\Pie\Platform\WindowsCompiler;
|
||||
@@ -54,7 +55,7 @@ Zend Extension Build => API420230831,TS,VS16
|
||||
PHP Extension Build => API20230831,TS,VS16
|
||||
TEXT);
|
||||
|
||||
$platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null);
|
||||
$platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null, null);
|
||||
|
||||
self::assertSame(OperatingSystem::Windows, $platform->operatingSystem);
|
||||
self::assertSame(OperatingSystemFamily::Windows, $platform->operatingSystemFamily);
|
||||
@@ -99,7 +100,7 @@ Debug Build => no
|
||||
Thread Safety => disabled
|
||||
TEXT);
|
||||
|
||||
$platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null);
|
||||
$platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null, null);
|
||||
|
||||
self::assertSame(OperatingSystem::NonWindows, $platform->operatingSystem);
|
||||
self::assertSame(OperatingSystemFamily::Linux, $platform->operatingSystemFamily);
|
||||
@@ -111,8 +112,52 @@ TEXT);
|
||||
public function testLibcFlavourIsMemoized(): void
|
||||
{
|
||||
self::assertSame(
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null)->libcFlavour(),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null)->libcFlavour(),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null)->libcFlavour(),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null)->libcFlavour(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpizePathCanBeSet(): void
|
||||
{
|
||||
$phpBinaryPath = $this->createMock(PhpBinaryPath::class);
|
||||
$phpBinaryPath->expects(self::any())
|
||||
->method('operatingSystem')
|
||||
->willReturn(OperatingSystem::NonWindows);
|
||||
$phpBinaryPath->expects(self::any())
|
||||
->method('operatingSystemFamily')
|
||||
->willReturn(OperatingSystemFamily::Linux);
|
||||
$phpBinaryPath->expects(self::any())
|
||||
->method('machineType')
|
||||
->willReturn(Architecture::x86_64);
|
||||
$phpBinaryPath->expects(self::any())
|
||||
->method('phpinfo')
|
||||
->willReturn(<<<'TEXT'
|
||||
phpinfo()
|
||||
PHP Version => 8.3.6
|
||||
|
||||
System => Linux myhostname 1.2.3 Ubuntu x86_64
|
||||
Build Date => Apr 11 2024 20:23:38
|
||||
Build System => Linux
|
||||
Server API => Command Line Interface
|
||||
Virtual Directory Support => disabled
|
||||
Configuration File (php.ini) Path => /etc/php/8.3/cli
|
||||
Loaded Configuration File => /etc/php/8.3/cli/php.ini
|
||||
Scan this dir for additional .ini files => /etc/php/8.3/cli/conf.d
|
||||
Additional .ini files parsed => (none)
|
||||
PHP API => 20230831
|
||||
PHP Extension => 20230831
|
||||
Zend Extension => 420230831
|
||||
Zend Extension Build => API420230831,NTS
|
||||
PHP Extension Build => API20230831,NTS
|
||||
Debug Build => no
|
||||
Thread Safety => disabled
|
||||
TEXT);
|
||||
|
||||
self::assertSame(
|
||||
'/path/to/phpize',
|
||||
TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null, new PhpizePath('/path/to/phpize'))
|
||||
->phpizePath
|
||||
?->phpizeBinaryPath,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ final class WindowsExtensionAssetNameTest extends TestCase
|
||||
ThreadSafetyMode::ThreadSafe,
|
||||
1,
|
||||
WindowsCompiler::VC14,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->phpVersion = $this->platform->phpBinaryPath->majorMinorVersion();
|
||||
|
||||
@@ -9,29 +9,39 @@ use Php\Pie\Platform\TargetPlatform;
|
||||
use Php\Pie\SelfManage\BuildTools\BinaryBuildToolFinder;
|
||||
use Php\Pie\SelfManage\BuildTools\PackageManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(BinaryBuildToolFinder::class)]
|
||||
final class BinaryBuildToolFinderTest extends TestCase
|
||||
{
|
||||
private TargetPlatform&MockObject $targetPlatform;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->targetPlatform = $this->createMock(TargetPlatform::class);
|
||||
}
|
||||
|
||||
public function testCheckFailsToFindTool(): void
|
||||
{
|
||||
self::assertFalse((new BinaryBuildToolFinder('this-should-not-be-anything-in-path', []))->check());
|
||||
self::assertFalse((new BinaryBuildToolFinder('this-should-not-be-anything-in-path', []))->check($this->targetPlatform));
|
||||
}
|
||||
|
||||
public function testCheckFailsToFindToolInList(): void
|
||||
{
|
||||
self::assertFalse((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path-1', 'this-should-not-be-anything-in-path-2'], []))->check());
|
||||
self::assertFalse((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path-1', 'this-should-not-be-anything-in-path-2'], []))->check($this->targetPlatform));
|
||||
}
|
||||
|
||||
public function testCheckFindsTool(): void
|
||||
{
|
||||
self::assertTrue((new BinaryBuildToolFinder('echo', []))->check());
|
||||
self::assertTrue((new BinaryBuildToolFinder('echo', []))->check($this->targetPlatform));
|
||||
}
|
||||
|
||||
public function testCheckFindsToolFromList(): void
|
||||
{
|
||||
self::assertTrue((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path', 'echo'], []))->check());
|
||||
self::assertTrue((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path', 'echo'], []))->check($this->targetPlatform));
|
||||
}
|
||||
|
||||
public function testPackageNameIsNullWhenNoPackageConfiguredForPackageManager(): void
|
||||
@@ -40,7 +50,7 @@ final class BinaryBuildToolFinderTest extends TestCase
|
||||
(new BinaryBuildToolFinder('a', []))
|
||||
->packageNameFor(
|
||||
PackageManager::Test,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -51,7 +61,7 @@ final class BinaryBuildToolFinderTest extends TestCase
|
||||
(new BinaryBuildToolFinder('a', [PackageManager::Test->value => null]))
|
||||
->packageNameFor(
|
||||
PackageManager::Test,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -63,7 +73,7 @@ final class BinaryBuildToolFinderTest extends TestCase
|
||||
(new BinaryBuildToolFinder('a', [PackageManager::Test->value => 'the-package']))
|
||||
->packageNameFor(
|
||||
PackageManager::Test,
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null),
|
||||
TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -77,7 +87,7 @@ final class BinaryBuildToolFinderTest extends TestCase
|
||||
(new BinaryBuildToolFinder('a', [PackageManager::Test->value => 'php{major}{minor}-dev']))
|
||||
->packageNameFor(
|
||||
PackageManager::Test,
|
||||
TargetPlatform::fromPhpBinaryPath($phpBinary, null),
|
||||
TargetPlatform::fromPhpBinaryPath($phpBinary, null, null),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ final class CheckAllBuildToolsTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
false,
|
||||
);
|
||||
@@ -70,6 +71,7 @@ final class CheckAllBuildToolsTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
false,
|
||||
);
|
||||
@@ -100,6 +102,7 @@ final class CheckAllBuildToolsTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
false,
|
||||
);
|
||||
@@ -130,6 +133,7 @@ final class CheckAllBuildToolsTest extends TestCase
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
true,
|
||||
);
|
||||
|
||||
105
test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php
Normal file
105
test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Php\PieUnitTest\SelfManage\BuildTools;
|
||||
|
||||
use Php\Pie\Platform\Architecture;
|
||||
use Php\Pie\Platform\OperatingSystem;
|
||||
use Php\Pie\Platform\OperatingSystemFamily;
|
||||
use Php\Pie\Platform\TargetPhp\PhpBinaryPath;
|
||||
use Php\Pie\Platform\TargetPhp\PhpizePath;
|
||||
use Php\Pie\Platform\TargetPlatform;
|
||||
use Php\Pie\Platform\ThreadSafetyMode;
|
||||
use Php\Pie\SelfManage\BuildTools\PhpizeBuildToolFinder;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use function getenv;
|
||||
use function putenv;
|
||||
use function realpath;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
#[RequiresOperatingSystemFamily('Linux')]
|
||||
#[CoversClass(PhpizeBuildToolFinder::class)]
|
||||
final class PhpizeBuildToolFinderTest extends TestCase
|
||||
{
|
||||
private const GOOD_PHPIZE_PATH = __DIR__ . '/../../../assets/phpize/good';
|
||||
private const BAD_PHPIZE_PATH = __DIR__ . '/../../../assets/phpize/bad';
|
||||
|
||||
public function testCheckWithPhpizeInPath(): void
|
||||
{
|
||||
$oldPath = getenv('PATH');
|
||||
putenv('PATH=' . realpath(self::GOOD_PHPIZE_PATH));
|
||||
|
||||
$mockPhpBinary = $this->createMock(PhpBinaryPath::class);
|
||||
(fn () => $this->phpBinaryPath = '/path/to/php')
|
||||
->bindTo($mockPhpBinary, PhpBinaryPath::class)();
|
||||
|
||||
self::assertTrue((new PhpizeBuildToolFinder([]))->check(new TargetPlatform(
|
||||
OperatingSystem::NonWindows,
|
||||
OperatingSystemFamily::Linux,
|
||||
$mockPhpBinary,
|
||||
Architecture::x86_64,
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
)));
|
||||
|
||||
putenv('PATH=' . $oldPath);
|
||||
}
|
||||
|
||||
public function testCheckWithPhpizeFromTargetPlatform(): void
|
||||
{
|
||||
$oldPath = getenv('PATH');
|
||||
putenv('PATH=' . realpath(self::BAD_PHPIZE_PATH));
|
||||
|
||||
$mockPhpBinary = $this->createMock(PhpBinaryPath::class);
|
||||
(fn () => $this->phpBinaryPath = '/path/to/php')
|
||||
->bindTo($mockPhpBinary, PhpBinaryPath::class)();
|
||||
|
||||
$goodPhpize = realpath(self::GOOD_PHPIZE_PATH . DIRECTORY_SEPARATOR . 'phpize');
|
||||
self::assertNotFalse($goodPhpize);
|
||||
|
||||
self::assertTrue((new PhpizeBuildToolFinder([]))->check(new TargetPlatform(
|
||||
OperatingSystem::NonWindows,
|
||||
OperatingSystemFamily::Linux,
|
||||
$mockPhpBinary,
|
||||
Architecture::x86_64,
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
new PhpizePath($goodPhpize),
|
||||
)));
|
||||
|
||||
putenv('PATH=' . $oldPath);
|
||||
}
|
||||
|
||||
public function testCheckWithPhpizeGuessed(): void
|
||||
{
|
||||
$oldPath = getenv('PATH');
|
||||
putenv('PATH=' . realpath(self::BAD_PHPIZE_PATH));
|
||||
|
||||
$mockPhpBinary = $this->createMock(PhpBinaryPath::class);
|
||||
$mockPhpBinary->method('phpApiVersion')->willReturn('20240924');
|
||||
$phpPath = realpath(self::GOOD_PHPIZE_PATH . DIRECTORY_SEPARATOR . 'php');
|
||||
(fn () => $this->phpBinaryPath = $phpPath)
|
||||
->bindTo($mockPhpBinary, PhpBinaryPath::class)();
|
||||
|
||||
self::assertTrue((new PhpizeBuildToolFinder([]))->check(new TargetPlatform(
|
||||
OperatingSystem::NonWindows,
|
||||
OperatingSystemFamily::Linux,
|
||||
$mockPhpBinary,
|
||||
Architecture::x86_64,
|
||||
ThreadSafetyMode::NonThreadSafe,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
)));
|
||||
|
||||
putenv('PATH=' . $oldPath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user