File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 31
31
"lint" : " php-cs-fixer fix" ,
32
32
"pr" : [
33
33
" php-cs-fixer fix --dry-run -vvv" ,
34
- " psalm --stats" ,
34
+ " psalm --no-cache -- stats" ,
35
35
" phpunit --testdox --coverage-text"
36
36
]
37
37
},
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MNC \Http ;
4
+
5
+ use PHPUnit \Framework \TestCase ;
6
+
7
+ /**
8
+ * Class HeadersTest
9
+ * @package MNC\Http
10
+ */
11
+ class HeadersTest extends TestCase
12
+ {
13
+ public function testItConvertsToArrayProperly (): void
14
+ {
15
+ $ headers = Headers::fromMap ([
16
+ 'Content-Type ' => 'application/json ' ,
17
+ 'Content-Length ' => '3532 ' ,
18
+ 'Server ' => 'nginx '
19
+ ]);
20
+
21
+ $ lines = $ headers ->toArray ();
22
+
23
+ self ::assertSame ('content-type: application/json ' , $ lines [0 ]);
24
+ self ::assertSame ('content-length: 3532 ' , $ lines [1 ]);
25
+ self ::assertSame ('server: nginx ' , $ lines [2 ]);
26
+ self ::assertCount (3 , $ lines );
27
+ }
28
+
29
+ public function testFilter (): void
30
+ {
31
+ $ headers = Headers::fromMap ([
32
+ 'Content-Type ' => 'application/json ' ,
33
+ 'Content-Length ' => '3532 ' ,
34
+ 'Server ' => 'nginx '
35
+ ]);
36
+
37
+ $ headers = $ headers ->filter (fn ($ value , $ name ) => $ name !== 'server ' );
38
+
39
+ self ::assertCount (2 , $ headers );
40
+ self ::assertArrayHasKey ('content-type ' , $ headers );
41
+ self ::assertArrayHasKey ('content-length ' , $ headers );
42
+ self ::assertArrayNotHasKey ('server ' , $ headers );
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments