Skip to content

Commit

Permalink
test: corrigir teste de NFSe
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreBellas committed Oct 5, 2024
1 parent 954a546 commit af2e48f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Entities/Nfses/__tests__/NfsesTest.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testShouldDeleteSuccessfully(): void
->method('destroy')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse/$idNotaServico"
)
)
Expand All @@ -72,7 +72,7 @@ public function testShouldGetSuccessfully(): void
->method('index')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse"
&& is_null($requestOptions->queryParams)
)
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testShouldFindSuccessfully(): void
->method('show')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse/$idNotaServico"
)
)
Expand Down Expand Up @@ -129,7 +129,7 @@ public function testShouldGetConfigurationsSuccessfully(): void
->method('index')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse/configurations"
)
)
Expand All @@ -156,7 +156,7 @@ public function testShouldCreateSuccessfully(): void
->method('store')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse"
)
)
Expand All @@ -183,7 +183,7 @@ public function testShouldSendSuccessfully(): void
->method('store')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse/$idNotaServico/enviar"
)
)
Expand All @@ -204,20 +204,24 @@ public function testShouldSendSuccessfully(): void
public function testShouldCancelSuccessfully(): void
{
$idNotaServico = fake()->randomNumber();
$cancelRequest = json_decode(file_get_contents(__DIR__ . '/cancel/request.json'), true);
$cancelResponse = json_decode(file_get_contents(__DIR__ . '/cancel/response.json'), true);
$repository = $this->getMockBuilder(IBlingRepository::class)->getMock();
$repository->expects($this->once())
->method('store')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse/$idNotaServico/cancelar"
)
)
->willReturn($this->buildResponse(status: 200, body: $this->buildBody($cancelResponse)));

/** @var IBlingRepository $repository */
$response = $this->getInstance($repository)->cancel($idNotaServico);
$response = $this->getInstance($repository)->cancel(
$idNotaServico,
$cancelRequest
);

$this->assertNull($response);
}
Expand All @@ -242,7 +246,7 @@ public function testShouldUpdateConfigurationsSuccessfully(): void
->method('replace')
->with(
$this->callback(
fn (RequestOptions $requestOptions) =>
fn(RequestOptions $requestOptions) =>
$requestOptions->endpoint === "nfse/configuracoes"
)
)
Expand Down
4 changes: 4 additions & 0 deletions src/Entities/Nfses/__tests__/cancel/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"codigoMotivo": 1,
"justificativa": "Cancelamento de NFS-e"
}

0 comments on commit af2e48f

Please sign in to comment.