/** @test */
 function it_should_create_an_stored_event_from_a_given_domain_event()
 {
     $event = new InstantaneousEvent(Identifier::fromString('abc'), Money::MXN(500000), new DateTime('2015-10-25 19:59:00'));
     $factory = new StoredEventFactory(new JsonSerializer());
     $storedEvent = $factory->from($event);
     // Stored events get an ID after being persisted
     $this->assertEquals(null, $storedEvent->id());
     $this->assertEquals('{"occurred_on":"2015-10-25 19:59:00","member_id":"abc","amount":500000}', $storedEvent->body());
     $this->assertEquals(InstantaneousEvent::class, $storedEvent->type());
     $this->assertEquals('2015-10-25 19:59:00', $storedEvent->occurredOn()->format('Y-m-d H:i:s'));
 }
Ejemplo n.º 2
0
 /** @before */
 function generateFixtures()
 {
     $this->store = $this->storeInstance();
     $factory = new StoredEventFactory(new JsonSerializer());
     $event1 = $factory->from(A::transferWasMadeEvent()->build());
     $this->event2 = $factory->from(A::transferWasMadeEvent()->build());
     $event3 = $factory->from(A::transferWasMadeEvent()->build());
     $this->event4 = $factory->from(A::transferWasMadeEvent()->build());
     $this->store->append($event1);
     $this->store->append($this->event2);
     $this->store->append($event3);
     $this->store->append($this->event4);
 }