2
2
3
3
namespace PHPFastCGI \Test \Slimmer ;
4
4
5
+ use PHPFastCGI \FastCGIDaemon \Http \Request ;
5
6
use PHPFastCGI \Slimmer \AppWrapper ;
6
7
use Slim \App ;
7
8
use Slim \Exception \Exception as SlimException ;
8
9
use Zend \Diactoros \Response \HtmlResponse ;
9
- use Zend \Diactoros \ServerRequest ;
10
10
11
11
/**
12
12
* Tests the app wrapper.
@@ -31,13 +31,16 @@ public function testHandleRequest()
31
31
$ kernel = new AppWrapper ($ app );
32
32
33
33
// Create a request to test the route set up for the app
34
- $ request = new ServerRequest ([], [], '/hello/Andrew ' );
34
+ $ stream = fopen ('php://temp ' , 'r ' );
35
+ $ request = new Request (['REQUEST_URI ' => '/hello/Andrew ' ], $ stream );
35
36
36
37
// Get the response from the kernel that is wrapping the app
37
38
$ response = $ kernel ->handleRequest ($ request );
38
39
39
40
// Check that the app has been wrapper properly by comparing to expected response
40
41
$ this ->assertSame ('Hello, Andrew ' , (string ) $ response ->getBody ());
42
+
43
+ fclose ($ stream );
41
44
}
42
45
43
46
/**
@@ -61,13 +64,16 @@ public function testSlimException()
61
64
$ kernel = new AppWrapper ($ app );
62
65
63
66
// Create a request to test the route set up for the app
64
- $ request = new ServerRequest ([], [], '/hello/Andrew ' );
67
+ $ stream = fopen ('php://temp ' , 'r ' );
68
+ $ request = new Request (['REQUEST_URI ' => '/hello/Andrew ' ], $ stream );
65
69
66
70
// Get the response from the kernel that is wrapping the app
67
71
$ response = $ kernel ->handleRequest ($ request );
68
72
69
73
// Check that the app has been wrapper properly by comparing to expected response
70
74
$ this ->assertEquals ((string ) $ expectedResponse ->getBody (), (string ) $ response ->getBody ());
75
+
76
+ fclose ($ stream );
71
77
}
72
78
73
79
/**
@@ -87,13 +93,16 @@ public function testException()
87
93
$ kernel = new AppWrapper ($ app );
88
94
89
95
// Create a request to test the route set up for the app
90
- $ request = new ServerRequest ([], [], '/hello/Andrew ' );
96
+ $ stream = fopen ('php://temp ' , 'r ' );
97
+ $ request = new Request (['REQUEST_URI ' => '/hello/Andrew ' ], $ stream );
91
98
92
99
// Get the response from the kernel that is wrapping the app
93
100
$ response = $ kernel ->handleRequest ($ request );
94
101
95
102
// Check that the app has returned a valid response
96
103
$ this ->assertInstanceOf ('Psr\Http\Message\ResponseInterface ' , $ response );
104
+
105
+ fclose ($ stream );
97
106
}
98
107
99
108
/**
@@ -118,7 +127,8 @@ public function testStrippedContentHeaders()
118
127
$ kernel = new AppWrapper ($ app );
119
128
120
129
// Create a request to test the route set up for the app
121
- $ request = new ServerRequest ([], [], '/hello/Andrew ' );
130
+ $ stream = fopen ('php://temp ' , 'r ' );
131
+ $ request = new Request (['REQUEST_URI ' => '/hello/Andrew ' ], $ stream );
122
132
123
133
// Get the response from the kernel that is wrapping the app
124
134
$ response = $ kernel ->handleRequest ($ request );
@@ -127,5 +137,7 @@ public function testStrippedContentHeaders()
127
137
$ this ->assertEquals ('Hello ' , (string ) $ response ->getBody ());
128
138
$ this ->assertFalse ($ response ->hasHeader ('Content-Type ' ));
129
139
$ this ->assertFalse ($ response ->hasHeader ('Content-Length ' ));
140
+
141
+ fclose ($ stream );
130
142
}
131
143
}
0 commit comments