mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Fix phpstan, add more phpunit test
This commit is contained in:
parent
c841ef5b9a
commit
dc9d6703bc
@ -4,7 +4,6 @@ parameters:
|
||||
paths:
|
||||
- ./src/
|
||||
ignoreErrors:
|
||||
- '#Constant .* not found#'
|
||||
- '#Unsafe usage of new static#'
|
||||
- '#class Fiber#'
|
||||
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
||||
@ -15,4 +14,4 @@ parameters:
|
||||
analyseAndScan:
|
||||
- ./src/globals/ext-tests/swoole.php
|
||||
- ./src/globals/ext-tests/swoole.phpt
|
||||
- ./src/globals/test-extensions.php
|
||||
- ./src/globals/test-extensions.php
|
||||
|
||||
5
phpunit.xml.dist
Normal file
5
phpunit.xml.dist
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<phpunit
|
||||
bootstrap="tests/bootstrap.php"
|
||||
>
|
||||
</phpunit>
|
||||
28
tests/SPC/builder/BuilderProviderTest.php
Normal file
28
tests/SPC/builder/BuilderProviderTest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\Tests\builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\BuilderProvider;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class BuilderProviderTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
BuilderProvider::makeBuilderByInput(new ArgvInput());
|
||||
BuilderProvider::getBuilder();
|
||||
}
|
||||
|
||||
public function testMakeBuilderByInput(): void
|
||||
{
|
||||
$this->assertInstanceOf(BuilderBase::class, BuilderProvider::makeBuilderByInput(new ArgvInput()));
|
||||
$this->assertInstanceOf(BuilderBase::class, BuilderProvider::getBuilder());
|
||||
}
|
||||
}
|
||||
91
tests/SPC/builder/ExtensionTest.php
Normal file
91
tests/SPC/builder/ExtensionTest.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\Tests\builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use SPC\builder\BuilderProvider;
|
||||
use SPC\builder\Extension;
|
||||
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);
|
||||
$builder->proveExts($extensions);
|
||||
$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->markTestIncomplete('This test is for Windows only');
|
||||
} else {
|
||||
$this->extension->runCliCheckWindows();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetLibFilesString()
|
||||
{
|
||||
$this->assertStringEndsWith('libonig.a', $this->extension->getLibFilesString());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
5
tests/bootstrap.php
Normal file
5
tests/bootstrap.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../src/globals/internal-env.php';
|
||||
Loading…
x
Reference in New Issue
Block a user