mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
fix tests
This commit is contained in:
parent
72abd63b69
commit
81f359dbcf
@ -17,6 +17,8 @@ use SPC\toolchain\ToolchainManager;
|
|||||||
*/
|
*/
|
||||||
class SPCTarget
|
class SPCTarget
|
||||||
{
|
{
|
||||||
|
const array LIBC_LIST = ['musl', 'glibc'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether we link the C runtime in statically.
|
* Returns whether we link the C runtime in statically.
|
||||||
*/
|
*/
|
||||||
@ -107,7 +109,6 @@ class SPCTarget
|
|||||||
* Currently, we only support native building.
|
* Currently, we only support native building.
|
||||||
*
|
*
|
||||||
* @return 'BSD'|'Darwin'|'Linux'|'Windows'
|
* @return 'BSD'|'Darwin'|'Linux'|'Windows'
|
||||||
* @throws WrongUsageException
|
|
||||||
*/
|
*/
|
||||||
public static function getTargetOS(): string
|
public static function getTargetOS(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -85,19 +85,6 @@ final class SPCTargetTest extends TestBase
|
|||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider invalidTargetProvider
|
|
||||||
*/
|
|
||||||
public function testGetTargetOSWithInvalidTarget(string $target): void
|
|
||||||
{
|
|
||||||
putenv("SPC_TARGET={$target}");
|
|
||||||
|
|
||||||
$this->expectException(WrongUsageException::class);
|
|
||||||
$this->expectExceptionMessage('Cannot parse target.');
|
|
||||||
|
|
||||||
SPCTarget::getTargetOS();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLibcListConstant(): void
|
public function testLibcListConstant(): void
|
||||||
{
|
{
|
||||||
$this->assertIsArray(SPCTarget::LIBC_LIST);
|
$this->assertIsArray(SPCTarget::LIBC_LIST);
|
||||||
@ -117,22 +104,13 @@ final class SPCTargetTest extends TestBase
|
|||||||
public function targetOSProvider(): array
|
public function targetOSProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'linux-target' => ['linux-x86_64', 'Linux'],
|
'linux-target' => ['native-linux', 'Linux'],
|
||||||
'macos-target' => ['macos-x86_64', 'Darwin'],
|
'macos-target' => ['native-macos', 'Darwin'],
|
||||||
'windows-target' => ['windows-x86_64', 'Windows'],
|
'windows-target' => ['native-windows', 'Windows'],
|
||||||
'empty-target' => ['', PHP_OS_FAMILY],
|
'empty-target' => ['', PHP_OS_FAMILY],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidTargetProvider(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'invalid-target' => ['invalid-target'],
|
|
||||||
'unknown-target' => ['unknown-target'],
|
|
||||||
'mixed-target' => ['mixed-target'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function assertIsStringOrNull($value): void
|
private function assertIsStringOrNull($value): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(is_string($value) || is_null($value), 'Value must be string or null');
|
$this->assertTrue(is_string($value) || is_null($value), 'Value must be string or null');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user