Last active
November 12, 2016 10:26
-
-
Save prolic/026caaad55e9f990cd4b2d5000e2735e to your computer and use it in GitHub Desktop.
create test-stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of the prooph/event-store-http-api. | |
* (c) 2016-2016 prooph software GmbH <[email protected]> | |
* (c) 2016-2016 Sascha-Oliver Prolic <[email protected]> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
namespace Prooph\EventStore\Http\Api; | |
use Prooph\EventStore\EventStore; | |
use Prooph\EventStore\Stream; | |
use Prooph\EventStore\StreamName; | |
use ProophTest\EventStore\Mock\UserCreated; | |
use ProophTest\EventStore\Mock\UsernameChanged; | |
require 'vendor/autoload.php'; | |
$container = include 'config/container.php'; | |
$eventStore = $container->get(EventStore::class); | |
/* @var EventStore $eventStore */ | |
$events = []; | |
$event = UserCreated::with(['firstName' => 'Fritz', 'lastName' => 'Heinz'], 1); | |
$event = $event->withAddedMetadata('_aggregate_id', $event->uuid()->toString()); | |
$event = $event->withAddedMetadata('_aggregate_type', 'user'); | |
$events[] = $event; | |
for ($i = 2; $i < 400; $i++) { | |
$event = UsernameChanged::with(['firstName' => uniqid(), 'lastName' => uniqid()], $i); | |
$event = $event->withAddedMetadata('_aggregate_id', $event->uuid()->toString()); | |
$event = $event->withAddedMetadata('_aggregate_type', 'user'); | |
$events[] = $event; | |
} | |
$eventStore->create(new Stream(new StreamName('Prooph\Model\User'), new \ArrayIterator($events))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment