@@ -19,9 +19,9 @@ class MiddlewareTest extends TestCase
1919 /**
2020 * @throws Throwable
2121 */
22- public function test_with_a_single_middleware_in_an_object ()
22+ public function test_with_a_single_middleware_as_an_object ()
2323 {
24- $ middleware = new SampleMiddleware (mt_rand ( 1 , 9999999 ) );
24+ $ middleware = new SampleMiddleware (666 );
2525
2626 $ router = $ this ->router ()
2727 ->get ('/ ' , $ this ->controller (), $ middleware )
@@ -34,7 +34,7 @@ public function test_with_a_single_middleware_in_an_object()
3434 /**
3535 * @throws Throwable
3636 */
37- public function test_with_a_single_middleware_in_a_string ()
37+ public function test_with_a_single_middleware_as_a_string ()
3838 {
3939 $ middleware = SampleMiddleware::class;
4040
@@ -49,12 +49,10 @@ public function test_with_a_single_middleware_in_a_string()
4949 /**
5050 * @throws Throwable
5151 */
52- public function test_with_a_single_middleware_in_a_closure ()
52+ public function test_with_a_single_middleware_as_a_closure ()
5353 {
5454 $ middleware = function (ServerRequest $ request , Closure $ next ) {
55- $ request = $ request ->withAttribute ('Middleware ' , 666 );
56-
57- return $ next ($ request );
55+ return $ next ($ request ->withAttribute ('Middleware ' , 666 ));
5856 };
5957
6058 $ router = $ this ->router ()
@@ -71,7 +69,7 @@ public function test_with_a_single_middleware_in_a_closure()
7169 */
7270 public function test_with_a_stopper_middleware ()
7371 {
74- $ middleware = new StopperMiddleware (mt_rand ( 1 , 9999999 ) );
72+ $ middleware = new StopperMiddleware (666 );
7573
7674 $ router = $ this ->router ()
7775 ->get ('/ ' , $ this ->controller (), $ middleware )
@@ -88,22 +86,22 @@ public function test_with_multiple_middleware()
8886 {
8987 $ middleware = [
9088 function (ServerRequest $ request , $ next ) {
91- $ request = $ request ->withAttribute ('t1 ' , microtime ( true ) );
89+ $ request = $ request ->withAttribute ('a ' , ' It ' );
9290 return $ next ($ request );
9391 },
9492 function (ServerRequest $ request , $ next ) {
95- $ request = $ request ->withAttribute ('t2 ' , microtime ( true ) );
93+ $ request = $ request ->withAttribute ('b ' , ' works! ' );
9694 return $ next ($ request );
9795 },
9896 ];
9997
10098 $ router = $ this ->router ()
10199 ->get ('/ ' , function (ServerRequest $ request ) {
102- return $ request ->getAttribute ('t2 ' ) - $ request ->getAttribute ('t1 ' );
100+ return $ request ->getAttribute ('a ' ) . ' ' . $ request ->getAttribute ('b ' );
103101 }, $ middleware )
104102 ->dispatch ();
105103
106- $ this ->assertGreaterThan ( 0 , $ this ->outputOf ($ router ));
104+ $ this ->assertEquals ( ' It works! ' , $ this ->outputOf ($ router ));
107105 }
108106
109107 /**
0 commit comments