public function create(ClassType $classType, Parameter $parameter)
 {
     $source = $this->sourceFactory->create($classType);
     $source->addParent(ClassType::create('Broadway\\EventSourcing\\EventSourcedAggregateRoot'));
     //Add aggregate root id as property.
     $source->addProperty($parameter);
     $source->addImport($parameter->getClassType());
     //Add static create() method.
     $source->addMethod($this->definitionFactory->createBroadwayModelCreateMethod($classType, [$parameter]));
     //Add aggregate root id getter.
     $source->addMethod($this->definitionFactory->createBroadwayModelAggregateRootIdGetterMethod($parameter));
     return $source;
 }
 public function it_will_create_source_from_given_class_type_and_aggregate_root_id_param(ClassSourceFactory $sourceFactory, DefinitionFactory $definitionFactory, ClassType $classType, ImprovedClassSource $classSource, Parameter $parameter, ClassType $parameterClassType, CreateMethod $createMethod, AggregateRootIdGetterMethod $aggregateRootIdGetterMethod)
 {
     $parameter->getClassType()->willReturn($parameterClassType);
     $sourceFactory->create($classType)->willReturn($classSource);
     $definitionFactory->createBroadwayModelCreateMethod($classType, [$parameter])->shouldBeCalled()->willReturn($createMethod);
     $definitionFactory->createBroadwayModelAggregateRootIdGetterMethod($parameter)->shouldBeCalled()->willReturn($aggregateRootIdGetterMethod);
     $this->create($classType, $parameter)->shouldReturn($classSource);
 }