Example #1
0
 /**
  * @param $userName
  * @param $email
  * @param $name
  * @param $password
  *
  * @dataProvider generateUsers
  */
 public function testSerialization($userName, $email, $name, $password)
 {
     $model = new UserDto($userName, $email, $name, $password);
     $model->setPassword($password);
     $array = $model->toArray();
     $this->assertArrayHasKey('userName', $array);
     $this->assertArrayHasKey('email', $array);
     $this->assertArrayHasKey('name', $array);
     /*
      * Private properties should not be serialized
      */
     $this->assertArrayNotHasKey('password', $array);
     $this->assertEquals($userName, $array['userName']);
     $this->assertEquals($email, $array['email']);
     $this->assertEquals($name, $array['name']);
 }
Example #2
0
function bindUserEntity($userEntity)
{
    if ($userEntity != null) {
        $userDto = new UserDto();
        $userDto->setUserId($userEntity->getUserId());
        $userDto->setEmail($userEntity->getEmail());
        $userDto->setPassword($userEntity->getPassword());
        $userDto->setName($userEntity->getName());
        $userDto->setSurname($userEntity->getSurname());
        $userDto->setPhone($userEntity->getPhone());
        $userDto->setGender($userEntity->getGender());
        $userDto->setAge($userEntity->getAge());
        $userDto->setUserAllowPush($userEntity->getUserAllowPush());
        return $userDto;
    } else {
        return null;
    }
}