mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
95 lines
2.5 KiB
PHP
95 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\Tests\builder;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use SPC\builder\BuilderProvider;
|
|
use SPC\builder\Extension;
|
|
use SPC\util\AttributeMapper;
|
|
use SPC\util\DependencyUtil;
|
|
use Symfony\Component\Console\Input\ArgvInput;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class ExtensionTest extends TestCase
|
|
{
|
|
private Extension $extension;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$builder = BuilderProvider::makeBuilderByInput(new ArgvInput());
|
|
[$extensions, $libs] = DependencyUtil::getExtsAndLibs(['mbregex']);
|
|
$builder->proveLibs($libs);
|
|
foreach ($extensions as $extension) {
|
|
$class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
|
|
$ext = new $class($extension, $builder);
|
|
$builder->addExt($ext);
|
|
}
|
|
foreach ($builder->getExts() as $ext) {
|
|
$ext->checkDependency();
|
|
}
|
|
$this->extension = $builder->getExt('mbregex');
|
|
}
|
|
|
|
public function testPatches()
|
|
{
|
|
$this->assertFalse($this->extension->patchBeforeBuildconf());
|
|
$this->assertFalse($this->extension->patchBeforeConfigure());
|
|
$this->assertFalse($this->extension->patchBeforeMake());
|
|
}
|
|
|
|
public function testGetExtensionDependency()
|
|
{
|
|
$this->assertEquals('mbstring', current($this->extension->getExtensionDependency())->getName());
|
|
}
|
|
|
|
public function testGetWindowsConfigureArg()
|
|
{
|
|
$this->assertEquals('', $this->extension->getWindowsConfigureArg());
|
|
}
|
|
|
|
public function testGetConfigureArg()
|
|
{
|
|
$this->assertEquals('', $this->extension->getUnixConfigureArg());
|
|
}
|
|
|
|
public function testGetExtVersion()
|
|
{
|
|
// only swoole has version, we cannot test it
|
|
$this->assertEquals(null, $this->extension->getExtVersion());
|
|
}
|
|
|
|
public function testGetDistName()
|
|
{
|
|
$this->assertEquals('mbregex', $this->extension->getName());
|
|
}
|
|
|
|
public function testRunCliCheckWindows()
|
|
{
|
|
if (is_unix()) {
|
|
$this->markTestSkipped('This test is for Windows only');
|
|
} else {
|
|
$this->extension->runCliCheckWindows();
|
|
$this->assertTrue(true);
|
|
}
|
|
}
|
|
|
|
public function testGetName()
|
|
{
|
|
$this->assertEquals('mbregex', $this->extension->getName());
|
|
}
|
|
|
|
public function testGetUnixConfigureArg()
|
|
{
|
|
$this->assertEquals('', $this->extension->getUnixConfigureArg());
|
|
}
|
|
|
|
public function testGetEnableArg()
|
|
{
|
|
$this->assertEquals('', $this->extension->getEnableArg());
|
|
}
|
|
}
|