MailerSendWithUnsetTemplateDefaultsToActionNameTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @since 5.0.0
  12. * @license https://opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Cake\Test\TestCase\Mailer;
  15. use Cake\Mailer\Mailer;
  16. use Cake\TestSuite\TestCase;
  17. class MailerSendWithUnsetTemplateDefaultsToActionNameTest extends TestCase
  18. {
  19. public function testSendAction(): void
  20. {
  21. $mailer = new class extends Mailer {
  22. public bool $testIsCalled = false;
  23. public function test($to, $subject)
  24. {
  25. $this->testIsCalled = true;
  26. }
  27. public function deliver(string $content = ''): array
  28. {
  29. return [];
  30. }
  31. protected function restore()
  32. {
  33. return $this;
  34. }
  35. };
  36. $mailer->send('test', ['foo', 'bar']);
  37. $this->assertSame('test', $mailer->viewBuilder()->getTemplate());
  38. $this->assertTrue($mailer->testIsCalled);
  39. }
  40. }