@@ -61,10 +61,14 @@ protected function setUp()
6161 $ this ->response = new \CodeIgniter \HTTP \Response ($ this ->config );
6262 $ this ->logger = \Config \Services::logger ();
6363 $ this ->codeigniter = new MockCodeIgniter ($ this ->config );
64- }
64+ // }
65+ //
66+ // protected function getCollector(array $config = [], array $files = [], $moduleConfig = null)
67+ // {
68+ $ config = [];
69+ $ files = [];
70+ $ moduleConfig = null ;
6571
66- protected function getCollector (array $ config = [], array $ files = [], $ moduleConfig = null )
67- {
6872 $ defaults = [
6973 'Config ' => APPPATH . 'Config ' ,
7074 'App ' => APPPATH ,
@@ -81,7 +85,13 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
8185 $ moduleConfig ->enabled = false ;
8286 }
8387
84- return new RouteCollection ($ loader , $ moduleConfig );
88+ // return new RouteCollection($loader, $moduleConfig);
89+ $ routes = new RouteCollection ($ loader , $ moduleConfig );
90+
91+ // Inject mock router.
92+ $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\RESTful\Worker ' ]);
93+ $ router = Services::router ($ routes , $ this ->request );
94+ Services::injectMock ('router ' , $ router );
8595 }
8696
8797 //--------------------------------------------------------------------
@@ -106,11 +116,11 @@ public function testIndex()
106116 $ _SERVER ['REQUEST_URI ' ] = '/work ' ;
107117 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
108118
109- // Inject mock router.
110- $ routes = $ this ->getCollector ();
111- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
112- $ router = Services::router ($ routes );
113- Services::injectMock ('router ' , $ router );
119+ // // Inject mock router.
120+ // $routes = $this->getCollector();
121+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
122+ // $router = Services::router($routes,$this->request );
123+ // Services::injectMock('router', $router);
114124
115125 ob_start ();
116126 $ this ->codeigniter ->useSafeOutput (true )->run ();
@@ -131,11 +141,11 @@ public function testShow()
131141 $ _SERVER ['REQUEST_URI ' ] = '/work/show/1 ' ;
132142 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
133143
134- // Inject mock router.
135- $ routes = $ this ->getCollector ();
136- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
137- $ router = Services::router ($ routes );
138- Services::injectMock ('router ' , $ router );
144+ // // Inject mock router.
145+ // $routes = $this->getCollector();
146+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
147+ // $router = Services::router($routes);
148+ // Services::injectMock('router', $router);
139149
140150 ob_start ();
141151 $ this ->codeigniter ->useSafeOutput (true )->run ();
@@ -155,11 +165,11 @@ public function testNew()
155165 $ _SERVER ['REQUEST_URI ' ] = '/work/new ' ;
156166 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
157167
158- // Inject mock router.
159- $ routes = $ this ->getCollector ();
160- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
161- $ router = Services::router ($ routes );
162- Services::injectMock ('router ' , $ router );
168+ // // Inject mock router.
169+ // $routes = $this->getCollector();
170+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
171+ // $router = Services::router($routes);
172+ // Services::injectMock('router', $router);
163173
164174 ob_start ();
165175 $ this ->codeigniter ->useSafeOutput (true )->run ();
@@ -179,11 +189,11 @@ public function testCreate()
179189 $ _SERVER ['REQUEST_URI ' ] = '/work/create ' ;
180190 $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
181191
182- // Inject mock router.
183- $ routes = $ this ->getCollector ();
184- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
185- $ router = Services::router ($ routes );
186- Services::injectMock ('router ' , $ router );
192+ // // Inject mock router.
193+ // $routes = $this->getCollector();
194+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
195+ // $router = Services::router($routes);
196+ // Services::injectMock('router', $router);
187197
188198 ob_start ();
189199 $ this ->codeigniter ->useSafeOutput (true )->run ();
@@ -204,11 +214,11 @@ public function testEdit()
204214 $ _SERVER ['REQUEST_URI ' ] = '/work/edit/1 ' ;
205215 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
206216
207- // Inject mock router.
208- $ routes = $ this ->getCollector ();
209- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
210- $ router = Services::router ($ routes );
211- Services::injectMock ('router ' , $ router );
217+ // // Inject mock router.
218+ // $routes = $this->getCollector();
219+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
220+ // $router = Services::router($routes);
221+ // Services::injectMock('router', $router);
212222
213223 ob_start ();
214224 $ this ->codeigniter ->useSafeOutput (true )->run ();
@@ -229,11 +239,11 @@ public function testUpdate()
229239 $ _SERVER ['REQUEST_URI ' ] = '/work/update/1 ' ;
230240 $ _SERVER ['REQUEST_METHOD ' ] = 'PUT ' ;
231241
232- // Inject mock router.
233- $ routes = $ this ->getCollector ();
234- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
235- $ router = Services::router ($ routes );
236- Services::injectMock ('router ' , $ router );
242+ // // Inject mock router.
243+ // $routes = $this->getCollector();
244+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
245+ // $router = Services::router($routes);
246+ // Services::injectMock('router', $router);
237247
238248 ob_start ();
239249 $ this ->codeigniter ->useSafeOutput (true )->run ();
@@ -254,11 +264,11 @@ public function testDelete()
254264 $ _SERVER ['REQUEST_URI ' ] = '/work/delete/1 ' ;
255265 $ _SERVER ['REQUEST_METHOD ' ] = 'DELETE ' ;
256266
257- // Inject mock router.
258- $ routes = $ this ->getCollector ();
259- $ routes ->resource ('work ' , ['controller ' => '\Tests\Support\Resource \Worker ' ]);
260- $ router = Services::router ($ routes );
261- Services::injectMock ('router ' , $ router );
267+ // // Inject mock router.
268+ // $routes = $this->getCollector();
269+ // $routes->resource('work', ['controller' => '\Tests\Support\RESTful \Worker']);
270+ // $router = Services::router($routes);
271+ // Services::injectMock('router', $router);
262272
263273 ob_start ();
264274 $ this ->codeigniter ->useSafeOutput (true )->run ();
0 commit comments