@@ -69,7 +69,10 @@ public function testGetQueryParams()
69
69
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
70
70
}
71
71
72
- // TODO write me
72
+ $ new = $ this ->serverRequest ->withQueryParams (['foo ' => 'bar ' ]);
73
+ $ this ->assertEmpty ($ this ->serverRequest ->getQueryParams (), 'withQueryParams MUST be immutable ' );
74
+
75
+ $ this ->assertArrayHasKey ('foo ' , $ new ->getQueryParams ());
73
76
}
74
77
75
78
public function testGetUploadedFiles ()
@@ -78,7 +81,13 @@ public function testGetUploadedFiles()
78
81
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
79
82
}
80
83
81
- // TODO write me
84
+ $ file = $ this ->buildUploadableFile ('foo ' );
85
+ $ new = $ this ->serverRequest ->withUploadedFiles ([$ file ]);
86
+ $ this ->assertEmpty ($ this ->serverRequest ->getUploadedFiles (), 'withUploadedFiles MUST be immutable ' );
87
+
88
+ $ files = $ new ->getUploadedFiles ();
89
+ $ this ->assertEquals (1 , count ($ files ));
90
+ $ this ->assertEquals ($ file , $ files [0 ]);
82
91
}
83
92
84
93
public function testGetParsedBody ()
@@ -87,7 +96,18 @@ public function testGetParsedBody()
87
96
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
88
97
}
89
98
90
- // TODO write me
99
+ $ data = [
100
+ 4711 ,
101
+ null ,
102
+ new \stdClass (),
103
+ ['foo ' => 'bar ' , 'baz ' ],
104
+ ];
105
+
106
+ foreach ($ data as $ item ) {
107
+ $ new = $ this ->serverRequest ->withParsedBody ($ item );
108
+ $ this ->assertNull ($ this ->serverRequest ->getParsedBody (), 'withParsedBody MUST be immutable ' );
109
+ $ this ->assertEquals ($ item , $ new ->getParsedBody ());
110
+ }
91
111
}
92
112
93
113
public function testGetAttributes ()
@@ -96,6 +116,36 @@ public function testGetAttributes()
96
116
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
97
117
}
98
118
99
- // TODO write me
119
+ $ new = $ this ->serverRequest ->withAttribute ('foo ' , 'bar ' );
120
+ $ this ->assertNull ($ this ->serverRequest ->getAttributes (), 'withAttribute MUST be immutable ' );
121
+ $ this ->assertEquals (['foo ' => 'bar ' ], $ new ->getAttributes ());
122
+
123
+ $ new = $ new ->withAttribute ('baz ' , 'biz ' );
124
+ $ this ->assertEquals (['foo ' => 'bar ' , 'baz ' => 'biz ' ], $ new ->getAttributes ());
125
+ }
126
+
127
+ public function testGetAttribute ()
128
+ {
129
+ if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
130
+ $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
131
+ }
132
+
133
+ $ new = $ this ->serverRequest ->withAttribute ('foo ' , 'bar ' );
134
+ $ this ->assertEquals ('bar ' , $ new ->getAttribute ('foo ' ));
135
+ $ this ->assertEquals ('baz ' , $ new ->getAttribute ('not found ' , 'baz ' ));
136
+ $ this ->assertEquals (null , $ new ->getAttribute ('not found ' ));
137
+ }
138
+
139
+ public function testWithoutAttribute ()
140
+ {
141
+ if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
142
+ $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
143
+ }
144
+
145
+ $ with = $ this ->serverRequest ->withAttribute ('foo ' , 'bar ' );
146
+ $ without = $ with ->withoutAttribute ('foo ' );
147
+
148
+ $ this ->assertEquals ('bar ' , $ with ->getAttribute ('foo ' ), 'withoutAttribute MUST be immutable ' );
149
+ $ this ->assertEquals (null , $ without ->getAttribute ('foo ' ));
100
150
}
101
151
}
0 commit comments