-
-
Notifications
You must be signed in to change notification settings - Fork 52
Assert Dispatched #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assert Dispatched #151
Conversation
A child workflow behaves as just another activity to the parent. It should be mocked and tested separately as its own workflow. |
You can run |
|
||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\App; | ||
use PHPUnit\Framework\Assert as PHPUnit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a problem with this because PHPUnit is usually require-dev not require and neither are actually listed in our composer.json. So we should only expect PHPUnit to be installed when running tests. I will do some more local testing to make sure.
I have made a couple of changes. I have moved everything into a Fakes trait. I added the Macroable trait and now the test methods are only added via macros if you call |
This PR allows your tests to assert that a certain workflow/activity was dispatched.
Motivation behind this PR:
Assume we have the following workflow structure:
CreateAndLinkEntities
CreateEntity1
returns$entity1Id
CreateEntity2
returns$entity2Id
LinkEntity1WithEntity2
returnsvoid
[$entity1Id, $entity2Id]
The latest release allows us to mock all three activities, but we cannot verify that the last activity has been dispatched.
With this PR you can now write:
This will also work to assert that a child workflow was dispatch.
It currently fails when we do not mock the child workflow itself, but we want to assert that the activities of the child workflow have been dispatched. We want to achieve some end-to-end-testing here.
It does not work because
WithoutOverlappingMiddleware
tries to get a lock on the parent workflow when trying to call thehandle
-Method on the child workflow.@rmcdaniel So before finalizing this PR: What is your opinion on this issue?