コード例 #1
0
ファイル: Form.php プロジェクト: docteurklein/event-store
 function it_compares_submitted_version_and_refuses_conflict()
 {
     $product = new Product($id = Uuid::uuid4());
     $product->rename('A');
     $this->repository->save($product);
     $fetch1 = $this->repository->find(Product::class, (string) $id)->get();
     $form = $this->forms->create('form', $fetch1);
     $form->submit(['version' => 3]);
     expect($this->repository)->toThrow(Conflict::class)->during('save', [$fetch1]);
 }
コード例 #2
0
 function it_refuses_to_store_superseeded_versions()
 {
     $directRepo = (new Repository\Factory($this->store))->create();
     $repository = (new Repository\Factory(new Store\Concurrency\Optimistic($this->store, new VersionTransporter\InMemory(1))))->create();
     $product = new Product(null, 'test');
     $product->rename('1');
     $product->rename('2');
     $directRepo->save($product);
     $fetch = $directRepo->find(Product::class, (string) $product->getId())->get();
     $fetch->rename('change 1');
     expect($repository)->toThrow(Conflict::class)->during('save', [$fetch]);
 }
コード例 #3
0
<?php

use example\Shop\Model\Product;
use example\Shop\Model\Attribute;
use Rhumsaa\Uuid\Uuid;
use example\Shop\Model\Price;
require __DIR__ . '/_base.php';
foreach (range(1, 1000) as $i) {
    $shoe = new Product($idShoe = Uuid::uuid4(), "a {$i} shoe", [new Attribute(Uuid::uuid4(), 'size', 4), new Attribute(Uuid::uuid4(), 'color', 'blue'), new Attribute(Uuid::uuid4(), 'price', new Price('EUR', 40 * $i))]);
    foreach (range(1, 10) as $j) {
        $shoe->rename("shoe {$i} {$j}");
        $shoe->addAttribute(new Attribute(Uuid::uuid4(), "length {$i}", 10 + $j));
    }
    $repository->save($shoe);
    var_dump((string) $shoe);
}