Skip to content

Commit

Permalink
Merge pull request #1 from tombenevides/add-facade-support
Browse files Browse the repository at this point in the history
add Facade for CepService
  • Loading branch information
lsnepomuceno authored Dec 13, 2022
2 parents b37e3c0 + 348ecd3 commit d21799c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ demo.php
Temp
*.pdf
*.pfx%
build
14 changes: 14 additions & 0 deletions src/Facades/CEP.php
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;
}
}
28 changes: 28 additions & 0 deletions tests/Feature/CepFacadeTest.php
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');
}
}

0 comments on commit d21799c

Please sign in to comment.