ServiceLocator example

/** * @internal * * @covers \Shopware\Core\Framework\MessageQueue\Api\ConsumeMessagesController */
class ConsumeMessagesControllerTest extends TestCase
{
    public function testInvalidReceiver(): void
    {
        $controller = new ConsumeMessagesController(
            new ServiceLocator([]),
            $this->createMock(MessageBusInterface::class),
            $this->createMock(StopWorkerOnRestartSignalListener::class),
            $this->createMock(EarlyReturnMessagesListener::class),
            $this->createMock(MessageQueueStatsSubscriber::class),
            'async',
            '128M',
            20,
            $this->createMock(LockFactory::class)
        );

        static::expectException(MessageQueueException::class);
        
$recurring = $registry->getRecurringPaymentHandler($this->ids->get(RecurringPaymentHandlerInterface::class));
        static::assertInstanceOf(RecurringPaymentHandlerInterface::class$recurring);

        $foo = $registry->getRecurringPaymentHandler(Uuid::randomHex());
        static::assertNull($foo);
    }

    public function testPaymentRegistryWithoutServices(): void
    {
        $registry = new PaymentHandlerRegistry(
            new ServiceLocator([]),
            new ServiceLocator([]),
            new ServiceLocator([]),
            new ServiceLocator([]),
            new ServiceLocator([]),
            $this->connection,
        );

        $sync = $registry->getSyncPaymentHandler($this->ids->get(SynchronousPaymentHandlerInterface::class));
        static::assertNull($sync);

        $async = $registry->getAsyncPaymentHandler($this->ids->get(AsynchronousPaymentHandlerInterface::class));
        
Home | Imprint | This part of the site doesn't use cookies.