TransportFactoryTestCase.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Mailer\Test;
  11. use Psr\Log\LoggerInterface;
  12. use Psr\Log\NullLogger;
  13. use Symfony\Component\EventDispatcher\EventDispatcher;
  14. use Symfony\Component\HttpClient\MockHttpClient;
  15. use Symfony\Component\Mailer\Transport\Dsn;
  16. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  17. use Symfony\Contracts\HttpClient\HttpClientInterface;
  18. /**
  19. * A test case to ease testing Transport Factory.
  20. *
  21. * @author Konstantin Myakshin <molodchick@gmail.com>
  22. *
  23. * @deprecated since Symfony 7.2, use AbstractTransportFactoryTestCase instead
  24. */
  25. abstract class TransportFactoryTestCase extends AbstractTransportFactoryTestCase
  26. {
  27. use IncompleteDsnTestTrait;
  28. protected EventDispatcherInterface $dispatcher;
  29. protected HttpClientInterface $client;
  30. protected LoggerInterface $logger;
  31. /**
  32. * @psalm-return iterable<array{0: Dsn, 1?: string|null}>
  33. */
  34. public static function unsupportedSchemeProvider(): iterable
  35. {
  36. return [];
  37. }
  38. /**
  39. * @psalm-return iterable<array{0: Dsn}>
  40. */
  41. public static function incompleteDsnProvider(): iterable
  42. {
  43. return [];
  44. }
  45. protected function getDispatcher(): EventDispatcherInterface
  46. {
  47. return $this->dispatcher ??= new EventDispatcher();
  48. }
  49. protected function getClient(): HttpClientInterface
  50. {
  51. return $this->client ??= new MockHttpClient();
  52. }
  53. protected function getLogger(): LoggerInterface
  54. {
  55. return $this->logger ??= new NullLogger();
  56. }
  57. }