19
19
/**
20
20
* Unit test helper trait
21
21
*/
22
- trait TestingHelpers {
22
+ trait TestingHelpers
23
+ {
23
24
24
25
/**
25
26
* @return string
@@ -62,8 +63,6 @@ public function setUp()
62
63
{
63
64
parent ::setUp ();
64
65
65
- $ this ->clearCache ();
66
-
67
66
// Obtain configuration params
68
67
$ class_name = $ this ->getApiCodesClassName ();
69
68
$ obj = new $ class_name ();
@@ -82,7 +81,7 @@ public function setUp()
82
81
$ map = $ this ->getProtectedMember (\MarcinOrlowski \ResponseBuilder \BaseApiCodes::class, 'base_map ' );
83
82
$ idx = mt_rand (1 , count ($ map ));
84
83
85
- $ this ->random_api_code_message_key = $ map [array_keys ($ map )[$ idx- 1 ] ];
84
+ $ this ->random_api_code_message_key = $ map [ array_keys ($ map )[ $ idx - 1 ] ];
86
85
$ this ->random_api_code_message = \Lang::get ($ this ->random_api_code_message_key , [
87
86
'api_code ' => $ this ->random_api_code ,
88
87
]);
@@ -93,31 +92,6 @@ public function setUp()
93
92
}
94
93
95
94
96
- /**
97
- * Clears Laravel config/route etc caches...
98
- */
99
- protected function clearCache ()
100
- {
101
- // $commands = ['clear-compiled', 'cache:clear', 'view:clear', 'config:clear', 'route:clear'];
102
- // foreach ($commands as $command) {
103
- // \Illuminate\Support\Facades\Artisan::call($command);
104
- // }
105
- }
106
-
107
- /**
108
- * Load service providers we need during the tests
109
- *
110
- * @param \Illuminate\Foundation\Application $app
111
- *
112
- * @return array
113
- */
114
- protected function getPackageProviders ($ app )
115
- {
116
- return [
117
- \MarcinOrlowski \ResponseBuilder \Tests \Providers \ResponseBuilderServiceProvider::class,
118
- ];
119
- }
120
-
121
95
// -----------------------------------------------------------
122
96
123
97
@@ -230,6 +204,21 @@ private function getResponseObjectRaw($expected_api_code, $expected_http_code, $
230
204
}
231
205
232
206
207
+ /**
208
+ * Use assertValidResponse() instead
209
+ *
210
+ * @param StdClass $json_object
211
+ * @param array $extra_keys
212
+ *
213
+ * @return void
214
+ *
215
+ * @deprecated Use assertValidResponse() instead
216
+ */
217
+ public function validateResponseStructure ($ json_object , array $ extra_keys = [])
218
+ {
219
+ $ this ->assertValidResponse ($ json_object , $ extra_keys );
220
+ }
221
+
233
222
/**
234
223
* Validates if given $json_object contains all expected elements
235
224
*
@@ -238,7 +227,7 @@ private function getResponseObjectRaw($expected_api_code, $expected_http_code, $
238
227
*
239
228
* @return void
240
229
*/
241
- public function validateResponseStructure ($ json_object , array $ extra_keys = [])
230
+ public function assertValidResponse ($ json_object , array $ extra_keys = [])
242
231
{
243
232
$ this ->assertTrue (is_object ($ json_object ));
244
233
@@ -260,7 +249,7 @@ public function validateResponseStructure($json_object, array $extra_keys = [])
260
249
$ this ->assertObjectHasAttribute ($ item , $ json_object , "No ' {$ item }' element in response structure found " );
261
250
}
262
251
263
- $ this ->assertTrue (is_bool ($ json_object ->{$ items [ResponseBuilder::KEY_SUCCESS ]}));
252
+ $ this ->assertTrue (is_bool ($ json_object ->{$ items [ ResponseBuilder::KEY_SUCCESS ]}));
264
253
$ this ->assertTrue (is_int ($ json_object ->code ));
265
254
$ this ->assertTrue (is_string ($ json_object ->locale ));
266
255
/** @noinspection UnNecessaryDoubleQuotesInspection */
@@ -484,5 +473,4 @@ protected function escape8($string)
484
473
return $ escaped ;
485
474
}
486
475
487
-
488
476
}
0 commit comments