@@ -15,7 +15,7 @@ public function testDefaultHeaders(): void
1515 {
1616 $ response = Response::from (code: HttpCode::OK , data: [], headers: null );
1717 $ expected = [
18- 'Status ' => [sprintf ( ' HTTP/1.1 %s ' , HttpCode::OK ->message () )],
18+ 'Status ' => [HttpCode::OK ->message ()],
1919 'Content-Type ' => [HttpContentType::APPLICATION_JSON ->value ]
2020 ];
2121
@@ -57,44 +57,45 @@ public function testGetHeaderLine(): void
5757 self ::assertEquals (HttpContentType::APPLICATION_JSON ->value , $ response ->getHeaderLine (name: 'Content-Type ' ));
5858 }
5959
60- public function testExceptionWhenBadMethodCallOnWithBody (): void
60+ public function testWithHeader (): void
6161 {
62+ $ value = '2850bf62-8383-4e9f-b237-d41247a1df3b ' ;
6263 $ response = Response::from (code: HttpCode::OK , data: [], headers: null );
64+ $ response ->withHeader (name: 'Token ' , value: $ value );
6365
64- self ::expectException (BadMethodCall::class);
65- self ::expectExceptionMessage ('Method <TinyBlocks\Http\Internal\Response::withBody> cannot be used. ' );
66+ $ expected = [$ value ];
6667
67- $ response ->withBody (body: StreamFactory:: from (data: [] ));
68+ self :: assertEquals ( $ expected , $ response ->getHeader (name: ' Token ' ));
6869 }
6970
70- public function testExceptionWhenBadMethodCallOnWithStatus (): void
71+ public function testWithoutHeader (): void
7172 {
7273 $ response = Response::from (code: HttpCode::OK , data: [], headers: null );
74+ $ response ->withoutHeader ('Status ' );
75+ $ expected = [HttpContentType::APPLICATION_JSON ->value ];
7376
74- self ::expectException (BadMethodCall::class);
75- self ::expectExceptionMessage ('Method <TinyBlocks\Http\Internal\Response::withStatus> cannot be used. ' );
76-
77- $ response ->withStatus (code: HttpCode::OK ->value );
77+ self ::assertEmpty ($ response ->getHeader (name: 'Status ' ));
78+ self ::assertEquals ($ expected , $ response ->getHeader (name: 'Content-Type ' ));
7879 }
7980
80- public function testExceptionWhenBadMethodCallOnWithHeader (): void
81+ public function testExceptionWhenBadMethodCallOnWithBody (): void
8182 {
8283 $ response = Response::from (code: HttpCode::OK , data: [], headers: null );
8384
8485 self ::expectException (BadMethodCall::class);
85- self ::expectExceptionMessage ('Method <TinyBlocks\Http\Internal\Response::withHeader > cannot be used. ' );
86+ self ::expectExceptionMessage ('Method <TinyBlocks\Http\Internal\Response::withBody > cannot be used. ' );
8687
87- $ response ->withHeader (name: '' , value: '' );
88+ $ response ->withBody (body: StreamFactory:: from (data: []) );
8889 }
8990
90- public function testExceptionWhenBadMethodCallOnWithoutHeader (): void
91+ public function testExceptionWhenBadMethodCallOnWithStatus (): void
9192 {
9293 $ response = Response::from (code: HttpCode::OK , data: [], headers: null );
9394
9495 self ::expectException (BadMethodCall::class);
95- self ::expectExceptionMessage ('Method <TinyBlocks\Http\Internal\Response::withoutHeader > cannot be used. ' );
96+ self ::expectExceptionMessage ('Method <TinyBlocks\Http\Internal\Response::withStatus > cannot be used. ' );
9697
97- $ response ->withoutHeader (name: '' );
98+ $ response ->withStatus (code: HttpCode:: OK -> value );
9899 }
99100
100101 public function testExceptionWhenBadMethodCallOnWithAddedHeader (): void
0 commit comments