Git Product home page Git Product logo

Comments (3)

frankdejonge avatar frankdejonge commented on June 6, 2024

So the first one seems relatively straight forward to resolve from what I can see here. The CategoryCreated event should have a categoryId, so you test it like this:

public function test_adding_a_person_to_an_event_with_category()
{
    $categoryId = uuid();

    $this->given(
        new EventStarted(),
        new CategoryCreated($categoryId)
    )->when(
        new AddPerson($this->aggregateRootId, $categoryId), // <- what is $categoryId?
    )->then(
        new PersonAdded(),
    );
}

The trick for this to always have deterministic identifiers. Your command to create the category should contain the ID to create it and the corresponding event should have to ID for future reference. For the other case, you've got two models that interact with each other. For this, you can use a process manager that listens to events from one aggregate and act on the other. Process managers are explained in the docs and are basically just consumers of messages that, instead of accumulating state, act. So to test this you have your first aggregate, test it in isolation. Test the process manager (only needs to forward the calls) and then test the person aggregate. You shouldn't want to capture this in one test because it's a different unit of isolation. Let me know if this helps, if not we can discuss further.

from eventsauce.

erikgaal avatar erikgaal commented on June 6, 2024

The first one makes sense that way.

On the last one; I've discussed it with my team too, that it makes sense to be able to test each aggregate in isolation. However, due to invariants being as much as across the entire domain, we were confused with how to split up the aggregates and how to test these.

Thank you for you quick response @frankdejonge, we'll explore this and report back with our solution.

from eventsauce.

frankdejonge avatar frankdejonge commented on June 6, 2024

Closing this for inactivity, can be re-opened later if needed.

from eventsauce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.