-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tombenevides/add-facade-support
add Facade for CepService
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ demo.php | |
Temp | ||
*.pfx% | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace LSNepomuceno\LaravelBrazilianCeps\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
use LSNepomuceno\LaravelBrazilianCeps\Services\CepService; | ||
|
||
class CEP extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return CepService::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace LSNepomuceno\LaravelBrazilianCeps\Tests\Feature; | ||
|
||
use Exception; | ||
use LSNepomuceno\LaravelBrazilianCeps\Entities\CepEntity; | ||
use LSNepomuceno\LaravelBrazilianCeps\Exceptions\CepNotFoundException; | ||
use LSNepomuceno\LaravelBrazilianCeps\Facades\CEP; | ||
use LSNepomuceno\LaravelBrazilianCeps\Tests\TestCase; | ||
|
||
class CepFacadeTest extends TestCase | ||
{ | ||
public function testCepFacadeReturnsCorrectResponseStructure() | ||
{ | ||
$response = CEP::get('29018-210'); | ||
|
||
$this->assertInstanceOf(CepEntity::class, $response); | ||
} | ||
|
||
public function testCepFacadeThrowsExceptionWhenCepNotFound() | ||
{ | ||
config(['brazilian-ceps.throw_not_found_exception' => true]); | ||
|
||
$this->expectException(Exception::class); | ||
|
||
CEP::get('66666666'); | ||
} | ||
} |