@@ -197,6 +197,7 @@ public function output_generates_phpdoc_for_model($definition, $path, $model)
197
197
$ this ->files ->expects ('exists ' )
198
198
->with (dirname ($ path ))
199
199
->andReturnTrue ();
200
+
200
201
$ this ->files ->expects ('put ' )
201
202
->with ($ path , $ this ->fixture ($ model ));
202
203
@@ -206,6 +207,42 @@ public function output_generates_phpdoc_for_model($definition, $path, $model)
206
207
$ this ->assertEquals (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
207
208
}
208
209
210
+ /**
211
+ * @test
212
+ */
213
+ public function output_generates_models_with_guarded_property_when_config_option_is_set ()
214
+ {
215
+ $ this ->app ['config ' ]->set ('blueprint.use_guarded ' , true );
216
+
217
+ $ this ->files ->expects ('stub ' )
218
+ ->with ('model/class.stub ' )
219
+ ->andReturn (file_get_contents ('stubs/model/class.stub ' ));
220
+
221
+ $ this ->files ->expects ('stub ' )
222
+ ->with ('model/guarded.stub ' )
223
+ ->andReturn (file_get_contents ('stubs/model/guarded.stub ' ));
224
+
225
+ $ this ->files ->expects ('stub ' )
226
+ ->with ('model/casts.stub ' )
227
+ ->andReturn (file_get_contents ('stubs/model/casts.stub ' ));
228
+
229
+ $ this ->files ->shouldReceive ('stub ' )
230
+ ->with ('model/method.stub ' )
231
+ ->andReturn (file_get_contents ('stubs/model/method.stub ' ));
232
+
233
+ $ this ->files ->expects ('exists ' )
234
+ ->with (dirname ('app/Comment.php ' ))
235
+ ->andReturnTrue ();
236
+
237
+ $ this ->files ->expects ('put ' )
238
+ ->with ('app/Comment.php ' , $ this ->fixture ('models/model-guarded.php ' ));
239
+
240
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('definitions/model-guarded.bp ' ));
241
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
242
+
243
+ $ this ->assertEquals (['created ' => ['app/Comment.php ' ]], $ this ->subject ->output ($ tree ));
244
+ }
245
+
209
246
public function modelTreeDataProvider ()
210
247
{
211
248
return [
0 commit comments