Skip to content

Instantly share code, notes, and snippets.

@prolic
Last active November 12, 2016 10:26
Show Gist options
  • Save prolic/026caaad55e9f990cd4b2d5000e2735e to your computer and use it in GitHub Desktop.
Save prolic/026caaad55e9f990cd4b2d5000e2735e to your computer and use it in GitHub Desktop.
create test-stream
<?php
/**
* This file is part of the prooph/event-store-http-api.
* (c) 2016-2016 prooph software GmbH <contact@prooph.de>
* (c) 2016-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* 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