/** * Create a Part in the event store as well as in the read model * @param Request $request * @return Response */ public function store(Request $request) { $partId = PartId::generate(); $manufacturerId = ManufacturerId::generate(); $command = new ManufacturePartCommand($partId, $manufacturerId, $request->get('manufacturer-name')); $this->commandBus->dispatch($command); return Redirect::route('parts.index')->with('success', 'Part successfully created.'); }
/** @test */ public function should_test_equality() { $one = PartId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $two = PartId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $three = PartId::generate(); $this->assertTrue($one->equals($two)); $this->assertFalse($one->equals($three)); }
/** * @test */ public function it_does_not_rename_manufacturer_to_the_same_name() { $id = PartId::generate(); $this->scenario->withAggregateId($id)->given([new PartWasManufacturedEvent($id, 'acme', 'Acme, Inc'), new PartWasManufacturedEvent($id, 'acme', 'Acme, Inc.')])->when(new RenameManufacturerForPartCommand($id, 'Acme, Inc.'))->then([]); }
/** * @return \Modules\Core\Domain\Identifier */ private function makeNewPartId() { $id = PartId::generate(); return PartId::fromString($id); }