Skip to content

Commit

Permalink
Added tests for Api Credits; more tests in separate PR
Browse files Browse the repository at this point in the history
  • Loading branch information
tholu committed Aug 21, 2014
1 parent e8909d8 commit 09772b0
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 166 deletions.
7 changes: 3 additions & 4 deletions SEOstats/Services/Sistrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,16 @@ public static function getApiCredits() {
self::guardApiKey();

$dataUrl = sprintf(Config\Services::SISTRIX_API_CREDITS_URL, Config\ApiKeys::SISTRIX_API_ACCESS_KEY);
$json = static::_getPage($dataUrl);

$json = parent::_getPage($dataUrl);

if(empty($json)) {
if(empty($json) || $json == '{}') {
return parent::noDataDefaultValue();
}
$json_decoded = (Helper\Json::decode($json, true));
return $json_decoded['answer'][0]['credits'][0]['value'];
}

protected static function checkApiCredits() {
public static function checkApiCredits() {
return static::getApiCredits() > 0;
}

Expand Down
Loading

0 comments on commit 09772b0

Please sign in to comment.