Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /**
  * @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;
 }
Exemplo n.º 3
0
 /**
  * @Given there is github user with username :username
  *
  * @param $username
  */
 public function thereIsGithubUserWithUsername($username)
 {
     $user = new GithubUser();
     $user->setUsername($username)->setName('John Doe');
     $this->save($user);
 }
Exemplo n.º 4
0
 /**
  * @param string $username
  *
  * @return GithubUser
  */
 private function createUserObjectFromUsername($username)
 {
     $githubUser = new GithubUser();
     $githubUser->setUsername($username);
     return $githubUser;
 }
Exemplo n.º 5
0
 /**
  * @param $username
  *
  * @return GithubUser
  */
 public function create($username)
 {
     $githubUser = new GithubUser();
     $githubUser->setUsername($username);
     return $githubUser;
 }