Example #1
0
 /**
  * @param $traversableArray
  * @return array
  */
 private function toPersistedArray($traversableArray)
 {
     if (!$this->isTraversableArray($traversableArray)) {
         return [];
     }
     $result = [];
     foreach ($traversableArray as $valueElement) {
         $result[$this->identifier->getIdentity($valueElement)] = $valueElement;
     }
     return $result;
 }
 function let(Definition\Repository $definitions, Identifier $identifier)
 {
     $definitions->getDefinition(Argument::type(EntityFake::getClassName()))->willReturn($this->createEntityDefinition());
     $definitions->getDefinition(Argument::type(AssociatedEntityFake::getClassName()))->willReturn($this->createAssociatedEntityDefinition());
     $identifier->isPersisted(Argument::any())->will(function ($args) {
         return !is_null($args[0]->getId());
     });
     $identifier->getIdentity(Argument::any())->will(function ($args) {
         return $args[0]->getId();
     });
     $this->beConstructedWith($definitions, $identifier);
 }