diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91f92e5..23cfa69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,17 +11,23 @@ permissions: jobs: test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.4', '8.5'] steps: - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' - extensions: curl, zlib + php-version: ${{ matrix.php }} + extensions: curl, zlib, swoole coverage: pcov tools: composer:v2 - name: Validate composer.json run: composer validate --no-check-publish --no-check-lock + - name: Verify Swoole version + run: php -r 'if (version_compare(SWOOLE_VERSION, "6.0.0", "<")) { fwrite(STDERR, "Swoole >= 6.0 required\n"); exit(1); }' - name: Install dependencies run: composer update --prefer-dist --no-progress --no-interaction - name: PHPStan @@ -32,7 +38,7 @@ jobs: vendor/bin/phpunit --coverage-clover=build/coverage.xml --exclude-group network - name: Enforce coverage threshold env: - COVERAGE_MIN: '65' + COVERAGE_MIN: '70' run: | php -r ' $xml = simplexml_load_file("build/coverage.xml"); diff --git a/src/Stream/Stream.php b/src/Stream/Stream.php index 6ba3cb1..855656c 100644 --- a/src/Stream/Stream.php +++ b/src/Stream/Stream.php @@ -42,7 +42,7 @@ class Stream implements StreamInterface, Stringable */ public function __construct(protected string $stream = 'php://memory', protected string $mode = 'w+b') { - $this->resource = fopen($stream, $this->mode); + $this->resource = @fopen($stream, $this->mode); if (!$this->resource) { throw new RuntimeException("Unable to open stream: $stream with mode: $mode"); diff --git a/tests/request/SwooleServerRequestTest.php b/tests/request/SwooleServerRequestTest.php index 8594d99..5a73ff1 100644 --- a/tests/request/SwooleServerRequestTest.php +++ b/tests/request/SwooleServerRequestTest.php @@ -5,6 +5,7 @@ use FastD\Http\Request\SwooleServerRequest; use FastD\Http\Request\ServerRequest; use FastD\Http\Stream\Stream; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\TestCase; /** @@ -55,6 +56,7 @@ public function testCanInstantiate() /** * 验证SwooleServerRequest扩展了ServerRequest */ + #[AllowMockObjectsWithoutExpectations] public function testExtendsServerRequest() { // 由于SwooleServerRequest继承自ServerRequest,我们验证继承关系 @@ -149,6 +151,7 @@ public function testInheritedMethods() /** * 测试类的不可变性 - with方法应该返回新实例 */ + #[AllowMockObjectsWithoutExpectations] public function testImmutableWithMethods() { // 创建一个模拟的SwooleServerRequest实例(通过反射绕过Swoole依赖) diff --git a/tests/request/UploadedFileTest.php b/tests/request/UploadedFileTest.php index 40fee53..8475f99 100644 --- a/tests/request/UploadedFileTest.php +++ b/tests/request/UploadedFileTest.php @@ -3,6 +3,7 @@ declare(strict_types=1); use FastD\Http\Request\UploadedFile; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\TestCase; use Psr\Http\Message\StreamInterface; @@ -781,6 +782,7 @@ public function testVariousMediaTypes(): void // ===== 构造函数带Stream测试 ===== + #[AllowMockObjectsWithoutExpectations] public function testConstructorWithProvidedStream(): void { $mockStream = $this->createMock(StreamInterface::class);