Skip to content

Commit

Permalink
complianted to releases api
Browse files Browse the repository at this point in the history
  • Loading branch information
miya0001 committed Feb 6, 2017
1 parent 8b93ad0 commit 0d8d970
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public static function get_latest_vccw_url()
$api = "https://api.github.com/repos/vccw-team/vccw/releases/latest";
$body = json_decode( self::download( $api ) );

if ( $body ) {
if ( ! empty( $body->assets[0] ) && ! empty( $body->assets[0]->browser_download_url ) ) {
return $body->assets[0]->browser_download_url;
} elseif ( $body ) {
return $body->zipball_url;
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/test-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

class Scaffold_VCCW_Test extends WP_UnitTestCase
{
/**
* Tests for the `Scaffold_VCCW::get_latest_vccw_url()`.
*
* @test
* @since 1.3.0
*/
public function get_latest_vccw_url()
{
$url = Scaffold_VCCW::get_latest_vccw_url();
$this->assertRegExp( '#^https://github.com/vccw-team/vccw/releases/download#', $url );
}

/**
* Tests for the `Scaffold_VCCW::rempty()`.
*
Expand Down

0 comments on commit 0d8d970

Please sign in to comment.