@@ -49,6 +49,7 @@ public function output_writes_nothing_for_empty_tree()
49
49
50
50
/**
51
51
* @test
52
+ * @environment-setup useLaravel7
52
53
* @dataProvider controllerTreeDataProvider
53
54
*/
54
55
public function output_generates_test_for_controller_tree ($ definition , $ path , $ test )
@@ -75,8 +76,38 @@ public function output_generates_test_for_controller_tree($definition, $path, $t
75
76
$ this ->assertEquals (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
76
77
}
77
78
79
+ /**
80
+ * @test
81
+ * @environment-setup useLaravel8
82
+ * @dataProvider laravel8ControllerTreeDataProvider
83
+ */
84
+ public function output_generates_test_for_controller_tree_l8 ($ definition , $ path , $ test )
85
+ {
86
+ $ this ->files ->expects ('stub ' )
87
+ ->with ('test.class.stub ' )
88
+ ->andReturn ($ this ->stub ('test.class.stub ' ));
89
+
90
+ $ this ->files ->expects ('stub ' )
91
+ ->with ('test.case.stub ' )
92
+ ->andReturn ($ this ->stub ('test.case.stub ' ));
93
+ $ dirname = dirname ($ path );
94
+ $ this ->files ->expects ('exists ' )
95
+ ->with ($ dirname )
96
+ ->andReturnFalse ();
97
+ $ this ->files ->expects ('makeDirectory ' )
98
+ ->with ($ dirname , 0755 , true );
99
+ $ this ->files ->expects ('put ' )
100
+ ->with ($ path , $ this ->fixture ($ test ));
101
+
102
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ($ definition ));
103
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
104
+
105
+ $ this ->assertEquals (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
106
+ }
107
+
78
108
/**
79
109
* @test
110
+ * @environment-setup useLaravel7
80
111
*/
81
112
public function output_works_for_pascal_case_definition ()
82
113
{
@@ -108,8 +139,43 @@ public function output_works_for_pascal_case_definition()
108
139
$ this ->assertEquals (['created ' => [$ certificateControllerTest , $ certificateTypeControllerTest ]], $ this ->subject ->output ($ tree ));
109
140
}
110
141
142
+ /**
143
+ * @test
144
+ * @environment-setup useLaravel8
145
+ */
146
+ public function output_works_for_pascal_case_definition_l8 ()
147
+ {
148
+ $ this ->files ->expects ('stub ' )
149
+ ->with ('test.class.stub ' )
150
+ ->andReturn ($ this ->stub ('test.class.stub ' ));
151
+
152
+ $ this ->files ->expects ('stub ' )
153
+ ->with ('test.case.stub ' )
154
+ ->andReturn ($ this ->stub ('test.case.stub ' ));
155
+
156
+ $ certificateControllerTest = 'tests/Feature/Http/Controllers/CertificateControllerTest.php ' ;
157
+ $ certificateTypeControllerTest = 'tests/Feature/Http/Controllers/CertificateTypeControllerTest.php ' ;
158
+
159
+ $ this ->files ->expects ('exists ' )
160
+ ->with (dirname ($ certificateControllerTest ))
161
+ ->andReturnTrue ();
162
+ $ this ->files ->expects ('put ' )
163
+ ->with ($ certificateControllerTest , $ this ->fixture ('tests/certificate-pascal-case-example-laravel8.php ' ));
164
+
165
+ $ this ->files ->expects ('exists ' )
166
+ ->with (dirname ($ certificateTypeControllerTest ))
167
+ ->andReturnTrue ();
168
+ $ this ->files ->expects ('put ' )
169
+ ->with ($ certificateTypeControllerTest , $ this ->fixture ('tests/certificate-type-pascal-case-example-laravel8.php ' ));
170
+
171
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/pascal-case.yaml ' ));
172
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
173
+ $ this ->assertEquals (['created ' => [$ certificateControllerTest , $ certificateTypeControllerTest ]], $ this ->subject ->output ($ tree ));
174
+ }
175
+
111
176
/**
112
177
* @test
178
+ * @environment-setup useLaravel7
113
179
*/
114
180
public function output_generates_test_for_controller_tree_using_cached_model ()
115
181
{
@@ -142,6 +208,40 @@ public function output_generates_test_for_controller_tree_using_cached_model()
142
208
143
209
/**
144
210
* @test
211
+ * @environment-setup useLaravel8
212
+ */
213
+ public function output_generates_test_for_controller_tree_using_cached_model_l8 ()
214
+ {
215
+ $ this ->files ->expects ('stub ' )
216
+ ->with ('test.class.stub ' )
217
+ ->andReturn ($ this ->stub ('test.class.stub ' ));
218
+
219
+ $ this ->files ->expects ('stub ' )
220
+ ->with ('test.case.stub ' )
221
+ ->andReturn ($ this ->stub ('test.case.stub ' ));
222
+ $ this ->files ->expects ('exists ' )
223
+ ->with ('tests/Feature/Http/Controllers ' )
224
+ ->andReturnFalse ();
225
+ $ this ->files ->expects ('makeDirectory ' )
226
+ ->with ('tests/Feature/Http/Controllers ' , 0755 , true );
227
+ $ this ->files ->expects ('put ' )
228
+ ->with ('tests/Feature/Http/Controllers/UserControllerTest.php ' , $ this ->fixture ('tests/reference-cache-laravel8.php ' ));
229
+
230
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/reference-cache.yaml ' ));
231
+ $ tokens ['cache ' ] = [
232
+ 'User ' => [
233
+ 'email ' => 'string ' ,
234
+ 'password ' => 'string ' ,
235
+ ]
236
+ ];
237
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
238
+
239
+ $ this ->assertEquals (['created ' => ['tests/Feature/Http/Controllers/UserControllerTest.php ' ]], $ this ->subject ->output ($ tree ));
240
+ }
241
+
242
+ /**
243
+ * @test
244
+ * @environment-setup useLaravel7
145
245
*/
146
246
public function output_generates_tests_with_models_with_custom_namespace_correctly ()
147
247
{
@@ -173,6 +273,40 @@ public function output_generates_tests_with_models_with_custom_namespace_correct
173
273
$ this ->assertEquals (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
174
274
}
175
275
276
+ /**
277
+ * @test
278
+ * @environment-setup useLaravel8
279
+ */
280
+ public function output_generates_tests_with_models_with_custom_namespace_correctly_l8 ()
281
+ {
282
+ $ definition = 'drafts/models-with-custom-namespace.yaml ' ;
283
+ $ path = 'tests/Feature/Http/Controllers/CategoryControllerTest.php ' ;
284
+ $ test = 'tests/models-with-custom-namespace-laravel8.php ' ;
285
+
286
+ $ this ->app ['config ' ]->set ('blueprint.models_namespace ' , 'Models ' );
287
+
288
+ $ this ->files ->expects ('stub ' )
289
+ ->with ('test.class.stub ' )
290
+ ->andReturn ($ this ->stub ('test.class.stub ' ));
291
+
292
+ $ this ->files ->expects ('stub ' )
293
+ ->with ('test.case.stub ' )
294
+ ->andReturn ($ this ->stub ('test.case.stub ' ));
295
+ $ dirname = dirname ($ path );
296
+ $ this ->files ->expects ('exists ' )
297
+ ->with ($ dirname )
298
+ ->andReturnFalse ();
299
+ $ this ->files ->expects ('makeDirectory ' )
300
+ ->with ($ dirname , 0755 , true );
301
+ $ this ->files ->expects ('put ' )
302
+ ->with ($ path , $ this ->fixture ($ test ));
303
+
304
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ($ definition ));
305
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
306
+
307
+ $ this ->assertEquals (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
308
+ }
309
+
176
310
public function controllerTreeDataProvider ()
177
311
{
178
312
return [
@@ -184,4 +318,16 @@ public function controllerTreeDataProvider()
184
318
['drafts/model-reference-validate.yaml ' , 'tests/Feature/Http/Controllers/CertificateControllerTest.php ' , 'tests/api-shorthand-validation.php ' ],
185
319
];
186
320
}
321
+
322
+ public function laravel8ControllerTreeDataProvider ()
323
+ {
324
+ return [
325
+ ['drafts/readme-example.yaml ' , 'tests/Feature/Http/Controllers/PostControllerTest.php ' , 'tests/readme-example-laravel8.php ' ],
326
+ ['drafts/readme-example-notification-facade.yaml ' , 'tests/Feature/Http/Controllers/PostControllerTest.php ' , 'tests/readme-example-notification-laravel8.php ' ],
327
+ ['drafts/readme-example-notification-model.yaml ' , 'tests/Feature/Http/Controllers/PostControllerTest.php ' , 'tests/readme-example-notification-laravel8.php ' ],
328
+ ['drafts/respond-statements.yaml ' , 'tests/Feature/Http/Controllers/Api/PostControllerTest.php ' , 'tests/respond-statements-laravel8.php ' ],
329
+ ['drafts/full-crud-example.yaml ' , 'tests/Feature/Http/Controllers/PostControllerTest.php ' , 'tests/full-crud-example-laravel8.php ' ],
330
+ ['drafts/model-reference-validate.yaml ' , 'tests/Feature/Http/Controllers/CertificateControllerTest.php ' , 'tests/api-shorthand-validation-laravel8.php ' ],
331
+ ];
332
+ }
187
333
}
0 commit comments