@@ -85,72 +85,6 @@ public function testCanGetEnvironmentVariable(): void
8585 $ this ->assertEquals (Http::getEnv ('unknown ' , 'test ' ), 'test ' );
8686 }
8787
88- public function testCanGetResources (): void
89- {
90- $ this ->container ->set ('rand ' , fn () => rand (), []);
91- $ this ->container ->set ('first ' , fn ($ second ) => "first- {$ second }" , ['second ' ]);
92- $ this ->container ->set ('second ' , fn () => 'second ' , []);
93-
94- $ second = $ this ->container ->get ('second ' );
95- $ first = $ this ->container ->get ('first ' );
96- $ this ->assertEquals ('second ' , $ second );
97- $ this ->assertEquals ('first-second ' , $ first );
98-
99- $ resource = $ this ->container ->get ('rand ' );
100-
101- $ this ->assertNotEmpty ($ resource );
102- $ this ->assertEquals ($ resource , $ this ->container ->get ('rand ' ));
103- $ this ->assertEquals ($ resource , $ this ->container ->get ('rand ' ));
104- $ this ->assertEquals ($ resource , $ this ->container ->get ('rand ' ));
105-
106- // Default Params
107- $ route = new Route ('GET ' , '/path ' );
108-
109- $ route
110- ->inject ('rand ' )
111- ->param ('x ' , 'x-def ' , new Text (200 ), 'x param ' , true )
112- ->param ('y ' , 'y-def ' , new Text (200 ), 'y param ' , true )
113- ->action (function ($ x , $ y , $ rand ) {
114- echo $ x . '- ' . $ y . '- ' . $ rand ;
115- });
116-
117- \ob_start ();
118- $ this ->http ->execute ($ route , new Request (), '1 ' );
119- $ result = \ob_get_contents ();
120- \ob_end_clean ();
121-
122- $ this ->assertEquals ('x-def-y-def- ' . $ resource , $ result );
123- }
124-
125- public function testCanGetDefaultValueWithFunction (): void
126- {
127- $ this ->container ->set ('first ' , fn ($ second ) => "first- {$ second }" , ['second ' ]);
128- $ this ->container ->set ('second ' , fn () => 'second ' , []);
129-
130- $ second = $ this ->container ->get ('second ' );
131- $ first = $ this ->container ->get ('first ' );
132- $ this ->assertEquals ('second ' , $ second );
133- $ this ->assertEquals ('first-second ' , $ first );
134-
135- // Default Value using function
136- $ route = new Route ('GET ' , '/path ' );
137-
138- $ route
139- ->param ('x ' , function ($ first , $ second ) {
140- return $ first . '- ' . $ second ;
141- }, new Text (200 ), 'x param ' , true , ['first ' , 'second ' ])
142- ->action (function ($ x ) {
143- echo $ x ;
144- });
145-
146- \ob_start ();
147- $ this ->http ->execute ($ route , new Request (), '1 ' );
148- $ result = \ob_get_contents ();
149- \ob_end_clean ();
150-
151- $ this ->assertEquals ('first-second-second ' , $ result );
152- }
153-
15488 public function testCanExecuteRoute (): void
15589 {
15690 $ this ->container ->set ('rand ' , fn () => rand (), []);
0 commit comments