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);