function it_returns_true_when_values_are_different_in_property_that_holds_array() { $firstObject = new EntityFake(1); $firstObject->setItems([new EntityFake(5), new EntityFake(6)]); $secondObject = new EntityFake(1); $secondObject->setItems([new EntityFake(5), new EntityFake(7)]); $this->hasDifferentValue(new Property("items"), $firstObject, $secondObject)->shouldReturn(true); }
/** * @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; }
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]]); }
function it_gets_identity_from_entity(Definition\Repository $definitions, Definition\IdentificationStrategy $identificationStrategy) { $entity = new EntityFake(1); $identificationStrategy->getIdentity($entity)->willReturn(1); $definitions->hasDefinition($entity)->willReturn(true); $definitions->getDefinition($entity)->willReturn(new Definition(new ClassName(EntityFake::getClassName()), new Definition\Identity("id"), $identificationStrategy->getWrappedObject())); $this->getIdentity($entity)->shouldReturn(1); }
function it_has_default_identification_strategy() { $this->beConstructedWith(new ClassName(EntityFake::getClassName()), new Identity("id")); $this->getIdentityStrategy()->shouldReturnAnInstanceOf('Isolate\\UnitOfWork\\Entity\\Definition\\IdentificationStrategy'); }
/** * @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; }