-
Notifications
You must be signed in to change notification settings - Fork 100
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 #148 from zucchetti-pos/handle-24hrs-rejection
fix: (Complements.php): suporta rejeição cStat 220
- Loading branch information
Showing
8 changed files
with
164 additions
and
32 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Pipeline | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
|
||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
testsuite: | ||
name: Testes Automatizados | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: ["7.4"] | ||
|
||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: mbstring, intl, mysql, zlib, dom, openssl, soap, json, simplexml, libxml | ||
|
||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Composer Install | ||
run: | | ||
composer install --no-progress -o --no-ansi --no-interaction | ||
- name: Rodando PHPUnit | ||
run: composer test |
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
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
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 |
---|---|---|
@@ -1,29 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
failOnRisky="true" | ||
failOnWarning="true"> | ||
|
||
<php> | ||
<ini name="display_errors" value="1" /> | ||
<ini name="error_reporting" value="-1" /> | ||
<server name="APP_ENV" value="test" force="true" /> | ||
<server name="SHELL_VERBOSITY" value="-1" /> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="sped-mdfe Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="tap" target="build/report.tap"/> | ||
<log type="junit" target="build/report.junit.xml"/> | ||
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/> | ||
<log type="coverage-text" target="build/coverage.txt"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
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
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,85 @@ | ||
<?php | ||
|
||
use NFePHP\MDFe\Complements; | ||
use NFePHP\MDFe\Exception\DocumentsException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ComplementsTest extends TestCase | ||
{ | ||
|
||
public function test_shouldThrowDocumentsExceptionWhenCancelTimePass24Hours() | ||
{ | ||
$request = <<<XML | ||
<eventoMDFe xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00"> | ||
<infEvento Id="ID1101114324110615725000011658001000000075100000000101"> | ||
<cOrgao>43</cOrgao> | ||
<tpAmb>1</tpAmb> | ||
<CNPJ>06157250000116</CNPJ> | ||
<chMDFe>43241106157250000116580010000000751000000001</chMDFe> | ||
<dhEvento>2024-11-29T20:48:53-03:00</dhEvento> | ||
<tpEvento>110111</tpEvento> | ||
<nSeqEvento>1</nSeqEvento> | ||
<detEvento versaoEvento="3.00"> | ||
<evCancMDFe> | ||
<descEvento>Cancelamento</descEvento> | ||
<nProt>943240033753981</nProt> | ||
<xJust>nao ocorreu a entrega</xJust> | ||
</evCancMDFe> | ||
</detEvento> | ||
</infEvento> | ||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> | ||
<SignedInfo> | ||
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /> | ||
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /> | ||
<Reference URI="#ID1101114324110615725000011658001000000075100000000101"> | ||
<Transforms> | ||
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /> | ||
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /> | ||
</Transforms> | ||
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> | ||
<DigestValue>Rw2TlnWyJcdKqQClJ3puvkC0s/o=</DigestValue> | ||
</Reference> | ||
</SignedInfo> | ||
<SignatureValue></SignatureValue> | ||
<KeyInfo> | ||
<X509Data> | ||
<X509Certificate></X509Certificate> | ||
</X509Data> | ||
</KeyInfo> | ||
</Signature> | ||
</eventoMDFe> | ||
XML; | ||
|
||
$response = <<<XML | ||
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<soap:Header> | ||
<mdfeCabecMsg xmlns="http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoEvento"> | ||
<cUF>43</cUF> | ||
<versaoDados>3.00</versaoDados> | ||
</mdfeCabecMsg> | ||
</soap:Header> | ||
<soap:Body> | ||
<mdfeRecepcaoEventoResult | ||
xmlns="http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoEvento"> | ||
<retEventoMDFe xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00"> | ||
<infEvento Id="ID999999999999999"> | ||
<tpAmb>1</tpAmb> | ||
<verAplic>RS20240710093829</verAplic> | ||
<cOrgao>43</cOrgao> | ||
<cStat>220</cStat> | ||
<xMotivo>Rejeicao: MDF-e autorizada ha mais de 24 horas</xMotivo> | ||
</infEvento> | ||
</retEventoMDFe> | ||
</mdfeRecepcaoEventoResult> | ||
</soap:Body> | ||
</soap:Envelope> | ||
XML; | ||
|
||
$this->expectException(DocumentsException::class); | ||
$this->expectExceptionMessage('O documento de resposta relata um erro [220] Rejeicao: MDF-e autorizada ha mais de 24 horas.'); | ||
|
||
Complements::toAuthorize($request, $response); | ||
} | ||
} |
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,5 @@ | ||
<?php | ||
|
||
include dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
||
define('TESTS_FIXTURES', __DIR__ . '/fixtures'); |
Binary file not shown.