Skip to content

Commit fd91c9e

Browse files
committed
Improve code coverage
1 parent 549505d commit fd91c9e

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/PackagistServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function provides()
4646
{
4747
return [
4848
PackagistClient::class,
49+
PackagistUrlGenerator::class,
4950
];
5051
}
5152
}

tests/PackagistServiceProviderTest.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,43 @@
44

55
use Illuminate\Config\Repository;
66
use MarkWalet\Packagist\Facades\Packagist;
7+
use MarkWalet\Packagist\PackagistServiceProvider;
78
use Spatie\Packagist\PackagistClient;
89
use Spatie\Packagist\PackagistUrlGenerator;
910

1011
class PackagistServiceProviderTest extends LaravelTestCase
1112
{
1213
/** @test */
13-
public function it_binds_a_packagist_manager_to_the_application()
14+
public function it_binds_a_packagist_client_to_the_application()
1415
{
1516
$bindings = $this->app->getBindings();
16-
1717
$this->assertArrayHasKey(PackagistClient::class, $bindings);
18+
19+
$result = $this->app->make(PackagistClient::class);
20+
$this->assertInstanceOf(PackagistClient::class, $result);
21+
}
22+
23+
/** @test */
24+
public function it_binds_a_url_generator_to_the_application()
25+
{
26+
$bindings = $this->app->getBindings();
27+
$this->assertArrayHasKey(PackagistUrlGenerator::class, $bindings);
28+
29+
$result = $this->app->make(PackagistUrlGenerator::class);
30+
$this->assertInstanceOf(PackagistUrlGenerator::class, $result);
31+
}
32+
33+
/** @test */
34+
public function the_service_provider_only_loads_when_one_of_the_bound_classes_should_be_injected()
35+
{
36+
$provider = new PackagistServiceProvider($this->app);
37+
38+
$result = $provider->provides();
39+
40+
$this->assertSame([
41+
PackagistClient::class,
42+
PackagistUrlGenerator::class,
43+
], $result);
1844
}
1945

2046
/** @test */
@@ -61,7 +87,7 @@ public function it_can_override_the_url_configuration()
6187
$config = $this->app['config'];
6288
$config->set('services.packagist', [
6389
'base_url' => 'https://markwalet.me',
64-
'repo_url' => 'https://github.com'
90+
'repo_url' => 'https://github.com',
6591
]);
6692
/** @var PackagistUrlGenerator $generator */
6793
$generator = $this->app->make(PackagistUrlGenerator::class);

0 commit comments

Comments
 (0)