@@ -10,7 +10,7 @@ use function ob_end_clean;
1010
1111final class EmitterStackTest extends HackTest {
1212
13- private ? EmitterStack $stack ;
13+ << __LateInit >> private EmitterStack $stack ;
1414
1515 <<__Override >>
1616 public async function beforeEachTestAsync (): Awaitable <void > {
@@ -19,10 +19,11 @@ final class EmitterStackTest extends HackTest {
1919
2020 public function testShouldEmitTrue (): void {
2121 $sapiEmmiter = new SapiEmitter ();
22- $this -> stack ? -> push($sapiEmmiter );
22+ $this -> stack -> push($sapiEmmiter );
2323 list ($readHandle , $writeHandle ) = IO \pipe_nd ();
24+ $writeHandle -> write(' testing' );
2425 ob_start ();
25- $result = $this -> stack ? -> emit(
26+ $result = $this -> stack -> emit(
2627 $readHandle ,
2728 new Response ($writeHandle , StatusCode :: OK )
2829 );
@@ -32,11 +33,11 @@ final class EmitterStackTest extends HackTest {
3233
3334 public function testShouldReturnMessageBody (): void {
3435 $sapiEmmiter = new SapiEmitter ();
35- $this -> stack ? -> push($sapiEmmiter );
36+ $this -> stack -> push($sapiEmmiter );
3637 list ($readHandle , $writeHandle ) = IO \pipe_nd ();
37- $writeHandle -> rawWriteBlocking (' content' );
38+ $writeHandle -> write (' content' );
3839 ob_start ();
39- $_ = $this -> stack ? -> emit(
40+ $_ = $this -> stack -> emit(
4041 $readHandle ,
4142 new Response ($writeHandle , StatusCode :: OK )
4243 );
@@ -47,12 +48,12 @@ final class EmitterStackTest extends HackTest {
4748
4849 public function testEmitsResponseHeaders (): void {
4950 $sapiEmmiter = new OverrideSapiEmitter ();
50- $this -> stack ? -> push($sapiEmmiter );
51+ $this -> stack -> push($sapiEmmiter );
5152 list ($readHandle , $writeHandle ) = IO \pipe_nd ();
52- $writeHandle -> rawWriteBlocking (' content' );
53+ $writeHandle -> write (' content' );
5354 $response = new TextResponse ($writeHandle , StatusCode :: OK );
5455 ob_start ();
55- $_ = $this -> stack ? -> emit(
56+ $_ = $this -> stack -> emit(
5657 $readHandle ,
5758 $response
5859 );
@@ -63,9 +64,11 @@ final class EmitterStackTest extends HackTest {
6364 expect ($header )-> toContainSubstring(' Content-Type: text/plain' );
6465 }
6566
66- public function testMultipleSetCookieHeadersAreNotReplaced (): void {
67+ public async function testMultipleSetCookieHeadersAreNotReplaced (): Awaitable < void > {
6768 $sapiEmmiter = new OverrideSapiEmitter ();
6869 list ($readHandle , $writeHandle ) = IO \pipe_nd ();
70+ await $writeHandle -> writeAsync(' ' );
71+ await $writeHandle -> closeAsync();
6972 $sapiEmmiter -> emit($readHandle , (new Response ($writeHandle ))
7073 -> withStatus(200 )
7174 -> withAddedHeader(' Set-Cookie' , vec [' foo=bar' , ' bar=baz' ]));
@@ -76,9 +79,11 @@ final class EmitterStackTest extends HackTest {
7679 ]);
7780 }
7881
79- public function testDoesNotLetResponseCodeBeOverriddenByHack (): void {
82+ public async function testDoesNotLetResponseCodeBeOverriddenByHack (): Awaitable < void > {
8083 $sapiEmmiter = new OverrideSapiEmitter ();
8184 list ($readHandle , $writeHandle ) = IO \pipe_nd ();
85+ await $writeHandle -> writeAsync(' ' );
86+ await $writeHandle -> closeAsync();
8287 $response = (new Response ($writeHandle ))
8388 -> withStatus(StatusCode :: ACCEPTED )
8489 -> withAddedHeader(' Location' , vec [' http://api.my-service.com/12345678' ])
@@ -97,13 +102,13 @@ final class EmitterStackTest extends HackTest {
97102
98103 public async function testShouldEmitOutput (): Awaitable <void > {
99104 $sapiEmmiter = new SapiEmitter ();
100- $this -> stack ? -> push($sapiEmmiter );
101- $this -> stack ? -> push($sapiEmmiter );
105+ $this -> stack -> push($sapiEmmiter );
106+ $this -> stack -> push($sapiEmmiter );
102107 list ($readHandle , $writeHandle ) = IO \pipe_nd ();
103108 await $writeHandle -> writeAsync(' content' );
104109 await $writeHandle -> closeAsync();
105110 ob_start ();
106- await $this -> stack ? -> emitAsync(
111+ await $this -> stack -> emitAsync(
107112 $readHandle ,
108113 new Response ($writeHandle , StatusCode :: OK )
109114 );
0 commit comments