@@ -65,6 +65,7 @@ public function test_can_serve_static_files_if_configured_to_and_file_is_within_
6565
6666 $ context = new RequestContext ([
6767 'publicPath ' => __DIR__ .'/public ' ,
68+ 'octaneConfig ' => [],
6869 ]);
6970
7071 $ this ->assertTrue ($ client ->canServeRequestAsStaticFile ($ request , $ context ));
@@ -78,6 +79,7 @@ public function test_cant_serve_static_files_if_file_is_outside_public_directory
7879
7980 $ context = new RequestContext ([
8081 'publicPath ' => __DIR__ .'/public/files ' ,
82+ 'octaneConfig ' => [],
8183 ]);
8284
8385 $ this ->assertFalse ($ client ->canServeRequestAsStaticFile ($ request , $ context ));
@@ -91,6 +93,7 @@ public function test_cant_serve_static_files_if_file_has_forbidden_extension()
9193
9294 $ context = new RequestContext ([
9395 'publicPath ' => __DIR__ .'/public/files ' ,
96+ 'octaneConfig ' => [],
9497 ]);
9598
9699 $ this ->assertFalse ($ client ->canServeRequestAsStaticFile ($ request , $ context ));
@@ -106,6 +109,7 @@ public function test_static_file_can_be_served()
106109 $ context = new RequestContext ([
107110 'swooleResponse ' => $ swooleResponse = Mockery::mock ('stdClass ' ),
108111 'publicPath ' => __DIR__ .'/public ' ,
112+ 'octaneConfig ' => [],
109113 ]);
110114
111115 $ swooleResponse ->shouldReceive ('status ' )->once ()->with (200 );
@@ -115,6 +119,32 @@ public function test_static_file_can_be_served()
115119 $ client ->serveStaticFile ($ request , $ context );
116120 }
117121
122+ public function test_static_file_headers_can_be_sent ()
123+ {
124+ $ client = new SwooleClient ;
125+
126+ $ request = Request::create ('/foo.txt ' , 'GET ' );
127+
128+ $ context = new RequestContext ([
129+ 'swooleResponse ' => $ swooleResponse = Mockery::mock ('stdClass ' ),
130+ 'publicPath ' => __DIR__ .'/public ' ,
131+ 'octaneConfig ' => [
132+ 'static_file_headers ' => [
133+ 'foo.txt ' => [
134+ 'X-Test-Header ' => 'Valid ' ,
135+ ],
136+ ],
137+ ],
138+ ]);
139+
140+ $ swooleResponse ->shouldReceive ('status ' )->once ()->with (200 );
141+ $ swooleResponse ->shouldReceive ('header ' )->once ()->with ('X-Test-Header ' , 'Valid ' );
142+ $ swooleResponse ->shouldReceive ('header ' )->once ()->with ('Content-Type ' , 'text/plain ' );
143+ $ swooleResponse ->shouldReceive ('sendfile ' )->once ()->with (realpath (__DIR__ .'/public/foo.txt ' ));
144+
145+ $ client ->serveStaticFile ($ request , $ context );
146+ }
147+
118148 public function test_can_serve_static_files_through_symlink ()
119149 {
120150 $ client = new SwooleClient ;
@@ -123,6 +153,7 @@ public function test_can_serve_static_files_through_symlink()
123153
124154 $ context = new RequestContext ([
125155 'publicPath ' => __DIR__ .'/public/files ' ,
156+ 'octaneConfig ' => [],
126157 ]);
127158
128159 $ this ->assertTrue ($ client ->canServeRequestAsStaticFile ($ request , $ context ));
@@ -136,6 +167,7 @@ public function test_cant_serve_static_files_through_symlink_using_directory_tra
136167
137168 $ context = new RequestContext ([
138169 'publicPath ' => __DIR__ .'/public/files ' ,
170+ 'octaneConfig ' => [],
139171 ]);
140172
141173 $ this ->assertFalse ($ client ->canServeRequestAsStaticFile ($ request , $ context ));
0 commit comments