public function it_will_map_property_values_from_remote_to_entity_even_if_only_username_exists(GithubUserDataInterface $remote, GithubUser $entity, $username) { $remote->getGithubId()->willReturn(null); $remote->getUsername()->willReturn($username); $remote->getEmail()->willReturn(null); $remote->getName()->willReturn(null); $remote->getAvatarUrl()->willReturn(null); $entity->setGithubId(Argument::any())->shouldNotBeCalled(); $entity->setUsername($username)->shouldBeCalled(); $entity->setEmail(Argument::any())->shouldNotBeCalled(); $entity->setName(Argument::any())->shouldNotBeCalled(); $entity->setAvatarUrl(Argument::any())->shouldNotBeCalled(); $this->map($remote, $entity)->shouldReturn(true); }
/** * @param GithubUserData|GithubUserDataInterface $remote * @param GithubUser $entity * * @return bool */ public function map(GithubUserDataInterface $remote, GithubUser $entity) { if (null !== $remote->getGithubId()) { $entity->setGithubId($remote->getGithubId()); } $entity->setUsername($remote->getUsername()); if (null !== $remote->getEmail()) { $entity->setEmail($remote->getEmail()); } if (null !== $remote->getName()) { $entity->setName($remote->getName()); } if (null !== $remote->getAvatarUrl()) { $entity->setAvatarUrl($remote->getAvatarUrl()); } return true; }