Пример #1
0
 /**
  * @dataProvider provideValidConstruction
  */
 public function testValidConstruction($user, $pass, $domain = null)
 {
     $apiUser = new ApiUser($user, $pass, $domain);
     $this->assertEquals($user, $apiUser->getUsername());
     $this->assertEquals($pass, $apiUser->getPassword());
     $this->assertEquals($domain, $apiUser->getDomain());
 }
Пример #2
0
 /**
  * @since 0.1
  *
  * @param ApiUser $apiUser
  *
  * @throws UsageException
  * @return bool success
  */
 public function login(ApiUser $apiUser)
 {
     $this->log(LogLevel::DEBUG, 'Logging in');
     $credentials = array('lgname' => $apiUser->getUsername(), 'lgpassword' => $apiUser->getPassword());
     if (!is_null($apiUser->getDomain())) {
         $credentials['lgdomain'] = $apiUser->getDomain();
     }
     $result = $this->postRequest(new SimpleRequest('login', $credentials));
     if ($result['login']['result'] == "NeedToken") {
         $result = $this->postRequest(new SimpleRequest('login', array_merge(array('lgtoken' => $result['login']['token']), $credentials)));
     }
     if ($result['login']['result'] == "Success") {
         $this->isLoggedIn = $apiUser->getUsername();
         return true;
     }
     $this->isLoggedIn = false;
     $this->throwLoginUsageException($result);
     return false;
 }
Пример #3
0
 public function testCreateUser()
 {
     $factory = TestEnvironment::newDefault()->getFactory();
     $createResult = $factory->newUserCreator()->create(self::$localApiUser->getUsername(), self::$localApiUser->getPassword());
     $this->assertTrue($createResult);
 }
Пример #4
0
 /**
  * @param ApiUser $apiUser
  *
  * @return string[]
  */
 private function getLoginParams(ApiUser $apiUser)
 {
     $params = array('lgname' => $apiUser->getUsername(), 'lgpassword' => $apiUser->getPassword());
     if (!is_null($apiUser->getDomain())) {
         $params['lgdomain'] = $apiUser->getDomain();
     }
     return $params;
 }