Skip to content
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

Help needed... Preconditions are not working in test scenarios #216

Closed
Parables opened this issue Jul 30, 2023 · 2 comments
Closed

Help needed... Preconditions are not working in test scenarios #216

Parables opened this issue Jul 30, 2023 · 2 comments

Comments

@Parables
Copy link

I've been trying to set up preconditions for my test scenarios using the given method, but it doesn't seem to be working.

I am using the example provided in the documentation found at https://eventsauce.io/docs/testing/preconditions/ to set up preconditions for my test scenarios.
Specifically, I'm using the SignUpProcess class as an aggregate root to initiate a sign-up process, and I'm trying to record events that occur during the sign-up process using the recordThat method. However, when I try to apply these events using the apply methods, they don't seem to be working as expected.

I've looked at the code examples provided in the documentation and I'm still having trouble figuring out what's going wrong. Has anyone else experienced similar issues with preconditions in test scenarios? Any help would be greatly appreciated.

Thank you.

@frankdejonge
Copy link
Member

@Parables Hi, can you show some code that highlights your problem? You're stating that the apply method does not work as expected, can you elaborate? Normal eventsauce usage would not involve needing to manually invoke that method, so you're most likely doing something wrong 😅

@Parables
Copy link
Author

Please accept my apologies for bothering you about this issue.
I eventually figured it out after scrutinising the docs.

Turns out I was creating new instances of the AggregateRootId
instead of using the one setup in the TestCase file.

it('can initiate a sign up process',function (){
-        $processId = ProcessId::create();
+        $processId = test()->aggregateRootId();

       $this->when(new InitiateSignUpProcess(
           $processId,
       ))->then(new SignUpProcessWasInitiated()); 
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants