@@ -29,9 +29,10 @@ public function setUp(): void
2929 ],
3030 ];
3131
32- $ this ->request = ServerRequestFactory::fromGlobals ([
33- 'REQUEST_URI ' => '/images/cake-logo.png?w=100 ' ,
34- ]);
32+ $ this ->request = ServerRequestFactory::fromGlobals (
33+ ['REQUEST_URI ' => '/images/cake-logo.png ' ],
34+ ['w ' => '100 ' ]
35+ );
3536 $ this ->handler = new TestRequestHandler ();
3637
3738 Security::setSalt ('salt ' );
@@ -66,6 +67,24 @@ public function testServerCallable()
6667 $ this ->assertTrue (is_dir (TMP . 'cache/cake-logo.png ' ));
6768 }
6869
70+ public function testAllowedParams ()
71+ {
72+ $ this ->config ['allowedParams ' ] = ['w ' ];
73+ $ middleware = new GlideMiddleware ($ this ->config );
74+ $ middleware ->process ($ this ->request , $ this ->handler );
75+
76+ $ request = ServerRequestFactory::fromGlobals (
77+ ['REQUEST_URI ' => '/images/cake-logo.png ' ],
78+ ['w ' => '100 ' , 'foo ' => 'bar ' ]
79+ );
80+
81+ $ middleware = new GlideMiddleware ($ this ->config );
82+ $ middleware ->process ($ request , $ this ->handler );
83+
84+ $ files = glob (TMP . 'cache/cake-logo.png/* ' );
85+ $ this ->assertSame (1 , count ($ files ));
86+ }
87+
6988 public function testOriginalPassThrough ()
7089 {
7190 $ fileSize = filesize (PLUGIN_ROOT . '/test_app/webroot/upload/cake-logo.png ' );
@@ -139,10 +158,13 @@ public function testCache()
139158 $ this ->assertTrue (isset ($ headers ['Last-Modified ' ]));
140159 $ this ->assertTrue (isset ($ headers ['Expires ' ]));
141160
142- $ request = ServerRequestFactory::fromGlobals ([
143- 'REQUEST_URI ' => '/images/cake-logo.png?w=100 ' ,
144- 'HTTP_IF_MODIFIED_SINCE ' => $ headers ['Last-Modified ' ][0 ],
145- ]);
161+ $ request = ServerRequestFactory::fromGlobals (
162+ [
163+ 'REQUEST_URI ' => '/images/cake-logo.png ' ,
164+ 'HTTP_IF_MODIFIED_SINCE ' => $ headers ['Last-Modified ' ][0 ],
165+ ],
166+ ['w ' => '100 ' ]
167+ );
146168
147169 $ middleware = new GlideMiddleware ($ this ->config );
148170 $ response = $ middleware ->process ($ request , $ this ->handler );
0 commit comments