| Conditions | 5 |
| Paths | 9 |
| Total Lines | 20 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | final protected function messenger(?string $transport = null): TestTransport |
||
| 25 | { |
||
| 26 | if (!$this instanceof KernelTestCase) { |
||
| 27 | throw new \LogicException(\sprintf('The %s trait can only be used with %s.', __TRAIT__, KernelTestCase::class)); |
||
| 28 | } |
||
| 29 | |||
| 30 | if (!self::$booted) { |
||
| 31 | self::bootKernel(); |
||
| 32 | } |
||
| 33 | |||
| 34 | $container = \method_exists($this, 'getContainer') ? self::getContainer() : self::$container; |
||
| 35 | |||
| 36 | if (!$container->has('zenstruck_messenger_test.transport_registry')) { |
||
| 37 | throw new \LogicException('Cannot access transport - is ZenstruckMessengerTestBundle enabled in your test environment?'); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** @var TestTransportRegistry $registry */ |
||
| 41 | $registry = $container->get('zenstruck_messenger_test.transport_registry'); |
||
| 42 | |||
| 43 | return $registry->get($transport); |
||
| 44 | } |
||
| 46 |