Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

tighten/novapackages

336 stars
1 code files
View tighten/novapackages on GitHub

tests/Unit/GitHubRepoTest.php

Open in GitHub
use App\GitHubRepo;
use App\Http\Remotes\GitHub;
use Mockery;
use Tests\TestCase;
 
class GitHubRepoTest extends TestCase
{
/** @test */
public function it_gets_the_latest_release_version_for_tagged_releases()
{
$this->mockGitHubWith([
'releases' => collect([
[
'name' => 'Release',
'tag_name' => 'v1.0',
],
]),
]);
 
$repo = GitHubRepo::make('https://github.com/starwars/lightsabers');
 
$this->assertEquals('v1.0', $repo->latestReleaseVersion());
}
 
/** @test */
public function it_falls_back_to_master_when_there_are_no_releases()
{
$this->mockGitHubWith([
'releases' => collect(),
]);
 
$repo = GitHubRepo::make('https://github.com/starwars/x-wings');
 
$this->assertEquals('master', $repo->latestReleaseVersion());
}
 
protected function mockGitHubWith($expectations)
{
$github = Mockery::mock(GitHub::class, $expectations);
$github->shouldReceive('api')->andReturn($github);
$github->shouldReceive('validateUrl')->andReturn(true);
app()->instance(GitHub::class, $github);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.