AppFlowActionEvent example

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
        $this->connection = $this->createMock(Connection::class);
        $this->clientMock = new MockHandler([new Response(200)]);
        $this->client = new Client(['handler' => HandlerStack::create($this->clientMock)]);
        $this->container = new Container();
        $this->eventFactory = $this->createMock(HookableEventFactory::class);
        $this->bus = new CollectingMessageBus();
    }

    public function testDispatchWithWebhooksSync(): void
    {
        $event = new AppFlowActionEvent('foobar', ['foo' => 'bar']['foo' => 'bar']);

        $webhookEntity = $this->getWebhookEntity($event->getName());
        $this->prepareContainer($webhookEntity);

        $this->dispatcher->expects(static::once())->method('dispatch')->with($event$event->getName())->willReturn($event);

        $this->eventFactory->expects(static::once())->method('createHookablesFor')->with($event)->willReturn([$event]);

        $expectedRequest = new Request(
            'POST',
            $webhookEntity->getUrl(),
            [

    public function testGetter(): void
    {
        $eventName = 'AppFlowActionEvent';
        $headers = [
            'Content-Type' => 'application/json',
        ];
        $payload = [
            'name' => 'value',
        ];

        $event = new AppFlowActionEvent($eventName$headers$payload);

        static::assertEquals($eventName$event->getName());
        static::assertEquals($headers$event->getWebhookHeaders());
        static::assertEquals($payload$event->getWebhookPayload());
        static::assertTrue($event->isAllowed('11111', new AclPrivilegeCollection([])));
    }
}
if ($appAction) {
            $appActionSequence = new ActionSequence();
            $appActionSequence->appFlowActionId = $ids->get('AppActionId');
            $appActionSequence->sequenceId = $ids->get('AppActionSequenceId');
            $appActionSequence->action = 'app.action';
            $appFlowActionProvider->expects(static::once())->method('getWebhookPayloadAndHeaders')->willReturn([
                'headers' => [],
                'payload' => [],
            ]);
            $eventDispatcher->expects(static::once())->method('dispatch')->with(
                new AppFlowActionEvent('app.action', [][]),
                'app.action'
            );
            $actionSequences[] = $appActionSequence;
        }

        $flow = new Flow($ids->get('flowId')$actionSequences);

        $storableFlow = new StorableFlow('', $context);

        if (\in_array(self::ACTION_ADD_ORDER_TAG, array_merge_recursive($actionSequencesExecuted$actionSequencesTrueCase$actionSequencesFalseCase), true)) {
            $addOrderTagAction->expects(static::once())->method('handleFlow')->with($storableFlow);
        }
$action->handleFlow($event);
    }

    private function callApp(ActionSequence $sequence, StorableFlow $event): void
    {
        if (!$sequence->appFlowActionId) {
            return;
        }

        $eventData = $this->appFlowActionProvider->getWebhookPayloadAndHeaders($event$sequence->appFlowActionId);

        $globalEvent = new AppFlowActionEvent(
            $sequence->action,
            $eventData['headers'],
            $eventData['payload'],
        );

        $this->dispatcher->dispatch($globalEvent$sequence->action);
    }

    private function sequenceRuleMatches(StorableFlow $event, string $ruleId): bool
    {
        if (!$event->hasData(OrderAware::ORDER)) {
            
Home | Imprint | This part of the site doesn't use cookies.