|
41 | 41 | class tlRestApi |
42 | 42 | { |
43 | 43 |
|
| 44 | + public $app; |
| 45 | + |
44 | 46 | public static $version = "1.0"; |
45 | 47 |
|
46 | 48 | /** |
@@ -125,92 +127,34 @@ public function __construct() |
125 | 127 |
|
126 | 128 | // test route with anonymous function |
127 | 129 | $this->app->get('/who', |
128 | | - function (): void { |
| 130 | + static function (): void { |
129 | 131 | echo __CLASS__ . ' : Get Route /who'; |
130 | 132 | }); |
131 | 133 |
|
132 | | - $this->app->get('/whoAmI', [ |
133 | | - $this, |
134 | | - 'authenticate' |
135 | | - ], [ |
136 | | - $this, |
137 | | - 'whoAmI' |
138 | | - ]); |
139 | | - $this->app->get('/testprojects', [ |
140 | | - $this, |
141 | | - 'authenticate' |
142 | | - ], [ |
143 | | - $this, |
144 | | - 'getProjects' |
145 | | - ]); |
146 | | - |
147 | | - $this->app->get('/testprojects/:id', [ |
148 | | - $this, |
149 | | - 'authenticate' |
150 | | - ], [ |
151 | | - $this, |
152 | | - 'getProjects' |
153 | | - ]); |
154 | | - $this->app->get('/testprojects/:id/testcases', |
155 | | - [ |
156 | | - $this, |
157 | | - 'authenticate' |
158 | | - ], [ |
159 | | - $this, |
160 | | - 'getProjectTestCases' |
161 | | - ]); |
162 | | - $this->app->get('/testprojects/:id/testplans', |
163 | | - [ |
164 | | - $this, |
165 | | - 'authenticate' |
166 | | - ], [ |
167 | | - $this, |
168 | | - 'getProjectTestPlans' |
169 | | - ]); |
170 | | - |
171 | | - $this->app->post('/testprojects', [ |
172 | | - $this, |
173 | | - 'authenticate' |
174 | | - ], [ |
175 | | - $this, |
176 | | - 'createTestProject' |
177 | | - ]); |
178 | | - $this->app->post('/executions', [ |
179 | | - $this, |
180 | | - 'authenticate' |
181 | | - ], [ |
182 | | - $this, |
183 | | - 'createTestCaseExecution' |
184 | | - ]); |
185 | | - $this->app->post('/testplans', [ |
186 | | - $this, |
187 | | - 'authenticate' |
188 | | - ], [ |
189 | | - $this, |
190 | | - 'createTestPlan' |
191 | | - ]); |
192 | | - $this->app->post('/testplans/:id', [ |
193 | | - $this, |
194 | | - 'authenticate' |
195 | | - ], [ |
196 | | - $this, |
197 | | - 'updateTestPlan' |
198 | | - ]); |
199 | | - |
200 | | - $this->app->post('/testsuites', [ |
201 | | - $this, |
202 | | - 'authenticate' |
203 | | - ], [ |
204 | | - $this, |
205 | | - 'createTestSuite' |
206 | | - ]); |
207 | | - $this->app->post('/testcases', [ |
208 | | - $this, |
209 | | - 'authenticate' |
210 | | - ], [ |
211 | | - $this, |
212 | | - 'createTestCase' |
213 | | - ]); |
| 134 | + $this->app->get('/whoAmI', $this->authenticate(...), $this->whoAmI(...)); |
| 135 | + $this->app->get('/testprojects', $this->authenticate(...), |
| 136 | + $this->getProjects(...)); |
| 137 | + |
| 138 | + $this->app->get('/testprojects/:id', $this->authenticate(...), |
| 139 | + $this->getProjects(...)); |
| 140 | + $this->app->get('/testprojects/:id/testcases', $this->authenticate(...), |
| 141 | + $this->getProjectTestCases(...)); |
| 142 | + $this->app->get('/testprojects/:id/testplans', $this->authenticate(...), |
| 143 | + $this->getProjectTestPlans(...)); |
| 144 | + |
| 145 | + $this->app->post('/testprojects', $this->authenticate(...), |
| 146 | + $this->createTestProject(...)); |
| 147 | + $this->app->post('/executions', $this->authenticate(...), |
| 148 | + $this->createTestCaseExecution(...)); |
| 149 | + $this->app->post('/testplans', $this->authenticate(...), |
| 150 | + $this->createTestPlan(...)); |
| 151 | + $this->app->post('/testplans/:id', $this->authenticate(...), |
| 152 | + $this->updateTestPlan(...)); |
| 153 | + |
| 154 | + $this->app->post('/testsuites', $this->authenticate(...), |
| 155 | + $this->createTestSuite(...)); |
| 156 | + $this->app->post('/testcases', $this->authenticate(...), |
| 157 | + $this->createTestCase(...)); |
214 | 158 |
|
215 | 159 | $this->db = new database(DB_TYPE); |
216 | 160 | $this->db->db->SetFetchMode(ADODB_FETCH_ASSOC); |
@@ -437,10 +381,9 @@ public function createTestProject() |
437 | 381 | try { |
438 | 382 | $request = $this->app->request(); |
439 | 383 | $item = json_decode($request->getBody()); |
440 | | - $op['id'] = $this->tprojectMgr->create($item, |
441 | | - [ |
442 | | - 'doChecks' => true |
443 | | - ]); |
| 384 | + $op['id'] = $this->tprojectMgr->create($item, [ |
| 385 | + 'doChecks' => true |
| 386 | + ]); |
444 | 387 | $op = [ |
445 | 388 | 'status' => 'ok', |
446 | 389 | 'message' => 'ok' |
|
0 commit comments