Skip to content

Commit

Permalink
Merge pull request #605 from jeidison/master
Browse files Browse the repository at this point in the history
Suporte ao laravel 8
  • Loading branch information
eduardokum authored Mar 16, 2021
2 parents 0ac5650 + 8137247 commit 797b99f
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 80 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu]
php: ["7.2"]
php: ["7.3"]
# Apenas versões com suporte
laravel:
- "5.5.*"
- "5.8.*"
- "6.*"
- "7.*"
- "8.*"
include:
- os: ubuntu
php: "7.3"
laravel: "8.*"
- os: macos
php: "7.2"
php: "7.3"
laravel: "7.*"
- os: windows
php: "7.2"
php: "7.3"
laravel: "7.*"
runs-on: ${{ matrix.os }}-latest
name: LRV ${{ matrix.laravel }} (${{ matrix.os }})
Expand Down
4 changes: 2 additions & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ filter:

build:
nodes:
php72:
php73:
environment:
php: 7.2
php: 7.3
dependencies:
override:
- composer install --no-interaction
Expand Down
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: php

php:
- 7.3

before_script:
- "composer self-update"
- "composer --version"
- "composer install --verbose"

script:
- "vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.clover"

after_script:
- "wget https://scrutinizer-ci.com/ocular.phar"
- "php ocular.phar code-coverage:upload --format=php-clover coverage.clover"

after_success:
- if [ $TRAVIS_PHP_VERSION = '7.0' ] && [ $TRAVIS_BRANCH = 'master' ]; then sh generate-api.sh; fi

env:
global:
secure: XTzPUKON+QTpUnWAlQJWzarcuOVOUZRHnDkvp8wKQp55k/Qsz7tw7edfjwzefGuzqBm1lINR4zpsm9n7zwy4rh97hPh+hFEMT5ozOS4R042YfVv7Xkz2mhGRsyIBwW2xDbFev1z7PekdzAxD8G8Fp0xlVKJzqyX8KqAm4XtubpnHisvItXyiE7qgxPmsQf3UbWr5FPtOBrUz7jHLsGrFM0Z55cYhGsnBTFf+qyo7qbLSUSj6kQUDneiRXzTIAn3xiqpBvHbJ10ByUXcLFycxa1b/FKKSqqBUCoM04l2+gA4g1yFwvsaOcdAsOrJp664nCLgBEGPR4BpEzIuqfOwsiqZEYD1AciIHqFTs42QumTwqGjQIvgt1GfO47/GjmlxvWqeOFB3SMFwT/nna7yS6tcFMhY1kSQmjctLfR81ciDPMoJFzmGDxlatWwz2tI52R+P0NSw6+pxOu0laS+jz+ARftS6KJ/FfJNDBxX9IRAobvMq3ASygz4XQaQ4mD6BEN5muwdPhq5fDUJW08R5FJ9EjyLxTKLLWDN2ENdTG9UpWjx4cuRd1BLOGphIwG//EHfYhktgCKwlhN6y9kvW/4YiFBpgpqTV77zTAXGBus/2T1oQtHfDc+ESiufbd9r67QgidQwVN2w58N/i/0GXl8kjV8V+cJslLEYryMfvIT9GM=
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM php:7.3.25-fpm-alpine3.11

RUN apk add --no-cache \
openssl \
bash \
unzip \
vim \
$PHPIZE_DEPS \
libzip-dev \
zlib-dev \
libsodium-dev \
icu-dev

RUN docker-php-ext-configure intl
RUN docker-php-ext-install zip sodium intl
RUN docker-php-ext-enable zip sodium

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer



WORKDIR /var/www

EXPOSE 9000

ENTRYPOINT ["php-fpm"]
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"php": ">5.5.0",
"ext-intl": "*",
"ext-mbstring": "*",
"laravel/framework": "^5.0||^6.0||^7.0||^8.0",
"laravel/framework": "^5.0||^6.0||^7.0|^8.0",
"neitanod/forceutf8": "^2.0",
"setasign/fpdf": "^1.8"
},
"require-dev": {
"phpunit/phpunit": ">=6.0,<9.0",
"phpunit/phpunit": ">=6.0||^8.0||^9.0",
"orchestra/testbench": "^3.1"
},
"autoload": {
Expand All @@ -40,4 +40,4 @@
"php": "7.2.0"
}
}
}
}
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.7'

services:

laravel-boleto:
build: .
container_name: laravel-boleto
tty: true
volumes:
- .:/var/www
networks:
- laravel-boleto-network

networks:
laravel-boleto-network:
driver: bridge
25 changes: 12 additions & 13 deletions tests/Boleto/BoletoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Eduardokum\LaravelBoleto\Boleto\Render\Pdf;
use Eduardokum\LaravelBoleto\Pessoa;
use Eduardokum\LaravelBoleto\Tests\TestCase;
use Exception;

class BoletoTest extends TestCase
{
Expand Down Expand Up @@ -194,11 +195,9 @@ public function testWithoutLogo()
$this->assertFileExists($file);
}

/**
* @expectedException \Exception
*/
public function testSemBoletoAdicionado()
{
$this->expectException(Exception::class);
$pdf = new Pdf();
$pdf->gerarBoleto($pdf::OUTPUT_STRING);
}
Expand Down Expand Up @@ -226,7 +225,7 @@ public function testBoletoBanrisul()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand All @@ -252,7 +251,7 @@ public function testBoletoBB()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -280,7 +279,7 @@ public function testBoletoBradesco()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -309,7 +308,7 @@ public function testBoletoCaixa()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -338,7 +337,7 @@ public function testBoletoHSBC()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -366,7 +365,7 @@ public function testBoletoItau()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -394,7 +393,7 @@ public function testBoletoSantander()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -423,7 +422,7 @@ public function testBoletoSicredi()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -452,7 +451,7 @@ public function testBoletoBancoob()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down Expand Up @@ -480,7 +479,7 @@ public function testBoletoBnb()
'especieDoc' => 'DM',
]
);
$this->assertInternalType('array', $boleto->toArray());
$this->assertIsArray($boleto->toArray());
$this->assertNotNull($boleto->renderHTML());
$this->assertNotNull($boleto->renderPDF());
}
Expand Down
17 changes: 8 additions & 9 deletions tests/PessoaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Eduardokum\LaravelBoleto\Pessoa;
use Eduardokum\LaravelBoleto\Util;
use Exception;

class PessoaTest extends TestCase
{
Expand Down Expand Up @@ -39,13 +40,13 @@ public function testPessoaCriandoConstrutor(){
$this->assertEquals(Util::maskString($documento, '###.###.###-##'), $pessoa->getDocumento());
$this->assertEquals('CPF', $pessoa->getTipoDocumento());

$this->assertContains(Util::maskString($cep, '#####-###'), $pessoa->getCepCidadeUf());
$this->assertContains($cidade, $pessoa->getCepCidadeUf());
$this->assertContains($uf, $pessoa->getCepCidadeUf());
$this->assertStringContainsString(Util::maskString($cep, '#####-###'), $pessoa->getCepCidadeUf());
$this->assertStringContainsString($cidade, $pessoa->getCepCidadeUf());
$this->assertStringContainsString($uf, $pessoa->getCepCidadeUf());

$this->assertContains($nome, $pessoa->getNomeDocumento());
$this->assertContains('CPF', $pessoa->getNomeDocumento());
$this->assertContains(Util::maskString($documento, '###.###.###-##'), $pessoa->getNomeDocumento());
$this->assertStringContainsString($nome, $pessoa->getNomeDocumento());
$this->assertStringContainsString('CPF', $pessoa->getNomeDocumento());
$this->assertStringContainsString(Util::maskString($documento, '###.###.###-##'), $pessoa->getNomeDocumento());

$pessoa->setDocumento('');
$this->assertEquals($nome, $pessoa->getNomeDocumento());
Expand All @@ -62,10 +63,8 @@ public function testPessoaCriandoConstrutor(){

}

/**
* @expectedException \Exception
*/
public function testPessoaDocumentoErrado(){
$this->expectException(Exception::class);

$pessoa = new Pessoa(
[
Expand Down
9 changes: 3 additions & 6 deletions tests/Remessa/RemessaCnab400Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Eduardokum\LaravelBoleto\Pessoa;
use Eduardokum\LaravelBoleto\Tests\TestCase;
use Eduardokum\LaravelBoleto\Util;
use Exception;

class RemessaCnab400Test extends TestCase
{
Expand Down Expand Up @@ -54,21 +55,17 @@ public static function tearDownAfterClass() : void
}
}

/**
* @expectedException \Exception
*/
public function testRemessaCamposInvalidos(){
$this->expectException(Exception::class);
$remessa = new Remessa\Banrisul([
'codigoCliente' => 11112222222,
'beneficiario' => self::$beneficiario,
]);
$remessa->gerar();
}

/**
* @expectedException \Exception
*/
public function testRemessaCarteiraIndisponivel(){
$this->expectException(Exception::class);
$remessa = new Remessa\Banrisul([
'agencia' => 1111,
'conta' => 22222,
Expand Down
17 changes: 5 additions & 12 deletions tests/Retorno/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,31 @@

use Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Detalhe;
use Eduardokum\LaravelBoleto\Tests\TestCase;
use Exception;
use Illuminate\Support\Collection;

class FactoryTest extends TestCase
{
/**
* @expectedException \Exception
*/
public function testCriarEmBranco(){
$this->expectException(Exception::class);
$retorno = \Eduardokum\LaravelBoleto\Cnab\Retorno\Factory::make('');
$retorno->processar();
}

/**
* @expectedException \Exception
*/
public function testCriarComRemessa(){
$this->expectException(Exception::class);
$retorno = \Eduardokum\LaravelBoleto\Cnab\Retorno\Factory::make(__DIR__ . '/files/cnab400/remessa.txt');
$retorno->processar();
}

/**
* @expectedException \Exception
*/
public function testCriarComPathQueNaoExiste(){
$this->expectException(Exception::class);
$retorno = \Eduardokum\LaravelBoleto\Cnab\Retorno\Factory::make(__DIR__ . '/files/cnab400/naoexiste.txt');
$retorno->processar();
}

/**
* @expectedException \Exception
*/
public function testCriarComRetornoBancoNaoExiste(){
$this->expectException(Exception::class);
$retorno = \Eduardokum\LaravelBoleto\Cnab\Retorno\Factory::make(__DIR__ . '/files/cnab400/retorno_banco_fake.ret');
$retorno->processar();
}
Expand Down
15 changes: 5 additions & 10 deletions tests/Retorno/RetornoCnab400Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@
use Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Bradesco;
use Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Detalhe;
use Eduardokum\LaravelBoleto\Tests\TestCase;
use Exception;
use Illuminate\Support\Collection;

class RetornoCnab400Test extends TestCase
{

/**
* @expectedException \Exception
*/
public function testRetornoInvalido(){
$this->expectException(Exception::class);
new Bradesco([]);
}

/**
* @expectedException \Exception
*/
public function testRetornoBancoInvalido(){
$this->expectException(Exception::class);
new Bradesco(__DIR__ . '/files/cnab400/retorno_banco_fake.ret');
}

/**
* @expectedException \Exception
*/
public function testRetornoServicoInvalido(){
$this->expectException(Exception::class);
new Bradesco(__DIR__ . '/files/cnab400/retorno_banco_fake_2.ret');
}

Expand All @@ -44,7 +39,7 @@ public function testRetornoSeekableIterator(){
$this->assertEquals(3, $retorno->key());
$this->assertInstanceOf(Detalhe::class, $retorno->current());

$this->expectException(\Exception::class);
$this->expectException(Exception::class);
$retorno->seek(100);
}

Expand Down
Loading

0 comments on commit 797b99f

Please sign in to comment.