Skip to content

Commit 2e61d7d

Browse files
committed
add more test
1 parent 0d733f2 commit 2e61d7d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Services/HttpPublisher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function publish($content): void
1919
http_response_code($content->getStatusCode());
2020

2121
foreach ($content->getHeaders() as $name => $values) {
22-
header($name . ': ' . $content->getHeaderLine($name));
22+
@header($name . ': ' . $content->getHeaderLine($name));
2323
}
2424

2525
fwrite($output, $content->getBody());

tests/Services/HttpPublisherTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,21 @@ public function test_publish_a_array_response()
5656

5757
$this->assertEquals('["a","b","c"]', ob_get_clean());
5858
}
59+
60+
/**
61+
* @throws Throwable
62+
*/
63+
public function test_publish_a_standard_response()
64+
{
65+
ob_start();
66+
67+
$router = Router::create();
68+
$router->get('/', function () {
69+
return new JsonResponse(['error' => 'failed'], 400);
70+
});
71+
72+
$router->dispatch();
73+
74+
$this->assertEquals('{"error":"failed"}', ob_get_clean());
75+
}
5976
}

0 commit comments

Comments
 (0)