/**
  * 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->providerInfoBook = new ProviderInfoBook($this->connection);
     for ($k = 0; $k < 10; $k++) {
         $providerInfo = new ProviderInfo();
         $providerInfo->setName(RandomBook::getRandomString())->setAppKey(RandomBook::getRandomString())->setSecretKey(RandomBook::getRandomString());
         $this->providerInfoList[] = $providerInfo;
     }
 }
 /**
  * @param int $providerId
  * @return ProviderInfo[]
  * @throws \Exception
  */
 public function get($providerId = null)
 {
     MDataType::mustBe(array(MDataType::INT));
     $toReturn = array();
     $sql = "CALL mt_provider_get(?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($providerId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $userLogins = new ProviderInfo();
         $userLogins->setName($row['name'])->setAppKey($row['app_key'])->setSecretKey($row['secret_key'])->setId((int) $row['id']);
         $toReturn[] = $userLogins;
     }
     return $toReturn;
 }