function it_throws_exception_when_associated_entity_is_not_defied() { $definition = new Definition(new ClassName(EntityFake::getClassName()), new Definition\Identity("not_exists")); $association = new Definition\Association(new ClassName(EntityFakeChild::getClassName()), Definition\Association::TO_MANY_ENTITIES); $definition->addToObserved(new Definition\Property("children", $association)); $this->shouldThrow(new InvalidArgumentException("Entity class \"Isolate\\UnitOfWork\\Tests\\Double\\EntityFakeChild\" used in association of \"Isolate\\UnitOfWork\\Tests\\Double\\EntityFake\" entity does not have definition."))->during("__construct", [[$definition]]); }
/** * @return Definition */ private function createEntityDefinition() { $definition = new Definition(new ClassName(EntityFake::getClassName()), new Definition\Identity("id")); $definition->addToObserved(new Definition\Property("firstName")); $definition->addToObserved(new Definition\Property("lastName")); return $definition; }
/** * @return Definition */ public function createDefinition() { $this->entityDefinition->setNewCommandHandler(new NewCommandHandlerMock()); $this->entityDefinition->setEditCommandHandler(new EditCommandHandlerMock()); $this->entityDefinition->setRemoveCommandHandler(new RemoveCommandHandlerMock()); return $this->entityDefinition; }
/** * @param Definition $definition * @param Property $property * @throws InvalidArgumentException */ private function validateAssociation(Definition $definition, Property $property) { if ($property->isAssociated()) { $targetClass = (string) $property->getAssociation()->getTargetClassName(); if (!array_key_exists($targetClass, $this->entityDefinitions)) { throw new InvalidArgumentException(sprintf("Entity class \"%s\" used in association of \"%s\" entity does not have definition.", $targetClass, (string) $definition->getClassName())); } } }
public static function buildDefinition() { $definition = new Definition( new ClassName(EntityFake::getClassName()), new Definition\Identity("id") ); $definition->setObserved([ new Definition\Property("firstName"), new Definition\Property("lastName") ]); return $definition; }
/** * @return Definition */ public function createDefinition() { $definition = new Definition(new ClassName(Recipe::class), new Definition\Identity("name"), new IdentificationStrategy($this->storage)); $definition->setObserved([new Definition\Property("steps"), new Definition\Property("publicationDate"), new Definition\Property("description")]); $definition->setEditCommandHandler(new EditCommandHandler($this->storage, $this->searchEngine)); $definition->setNewCommandHandler(new NewCommandHandler($this->storage, $this->searchEngine)); $definition->setRemoveCommandHandler(new RemoveCommandHandler($this->storage, $this->searchEngine)); return $definition; }
/** * @return Definition */ private function createAssociatedEntityDefinition() { $definition = new Definition(new ClassName(AssociatedEntityFake::getClassName()), new Definition\Identity("id")); $parentAssociation = new Definition\Association(new ClassName(AssociatedEntityFake::getClassName()), Definition\Association::TO_SINGLE_ENTITY); $definition->setObserved([new Definition\Property("parent", $parentAssociation), new Definition\Property("children", $this->createChildrenAssociation()), new Definition\Property("name")]); return $definition; }
/** * @return RemoveCommandHandlerMock */ private function getEntityFakeRemoveCommandHandler() { return $this->uowEntityFakeDefinition->getRemoveCommandHandler(); }
/** * @return \Isolate\UnitOfWork\Entity\Definition */ private function createFakeEntityDefinition() { $definition = new Definition(new ClassName(EntityFake::getClassName()), new Identity("id")); $definition->setObserved([new Property("firstName"), new Property("lastName"), new Property("items")]); $definition->setNewCommandHandler($this->newCommandHandler); $definition->setEditCommandHandler($this->editCommandHandler); $definition->setRemoveCommandHandler($this->removeCommandHandler); return $definition; }