Skip to content

Cannot test subscribers with $recordedOn and custom headers #18

@fritz-gerneth

Description

@fritz-gerneth

Setting up Subscriber tests as detailed here works in general. But once a callback expects additional arguments like $recordedOn, or any other custom ArgumentResolver this fails. Passing the array of ArgumentResolvers does not help either - that information is simply not available.

When I change the executeRun method to accept messages instead, and pass the RecordedAtHeader as an header along, everything works as expected.

Figure it might make sense to add an additional function here that does this:

    /** @param array<Message> $messages */
    public function executeRun(array $messages): self
    {
        $subscriberAccessors = $this->subscriberAccessorRepository->all();

        foreach ($messages as $message) {
            $eventClass = $message->event()::class;

            foreach ($subscriberAccessors as $subscriberAccessor) {
                foreach ($subscriberAccessor->subscribeMethods($eventClass) as $subscribeMethod) {
                    $subscribeMethod($message);
                }
            }
        }

        return $this;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions