PaymentTransactionStructFactory example


#[Package('checkout')] class PaymentTransactionStructFactoryTest extends TestCase
{
    public function testDecorated(): void
    {
        static::expectException(DecorationPatternException::class);

        $factory = new PaymentTransactionStructFactory();
        $factory->getDecorated();
    }

    public function testDecoration(): void
    {
        $factory = new class() extends PaymentTransactionStructFactory {
            public function getDecorated(): AbstractPaymentTransactionStructFactory
            {
                return new static();
            }
        };

        
->expects(static::once())
            ->method('dispatch')
            ->with(static::isInstanceOf(PayPaymentOrderCriteriaEvent::class));

        $processor = new PaymentTransactionChainProcessor(
            $this->createMock(TokenFactoryInterfaceV2::class),
            $orderRepository,
            $this->createMock(RouterInterface::class),
            $this->createMock(PaymentHandlerRegistry::class),
            $this->createMock(SystemConfigService::class),
            $this->createMock(InitialStateIdLoader::class),
            new PaymentTransactionStructFactory(),
            $eventDispatcher,
        );

        if (!Feature::isActive('v6.6.0.0')) {
            $this->expectException(InvalidOrderException::class);
        }
        $this->expectException(PaymentException::class);
        static::expectExceptionMessage(
            \sprintf('The order with id %s is invalid or could not be found.', $this->ids->get('test-order'))
        );

        
$dispatcher = $this->createMock(EventDispatcherInterface::class);
        $dispatcher
            ->expects(static::once())
            ->method('dispatch')
            ->with(static::isInstanceOf(RecurringPaymentOrderCriteriaEvent::class));

        $processor = new PaymentRecurringProcessor(
            $repo,
            $this->createMock(InitialStateIdLoader::class),
            $this->createMock(OrderTransactionStateHandler::class),
            $this->createMock(PaymentHandlerRegistry::class),
            new PaymentTransactionStructFactory(),
            $dispatcher,
        );

        static::expectException(OrderException::class);

        $processor->processRecurring($orderId, Context::createDefaultContext());
    }

    public function testOrderNotFoundException(): void
    {
        $repo = $this->createMock(EntityRepository::class);
        
Home | Imprint | This part of the site doesn't use cookies.