/**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->connection = Connection::get();
     $this->userBook = new UserBook($this->connection);
     $this->providerInfoBook = new ProviderInfoBook($this->connection);
     $this->providerUserBook = new ProviderUserBook($this->connection);
     foreach ($this->providerInfoBook->get() as $providerInfo) {
         $this->providerInfoBook->delete($providerInfo);
     }
     foreach ($this->userBook->get() as $user) {
         $this->userBook->delete($user);
     }
     for ($k = 0; $k < 10; $k++) {
         $user = new User();
         $user->setEnabled(RandomBook::getRandomBoolean())->setEnabledDate(RandomBook::getRandomDate())->setAccessFailedCount(rand(1, 5))->setEmail(RandomBook::getRandomEmail())->setPassword(RandomBook::getRandomString())->setPhoneNumber(RandomBook::getRandomPhoneNumber())->setTwoFactorEnabled(RandomBook::getRandomBoolean())->setUserName(RandomBook::getRandomString());
         $user->setId($this->userBook->save($user));
         $this->userList[] = $user;
         for ($k = 0; $k < 10; $k++) {
             $providerInfo = new ProviderInfo();
             $providerInfo->setName(RandomBook::getRandomString())->setAppKey(RandomBook::getRandomString())->setSecretKey(RandomBook::getRandomString());
             $providerInfo->setId((int) $this->providerInfoBook->save($providerInfo));
             $this->providerInfoList[] = $providerInfo;
             $providerUser = new ProviderUser();
             $providerUser->setUserId($user->getId())->setProviderId($providerInfo->getId())->setProviderName($providerInfo->getName())->setProviderUserId(RandomBook::getRandomString());
             $this->providerUserList[] = $providerUser;
         }
     }
 }
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->connection = Connection::get();
     $this->userBook = new UserBook($this->connection);
     $this->providerInfoBook = new ProviderInfoBook($this->connection);
     $this->roleBook = new RoleBook($this->connection);
     foreach ($this->providerInfoBook->get() as $providerInfo) {
         $this->providerInfoBook->delete($providerInfo);
     }
     foreach ($this->roleBook->get() as $role) {
         $this->roleBook->delete($role);
     }
     for ($k = 0; $k < 10; $k++) {
         $user = new User();
         $user->setEnabled(RandomBook::getRandomBoolean())->setEnabledDate(RandomBook::getRandomDate())->setAccessFailedCount(rand(1, 5))->setEmail(RandomBook::getRandomEmail())->setPassword(RandomBook::getRandomString())->setPhoneNumber(RandomBook::getRandomPhoneNumber())->setTwoFactorEnabled(RandomBook::getRandomBoolean())->setUserName(RandomBook::getRandomString());
         $this->userList[] = $user;
     }
 }
 /**
  * @param int|null $userId
  * @param string|null $username
  * @param string|null $email
  * @return User[]
  * @throws \Exception
  */
 public function get($userId = null, $username = null, $email = null)
 {
     MDataType::mustBeNullableInt($userId);
     MDataType::mustBeNullableString($username);
     MDataType::mustBeNullableString($email);
     $userList = array();
     $sql = "CALL mt_user_get(?, ?, ?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($userId);
     $query->bindValue($username);
     $query->bindValue($email);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $userList;
     }
     foreach ($query->getResult() as $row) {
         $user = new User();
         $enabledDate = \DateTime::createFromFormat('Y-m-d H:i:s', $row['enabled_date']);
         $user->setId((int) $row['id'])->setEmail($row['email'])->setPassword($row['password'])->setPhoneNumber($row['phone_number'])->setTwoFactorEnabled($row['two_factor_enabled'] == 1 ? true : false)->setEnabledDate($enabledDate)->setEnabled($row['enabled'] == 1 ? true : false)->setAccessFailedCount((int) $row['access_failed_count'])->setUserName($row['username'])->setRoleList($this->roleBook->get((int) $row['id']))->setProviderUserList($this->providerUserBook->get((int) $row['id']));
         $userList[] = $user;
     }
     return $userList;
 }