|
1373 | 1373 | && $mail-> hasReplyTo( '[email protected]', 'Reply');
|
1374 | 1374 | });
|
1375 | 1375 | });
|
| 1376 | + |
| 1377 | +it('does not send the template tags to provider if not enabled', function () { |
| 1378 | + Config::set('mailcarrier.send.template_tags', false); |
| 1379 | + |
| 1380 | + Template::factory()->create([ |
| 1381 | + 'slug' => 'welcome', |
| 1382 | + 'tags' => ['tag1'], |
| 1383 | + ]); |
| 1384 | + |
| 1385 | + postJson(route('mailcarrier.send'), [ |
| 1386 | + 'enqueue' => false, |
| 1387 | + 'template' => 'welcome', |
| 1388 | + 'subject' => 'Welcome!', |
| 1389 | + 'recipient' => '[email protected]', |
| 1390 | + 'tags' => ['foo'], |
| 1391 | + ])->assertOk(); |
| 1392 | + |
| 1393 | + Mail::assertSent(GenericMail::class, 1); |
| 1394 | + Mail::assertSent(GenericMail::class, function (GenericMail $mail) { |
| 1395 | + $mail->build(); |
| 1396 | + |
| 1397 | + return $mail-> hasTo( '[email protected]') |
| 1398 | + && $mail->hasSubject('Welcome!') |
| 1399 | + && $mail->hasTag('foo') |
| 1400 | + && !$mail->hasTag('tag1'); |
| 1401 | + }); |
| 1402 | +}); |
| 1403 | + |
| 1404 | +it('sends the template tags to provider when enabled', function () { |
| 1405 | + Config::set('mailcarrier.send.template_tags', true); |
| 1406 | + |
| 1407 | + Template::factory()->create([ |
| 1408 | + 'slug' => 'welcome', |
| 1409 | + 'tags' => ['tag1'], |
| 1410 | + ]); |
| 1411 | + |
| 1412 | + postJson(route('mailcarrier.send'), [ |
| 1413 | + 'enqueue' => false, |
| 1414 | + 'template' => 'welcome', |
| 1415 | + 'subject' => 'Welcome!', |
| 1416 | + 'recipient' => '[email protected]', |
| 1417 | + ])->assertOk(); |
| 1418 | + |
| 1419 | + Mail::assertSent(GenericMail::class, 1); |
| 1420 | + Mail::assertSent(GenericMail::class, function (GenericMail $mail) { |
| 1421 | + $mail->build(); |
| 1422 | + |
| 1423 | + return $mail-> hasTo( '[email protected]') |
| 1424 | + && $mail->hasSubject('Welcome!') |
| 1425 | + && $mail->hasTag('tag1'); |
| 1426 | + }); |
| 1427 | +}); |
| 1428 | + |
| 1429 | +it('merges the template tags along with request ones', function () { |
| 1430 | + Config::set('mailcarrier.send.template_tags', true); |
| 1431 | + |
| 1432 | + Template::factory()->create([ |
| 1433 | + 'slug' => 'welcome', |
| 1434 | + 'tags' => ['tag1'], |
| 1435 | + ]); |
| 1436 | + |
| 1437 | + postJson(route('mailcarrier.send'), [ |
| 1438 | + 'enqueue' => false, |
| 1439 | + 'template' => 'welcome', |
| 1440 | + 'subject' => 'Welcome!', |
| 1441 | + 'recipient' => '[email protected]', |
| 1442 | + 'tags' => ['foo'], |
| 1443 | + ])->assertOk(); |
| 1444 | + |
| 1445 | + Mail::assertSent(GenericMail::class, 1); |
| 1446 | + Mail::assertSent(GenericMail::class, function (GenericMail $mail) { |
| 1447 | + $mail->build(); |
| 1448 | + |
| 1449 | + return $mail-> hasTo( '[email protected]') |
| 1450 | + && $mail->hasSubject('Welcome!') |
| 1451 | + && $mail->hasTag('foo') |
| 1452 | + && $mail->hasTag('tag1'); |
| 1453 | + }); |
| 1454 | +}); |
0 commit comments