Example #1
0
 /**
  * @param $entity
  * @throws InvalidArgumentException
  * @throws RuntimeException
  */
 public function register($entity)
 {
     if (!is_object($entity)) {
         throw new InvalidArgumentException("Only objects can be registered in Unit of Work.");
     }
     if (!$this->identifier->isEntity($entity)) {
         throw new InvalidArgumentException("Only entities can be registered in Unit of Work.");
     }
     $this->registry->register($entity);
 }
Example #2
0
 function it_tells_when_entity_was_registered(Registry $registry, Identifier $identifier)
 {
     $entity = new EntityFake();
     $registry->isRegistered($entity)->willReturn(true);
     $identifier->isEntity($entity)->willReturn(true);
     $registry->register($entity)->willReturn();
     $this->register($entity);
     $this->isRegistered($entity)->shouldReturn(true);
 }