@@ -39,6 +39,9 @@ public function output_writes_nothing_for_empty_tree()
39
39
$ this ->filesystem ->expects ('stub ' )
40
40
->with ('mail.stub ' )
41
41
->andReturn ($ this ->stub ('mail.stub ' ));
42
+ $ this ->filesystem ->expects ('stub ' )
43
+ ->with ('mail.view.stub ' )
44
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
42
45
43
46
$ this ->filesystem ->shouldNotHaveReceived ('put ' );
44
47
@@ -53,6 +56,9 @@ public function output_writes_nothing_tree_without_validate_statements()
53
56
$ this ->filesystem ->expects ('stub ' )
54
57
->with ('mail.stub ' )
55
58
->andReturn ($ this ->stub ('mail.stub ' ));
59
+ $ this ->filesystem ->expects ('stub ' )
60
+ ->with ('mail.view.stub ' )
61
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
56
62
57
63
$ this ->filesystem ->shouldNotHaveReceived ('put ' );
58
64
@@ -70,30 +76,57 @@ public function output_writes_mails()
70
76
$ this ->filesystem ->expects ('stub ' )
71
77
->with ('mail.stub ' )
72
78
->andReturn ($ this ->stub ('mail.stub ' ));
79
+ $ this ->filesystem ->expects ('stub ' )
80
+ ->with ('mail.view.stub ' )
81
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
73
82
$ this ->filesystem ->shouldReceive ('stub ' )
74
83
->with ('constructor.stub ' )
75
84
->andReturn ($ this ->stub ('constructor.stub ' ));
76
- $ this ->filesystem ->shouldReceive ('exists ' )
85
+ $ this ->filesystem ->expects ('exists ' )
77
86
->twice ()
78
87
->with ('app/Mail ' )
79
88
->andReturns (false , true );
89
+ $ this ->filesystem ->expects ('exists ' )
90
+ ->twice ()
91
+ ->with ('resources/views/emails ' )
92
+ ->andReturns (false , true );
80
93
$ this ->filesystem ->expects ('exists ' )
81
94
->with ('app/Mail/ReviewPost.php ' )
82
95
->andReturnFalse ();
83
96
$ this ->filesystem ->expects ('makeDirectory ' )
84
97
->with ('app/Mail ' , 0755 , true );
85
98
$ this ->filesystem ->expects ('put ' )
86
99
->with ('app/Mail/ReviewPost.php ' , $ this ->fixture ('mailables/review-post.php ' ));
100
+ $ this ->filesystem ->expects ('exists ' )
101
+ ->with ('resources/views/emails/review-post.blade.php ' )
102
+ ->andReturnFalse ();
103
+ $ this ->filesystem ->expects ('makeDirectory ' )
104
+ ->with ('resources/views/emails ' , 0755 , true );
105
+ $ this ->filesystem ->expects ('put ' )
106
+ ->with ('resources/views/emails/review-post.blade.php ' , $ this ->fixture ('mailables/review-post-view.blade.php ' ));
107
+
87
108
$ this ->filesystem ->expects ('exists ' )
88
109
->with ('app/Mail/PublishedPost.php ' )
89
110
->andReturnFalse ();
90
111
$ this ->filesystem ->expects ('put ' )
91
112
->with ('app/Mail/PublishedPost.php ' , $ this ->fixture ('mailables/published-post.php ' ));
113
+ $ this ->filesystem ->expects ('exists ' )
114
+ ->with ('resources/views/emails/published-post.blade.php ' )
115
+ ->andReturnFalse ();
116
+ $ this ->filesystem ->expects ('put ' )
117
+ ->with ('resources/views/emails/published-post.blade.php ' , $ this ->fixture ('mailables/published-post-view.blade.php ' ));
92
118
93
119
$ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/send-statements.yaml ' ));
94
120
$ tree = $ this ->blueprint ->analyze ($ tokens );
95
121
96
- $ this ->assertEquals (['created ' => ['app/Mail/ReviewPost.php ' , 'app/Mail/PublishedPost.php ' ]], $ this ->subject ->output ($ tree ));
122
+ $ this ->assertEquals ([
123
+ 'created ' => [
124
+ 'app/Mail/ReviewPost.php ' ,
125
+ 'resources/views/emails/review-post.blade.php ' ,
126
+ 'app/Mail/PublishedPost.php ' ,
127
+ 'resources/views/emails/published-post.blade.php ' ,
128
+ ],
129
+ ], $ this ->subject ->output ($ tree ));
97
130
}
98
131
99
132
/**
@@ -104,6 +137,9 @@ public function it_only_outputs_new_mails()
104
137
$ this ->filesystem ->expects ('stub ' )
105
138
->with ('mail.stub ' )
106
139
->andReturn ($ this ->stub ('mail.stub ' ));
140
+ $ this ->filesystem ->expects ('stub ' )
141
+ ->with ('mail.view.stub ' )
142
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
107
143
$ this ->filesystem ->expects ('exists ' )
108
144
->with ('app/Mail/ReviewPost.php ' )
109
145
->andReturnTrue ();
@@ -128,6 +164,9 @@ public function it_respects_configuration()
128
164
$ this ->filesystem ->expects ('stub ' )
129
165
->with ('mail.stub ' )
130
166
->andReturn ($ this ->stub ('mail.stub ' ));
167
+ $ this ->filesystem ->expects ('stub ' )
168
+ ->with ('mail.view.stub ' )
169
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
131
170
$ this ->filesystem ->expects ('stub ' )
132
171
->with ('constructor.stub ' )
133
172
->andReturn ($ this ->stub ('constructor.stub ' ));
@@ -141,11 +180,23 @@ public function it_respects_configuration()
141
180
->with ('src/path/Mail ' , 0755 , true );
142
181
$ this ->filesystem ->expects ('put ' )
143
182
->with ('src/path/Mail/ReviewPost.php ' , $ this ->fixture ('mailables/mail-configured.php ' ));
183
+ $ this ->filesystem ->expects ('exists ' )
184
+ ->with ('resources/views/emails/review-post.blade.php ' )
185
+ ->andReturnFalse ();
186
+ $ this ->filesystem ->expects ('makeDirectory ' )
187
+ ->with ('resources/views/emails ' , 0755 , true );
188
+ $ this ->filesystem ->expects ('put ' )
189
+ ->with ('resources/views/emails/review-post.blade.php ' , $ this ->fixture ('mailables/review-post-view.blade.php ' ));
144
190
145
191
$ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/readme-example.yaml ' ));
146
192
$ tree = $ this ->blueprint ->analyze ($ tokens );
147
193
148
- $ this ->assertEquals (['created ' => ['src/path/Mail/ReviewPost.php ' ]], $ this ->subject ->output ($ tree ));
194
+ $ this ->assertEquals ([
195
+ 'created ' => [
196
+ 'src/path/Mail/ReviewPost.php ' ,
197
+ 'resources/views/emails/review-post.blade.php ' ,
198
+ ],
199
+ ], $ this ->subject ->output ($ tree ));
149
200
}
150
201
151
202
/**
@@ -160,6 +211,9 @@ public function output_using_return_types()
160
211
$ this ->filesystem ->expects ('stub ' )
161
212
->with ('mail.stub ' )
162
213
->andReturn ($ this ->stub ('mail.stub ' ));
214
+ $ this ->filesystem ->expects ('stub ' )
215
+ ->with ('mail.view.stub ' )
216
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
163
217
$ this ->filesystem ->expects ('stub ' )
164
218
->with ('constructor.stub ' )
165
219
->andReturn ($ this ->stub ('constructor.stub ' ));
@@ -173,10 +227,113 @@ public function output_using_return_types()
173
227
->with ('src/path/Mail ' , 0755 , true );
174
228
$ this ->filesystem ->expects ('put ' )
175
229
->with ('src/path/Mail/ReviewPost.php ' , $ this ->fixture ('mailables/return-type-declarations.php ' ));
230
+ $ this ->filesystem ->expects ('exists ' )
231
+ ->with ('resources/views/emails/review-post.blade.php ' )
232
+ ->andReturnFalse ();
233
+ $ this ->filesystem ->expects ('makeDirectory ' )
234
+ ->with ('resources/views/emails ' , 0755 , true );
235
+ $ this ->filesystem ->expects ('put ' )
236
+ ->with ('resources/views/emails/review-post.blade.php ' , $ this ->fixture ('mailables/review-post-view.blade.php ' ));
176
237
177
238
$ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/readme-example.yaml ' ));
178
239
$ tree = $ this ->blueprint ->analyze ($ tokens );
179
240
180
- $ this ->assertEquals (['created ' => ['src/path/Mail/ReviewPost.php ' ]], $ this ->subject ->output ($ tree ));
241
+ $ this ->assertEquals ([
242
+ 'created ' => [
243
+ 'src/path/Mail/ReviewPost.php ' ,
244
+ 'resources/views/emails/review-post.blade.php ' ,
245
+ ],
246
+ ], $ this ->subject ->output ($ tree ));
247
+ }
248
+
249
+ /**
250
+ * @test
251
+ */
252
+ public function output_writes_mails_but_not_existing_templates ()
253
+ {
254
+ $ this ->filesystem ->expects ('stub ' )
255
+ ->with ('mail.stub ' )
256
+ ->andReturn ($ this ->stub ('mail.stub ' ));
257
+ $ this ->filesystem ->expects ('stub ' )
258
+ ->with ('mail.view.stub ' )
259
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
260
+ $ this ->filesystem ->shouldReceive ('stub ' )
261
+ ->with ('constructor.stub ' )
262
+ ->andReturn ($ this ->stub ('constructor.stub ' ));
263
+ $ this ->filesystem ->expects ('exists ' )
264
+ ->twice ()
265
+ ->with ('app/Mail ' )
266
+ ->andReturns (false );
267
+ $ this ->filesystem ->expects ('exists ' )
268
+ ->with ('app/Mail/ReviewPost.php ' )
269
+ ->andReturnFalse ();
270
+ $ this ->filesystem ->expects ('put ' )
271
+ ->with ('app/Mail/ReviewPost.php ' , $ this ->fixture ('mailables/review-post.php ' ));
272
+ $ this ->filesystem ->expects ('exists ' )
273
+ ->with ('resources/views/emails/review-post.blade.php ' )
274
+ ->andReturnTrue ();
275
+
276
+ $ this ->filesystem ->expects ('exists ' )
277
+ ->with ('app/Mail/PublishedPost.php ' )
278
+ ->andReturnFalse ();
279
+ $ this ->filesystem ->expects ('put ' )
280
+ ->with ('app/Mail/PublishedPost.php ' , $ this ->fixture ('mailables/published-post.php ' ));
281
+ $ this ->filesystem ->expects ('exists ' )
282
+ ->with ('resources/views/emails/published-post.blade.php ' )
283
+ ->andReturnTrue ();
284
+
285
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/send-statements.yaml ' ));
286
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
287
+
288
+ $ this ->assertEquals ([
289
+ 'created ' => [
290
+ 'app/Mail/ReviewPost.php ' ,
291
+ 'app/Mail/PublishedPost.php ' ,
292
+ ],
293
+ ], $ this ->subject ->output ($ tree ));
294
+ }
295
+
296
+ /**
297
+ * @test
298
+ */
299
+ public function output_writes_mail_with_custom_template ()
300
+ {
301
+ $ this ->filesystem ->expects ('stub ' )
302
+ ->with ('mail.stub ' )
303
+ ->andReturn ($ this ->stub ('mail.stub ' ));
304
+ $ this ->filesystem ->expects ('stub ' )
305
+ ->with ('mail.view.stub ' )
306
+ ->andReturn ($ this ->stub ('mail.view.stub ' ));
307
+ $ this ->filesystem ->shouldReceive ('stub ' )
308
+ ->with ('constructor.stub ' )
309
+ ->andReturn ($ this ->stub ('constructor.stub ' ));
310
+ $ this ->filesystem ->expects ('exists ' )
311
+ ->with ('app/Mail ' )
312
+ ->andReturns (true );
313
+ $ this ->filesystem ->expects ('exists ' )
314
+ ->with ('resources/views/emails/admin ' )
315
+ ->andReturns (false );
316
+ $ this ->filesystem ->expects ('exists ' )
317
+ ->with ('app/Mail/AddedAdmin.php ' )
318
+ ->andReturnFalse ();
319
+ $ this ->filesystem ->expects ('put ' )
320
+ ->with ('app/Mail/AddedAdmin.php ' , $ this ->fixture ('mailables/added-admin.php ' ));
321
+ $ this ->filesystem ->expects ('exists ' )
322
+ ->with ('resources/views/emails/admin/added.blade.php ' )
323
+ ->andReturnFalse ();
324
+ $ this ->filesystem ->expects ('makeDirectory ' )
325
+ ->with ('resources/views/emails/admin ' , 0755 , true );
326
+ $ this ->filesystem ->expects ('put ' )
327
+ ->with ('resources/views/emails/admin/added.blade.php ' , $ this ->fixture ('mailables/added-admin-view.blade.php ' ));
328
+
329
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/send-statement-with-view.yaml ' ));
330
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
331
+
332
+ $ this ->assertEquals ([
333
+ 'created ' => [
334
+ 'app/Mail/AddedAdmin.php ' ,
335
+ 'resources/views/emails/admin/added.blade.php ' ,
336
+ ],
337
+ ], $ this ->subject ->output ($ tree ));
181
338
}
182
339
}
0 commit comments