Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/Stream/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions tests/request/SwooleServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -55,6 +56,7 @@ public function testCanInstantiate()
/**
* 验证SwooleServerRequest扩展了ServerRequest
*/
#[AllowMockObjectsWithoutExpectations]
public function testExtendsServerRequest()
{
// 由于SwooleServerRequest继承自ServerRequest,我们验证继承关系
Expand Down Expand Up @@ -149,6 +151,7 @@ public function testInheritedMethods()
/**
* 测试类的不可变性 - with方法应该返回新实例
*/
#[AllowMockObjectsWithoutExpectations]
public function testImmutableWithMethods()
{
// 创建一个模拟的SwooleServerRequest实例(通过反射绕过Swoole依赖)
Expand Down
2 changes: 2 additions & 0 deletions tests/request/UploadedFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -781,6 +782,7 @@ public function testVariousMediaTypes(): void

// ===== 构造函数带Stream测试 =====

#[AllowMockObjectsWithoutExpectations]
public function testConstructorWithProvidedStream(): void
{
$mockStream = $this->createMock(StreamInterface::class);
Expand Down
Loading