<?php

declare(strict_types=1);

namespace App\Framework\EventSourcing\Demo;

use App\Framework\EventSourcing\AggregateId;

final class DemoTest
{
    public function __construct()
    {

        $aggregateId = AggregateId::generate();
        $domainId = DemoAggregateDomainId::generate();

        $aggregate = DemoAggregate::create($aggregateId, $domainId);

        $aggregate->eventHappened(new DemoAggregateEvent($domainId));

        $aggregate->root->eventRecorder->pullRecordedEvents();

        $rehydrated = DemoAggregate::rehydrate($aggregateId, $aggregate->root->eventRecorder->pullRecordedEvents());

        var_dump("<pre>", $rehydrated);
    }
}
