public function create(ClassType $classType, ClassType $modelClassType) { $source = $this->sourceFactory->create($classType); $source->addParent(ClassType::create('Broadway\\EventSourcing\\EventSourcingRepository')); $source->addImport(ClassType::create('Broadway\\EventSourcing\\AggregateFactory\\PublicConstructorAggregateFactory')); $source->addImport(ClassType::create('Broadway\\EventHandling\\EventBusInterface')); $source->addImport(ClassType::create('Broadway\\EventStore\\EventStoreInterface')); //Add aggregate root id as property. //Add constructor which calls parent constructor method. $source->addMethod($this->definitionFactory->createBroadwayModelRepositoryConstructorMethod($modelClassType)); return $source; }
public function it_will_create_source_from_given_class_type_and_target_entity(ClassSourceFactory $sourceFactory, DefinitionFactory $definitionFactory, ClassType $classType, ImprovedClassSource $classSource, ClassType $modelClassType, RepositoryConstructorMethod $repositoryConstructorMethod) { $sourceFactory->create($classType)->willReturn($classSource); $definitionFactory->createBroadwayModelRepositoryConstructorMethod($modelClassType)->shouldBeCalled()->willReturn($repositoryConstructorMethod); $this->create($classType, $modelClassType)->shouldReturn($classSource); }