@@ -30,7 +30,7 @@ protected function setUp(): void
30
30
/**
31
31
* @test
32
32
*/
33
- public function output_writes_nothing_for_empty_tree ()
33
+ public function output_generates_nothing_for_empty_tree ()
34
34
{
35
35
$ this ->files ->expects ('stub ' )
36
36
->with ('model/class.stub ' )
@@ -45,7 +45,7 @@ public function output_writes_nothing_for_empty_tree()
45
45
* @test
46
46
* @dataProvider modelTreeDataProvider
47
47
*/
48
- public function output_writes_migration_for_model_tree ($ definition , $ path , $ model )
48
+ public function output_generates_models ($ definition , $ path , $ model )
49
49
{
50
50
$ this ->files ->expects ('stub ' )
51
51
->with ('model/class.stub ' )
@@ -112,6 +112,45 @@ public function output_respects_configuration()
112
112
$ this ->assertEquals (['created ' => ['src/path/Models/Comment.php ' ]], $ this ->subject ->output ($ tree ));
113
113
}
114
114
115
+ /**
116
+ * @test
117
+ * @dataProvider docBlockModelsDataProvider
118
+ */
119
+ public function output_generates_phpdoc_for_model ($ definition , $ path , $ model )
120
+ {
121
+ $ this ->app ['config ' ]->set ('blueprint.generate_phpdocs ' , true );
122
+
123
+ $ this ->files ->expects ('stub ' )
124
+ ->with ('model/class.stub ' )
125
+ ->andReturn (file_get_contents ('stubs/model/class.stub ' ));
126
+
127
+ $ this ->files ->expects ('stub ' )
128
+ ->with ('model/fillable.stub ' )
129
+ ->andReturn (file_get_contents ('stubs/model/fillable.stub ' ));
130
+
131
+ $ this ->files ->expects ('stub ' )
132
+ ->with ('model/casts.stub ' )
133
+ ->andReturn (file_get_contents ('stubs/model/casts.stub ' ));
134
+
135
+ if ($ definition === 'definitions/readme-example.bp ' ) {
136
+ $ this ->files ->expects ('stub ' )
137
+ ->with ('model/dates.stub ' )
138
+ ->andReturn (file_get_contents ('stubs/model/dates.stub ' ));
139
+ }
140
+
141
+ $ this ->files ->shouldReceive ('stub ' )
142
+ ->with ('model/method.stub ' )
143
+ ->andReturn (file_get_contents ('stubs/model/method.stub ' ));
144
+
145
+ $ this ->files ->expects ('put ' )
146
+ ->with ($ path , $ this ->fixture ($ model ));
147
+
148
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ($ definition ));
149
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
150
+
151
+ $ this ->assertEquals (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
152
+ }
153
+
115
154
public function modelTreeDataProvider ()
116
155
{
117
156
return [
@@ -123,4 +162,13 @@ public function modelTreeDataProvider()
123
162
['definitions/nested-components.bp ' , 'app/Admin/User.php ' , 'models/nested-components.php ' ],
124
163
];
125
164
}
165
+
166
+ public function docBlockModelsDataProvider ()
167
+ {
168
+ return [
169
+ ['definitions/readme-example.bp ' , 'app/Post.php ' , 'models/readme-example-phpdoc.php ' ],
170
+ ['definitions/soft-deletes.bp ' , 'app/Comment.php ' , 'models/soft-deletes-phpdoc.php ' ],
171
+ ['definitions/disable-auto-columns.bp ' , 'app/State.php ' , 'models/disable-auto-columns-phpdoc.php ' ],
172
+ ];
173
+ }
126
174
}
0 commit comments