Skip to content

Commit 65bd401

Browse files
authored
Fixed Swoole response status code (#70)
* Fixed Swoole SymfonyRunner response status code * Fixed Swoole LaravelRunner response status code
1 parent 68c3b5e commit 65bd401

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

src/LaravelRunner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public function handle(Request $request, Response $response): void
5454
$response->header($name, $value);
5555
}
5656
}
57+
58+
$response->status($sfResponse->getStatusCode());
5759
$response->end($sfResponse->getContent());
5860
}
5961
}

src/SymfonyRunner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public function handle(Request $request, Response $response): void
5454
$response->header($name, $value);
5555
}
5656
}
57+
58+
$response->status($sfResponse->getStatusCode());
5759
$response->end($sfResponse->getContent());
5860
}
5961
}

tests/Unit/LaravelRunnerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function testHandle(): void
3434
{
3535
$sfResponse = $this->createMock(\Symfony\Component\HttpFoundation\Response::class);
3636
$sfResponse->headers = new HeaderBag(['X-Test' => 'Swoole-Runtime']);
37+
$sfResponse->expects(self::once())->method('getStatusCode')->willReturn(201);
3738
$sfResponse->expects(self::once())->method('getContent')->willReturn('Test');
3839

3940
$application = $this->createMock(Kernel::class);
@@ -44,6 +45,7 @@ public function testHandle(): void
4445

4546
$response = $this->createMock(Response::class);
4647
$response->expects(self::once())->method('header')->with('x-test', 'Swoole-Runtime');
48+
$response->expects(self::once())->method('status')->with(201);
4749
$response->expects(self::once())->method('end')->with('Test');
4850

4951
$factory = $this->createMock(ServerFactory::class);

tests/Unit/SymfonyRunnerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function testHandle(): void
3434
{
3535
$sfResponse = $this->createMock(\Symfony\Component\HttpFoundation\Response::class);
3636
$sfResponse->headers = new HeaderBag(['X-Test' => 'Swoole-Runtime']);
37+
$sfResponse->expects(self::once())->method('getStatusCode')->willReturn(201);
3738
$sfResponse->expects(self::once())->method('getContent')->willReturn('Test');
3839

3940
$application = $this->createMock(HttpKernelInterface::class);
@@ -44,6 +45,7 @@ public function testHandle(): void
4445

4546
$response = $this->createMock(Response::class);
4647
$response->expects(self::once())->method('header')->with('x-test', 'Swoole-Runtime');
48+
$response->expects(self::once())->method('status')->with(201);
4749
$response->expects(self::once())->method('end')->with('Test');
4850

4951
$factory = $this->createMock(ServerFactory::class);

0 commit comments

Comments
 (0)