Skip to content

Commit

Permalink
Merge pull request #1 from ArthurAlmerio/linha-digitavel
Browse files Browse the repository at this point in the history
Adicionado mascara linha digitavel boleto
  • Loading branch information
phlllpe authored Aug 23, 2022
2 parents acfc8dd + be341e8 commit 4c03a6e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/Predefined/Br/LinhaDigitavel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Mask\Predefined\Br;

use Mask\AbstractMask;

class LinhaDigitavel extends AbstractMask
{
public function getStringMask()
{
return '#####.##### #####.###### #####.###### # ##############';
}
}
45 changes: 45 additions & 0 deletions tests/Mask/Predefined/Br/LinhaDigitavelTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Tests\Mask\Predefined\Br;

use Mask\Predefined\Br\LinhaDigitavel;
use PHPUnit_Framework_TestCase;

class LinhaDigitavelTest extends PHPUnit_Framework_TestCase
{
use \Tests\Mask\Structure\SetUp;

public function testGetStringMask()
{
$this->assertContains('.', (new LinhaDigitavel)->getStringMask());
$this->assertContains('#', (new LinhaDigitavel)->getStringMask());
$this->assertNotContains('/', (new LinhaDigitavel)->getStringMask());
$this->assertNotContains('\\', (new LinhaDigitavel)->getStringMask());
$this->assertNotContains('-', (new LinhaDigitavel)->getStringMask());
}

public function provider()
{
return [
['00190000090312855701821548161179591160000002222'],
];
}

/**
* @dataProvider provider
*/
public function testMaskDefault($linhaDigitavel)
{
$this->assertContains('.', (new LinhaDigitavel)->mask($linhaDigitavel)->toString());
$this->assertTrue(strlen($linhaDigitavel) < strlen((new LinhaDigitavel)->mask($linhaDigitavel)->toString()));
}

/**
* @dataProvider provider
*/
public function testMaskReal($linhaDigitavel)
{
$this->assertContains('.', (new LinhaDigitavel)->mask($linhaDigitavel)->toString());
$this->assertEquals('00190.00009 03128.557018 21548.161179 5 91160000002222', (new LinhaDigitavel)->mask($linhaDigitavel)->toString());
}
}

0 comments on commit 4c03a6e

Please sign in to comment.