Skip to content

Commit f976953

Browse files
Updating the tests
1 parent 8e55167 commit f976953

File tree

4 files changed

+57
-31
lines changed

4 files changed

+57
-31
lines changed

tests/GravatarServiceProviderTest.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php namespace Arcanedev\Gravatar\Tests;
2+
23
use Arcanedev\Gravatar\GravatarServiceProvider;
34

45
/**
@@ -24,26 +25,43 @@ public function setUp()
2425
{
2526
parent::setUp();
2627

27-
$this->provider = new GravatarServiceProvider($this->app);
28+
$this->provider = $this->app->getProvider(GravatarServiceProvider::class);
2829
}
2930

3031
public function tearDown()
3132
{
32-
parent::tearDown();
33-
3433
unset($this->provider);
34+
35+
parent::tearDown();
3536
}
3637

3738
/* ------------------------------------------------------------------------------------------------
3839
| Test Functions
3940
| ------------------------------------------------------------------------------------------------
4041
*/
4142
/** @test */
42-
public function it_can_get_what_it_provides()
43+
public function it_can_be_instantiated()
4344
{
44-
$this->assertEquals(
45-
['arcanedev.gravatar'],
46-
$this->provider->provides()
47-
);
45+
$expectations = [
46+
\Illuminate\Support\ServiceProvider::class,
47+
\Arcanedev\Support\ServiceProvider::class,
48+
\Arcanedev\Support\PackageServiceProvider::class,
49+
\Arcanedev\Gravatar\GravatarServiceProvider::class,
50+
];
51+
52+
foreach ($expectations as $expected) {
53+
$this->assertInstanceOf($expected, $this->provider);
54+
}
55+
}
56+
57+
/** @test */
58+
public function it_can_provides()
59+
{
60+
$expected = [
61+
'arcanedev.gravatar',
62+
\Arcanedev\Gravatar\Contracts\Gravatar::class,
63+
];
64+
65+
$this->assertEquals($expected, $this->provider->provides());
4866
}
4967
}

tests/GravatarTest.php

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GravatarTest extends TestCase
1414
| Properties
1515
| ------------------------------------------------------------------------------------------------
1616
*/
17-
/** @var Gravatar */
17+
/** @var \Arcanedev\Gravatar\Gravatar */
1818
private $gravatar;
1919

2020
/* ------------------------------------------------------------------------------------------------
@@ -25,14 +25,14 @@ public function setUp()
2525
{
2626
parent::setUp();
2727

28-
$this->gravatar = $this->app['arcanedev.gravatar'];
28+
$this->gravatar = $this->app->make('arcanedev.gravatar');
2929
}
3030

3131
public function tearDown()
3232
{
33-
parent::tearDown();
34-
3533
unset($this->gravatar);
34+
35+
parent::tearDown();
3636
}
3737

3838
/* ------------------------------------------------------------------------------------------------
@@ -42,10 +42,15 @@ public function tearDown()
4242
/** @test */
4343
public function it_can_be_instantiated()
4444
{
45-
$this->assertInstanceOf(Gravatar::class, $this->gravatar);
46-
$this->assertEquals('g', $this->gravatar->getRating());
47-
$this->assertEquals(80, $this->gravatar->getSize());
48-
$this->assertTrue($this->gravatar->isSecured());
45+
$this->assertGravatarInstance($this->gravatar);
46+
47+
// By a helper function
48+
$this->assertGravatarInstance(gravatar());
49+
50+
// By a Contract
51+
$this->assertGravatarInstance(
52+
$this->app->make(\Arcanedev\Gravatar\Contracts\Gravatar::class)
53+
);
4954
}
5055

5156
/** @test */
@@ -272,4 +277,21 @@ public function it_can_set_size_from_height_or_width_attributes()
272277

273278
$this->assertEquals(256, $this->gravatar->getSize());
274279
}
280+
281+
/* ------------------------------------------------------------------------------------------------
282+
| Other Functions
283+
| ------------------------------------------------------------------------------------------------
284+
*/
285+
/**
286+
* Assert the gravatar instance.
287+
*
288+
* @param \Arcanedev\Gravatar\Contracts\Gravatar $gravatar
289+
*/
290+
public function assertGravatarInstance($gravatar)
291+
{
292+
$this->assertInstanceOf(\Arcanedev\Gravatar\Gravatar::class, $gravatar);
293+
$this->assertEquals('g', $gravatar->getRating());
294+
$this->assertEquals(80, $gravatar->getSize());
295+
$this->assertTrue($gravatar->isSecured());
296+
}
275297
}

tests/Helpers/HtmlBuilderTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@
1111
*/
1212
class HtmlBuilderTest extends TestCase
1313
{
14-
/* ------------------------------------------------------------------------------------------------
15-
| Main Functions
16-
| ------------------------------------------------------------------------------------------------
17-
*/
18-
public function setUp()
19-
{
20-
parent::setUp();
21-
}
22-
23-
public function tearDown()
24-
{
25-
parent::tearDown();
26-
}
27-
2814
/* ------------------------------------------------------------------------------------------------
2915
| Test Functions
3016
| ------------------------------------------------------------------------------------------------

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ protected function getPackageAliases($app)
6060
*/
6161
protected function getEnvironmentSetUp($app)
6262
{
63-
63+
//
6464
}
6565
}

0 commit comments

Comments
 (0)