Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Specs 2.3] Adjust allowed characters #280

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/QrCode/QrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class QrCode
public const FILE_FORMAT_PNG = 'png';
public const FILE_FORMAT_SVG = 'svg';

public const SUPPORTED_CHARACTERS = 'a-zA-Z0-9.,;:\'"+\-\/()?*\[\]{}|`´~ !^#%&<>÷=@_$£àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑ';
public const SUPPORTED_CHARACTERS = '\x20-\x7E\xA0-\xFF\x{0100}-\x{017F}\x{0218}\x{0219}\x{021A}\x{021B}\x{20AC}';

private const SUPPORTED_FILE_FORMATS = [
self::FILE_FORMAT_PNG,
Expand Down
7 changes: 3 additions & 4 deletions tests/QrBillTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function testItReplacesUnsupportedCharacters()
]);

$this->assertStringContainsString(
'Team We are the Champions!',
'Team «We tests!»',
$qrBill->getQrCode()->getText()
);
}
Expand All @@ -265,14 +265,13 @@ public function testItConsidersReplacementCharacters()
]);

$unsupportedCharacterReplacements = [
'«' => '"',
'»' => '"',
'♥' => '<3'
];

$qrBill->setUnsupportedCharacterReplacements($unsupportedCharacterReplacements);

$this->assertStringContainsString(
'Team "We are the Champions!"',
'Team «We <3 tests!»',
$qrBill->getQrCode()->getText()
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/QrBillTestDataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function longAddress(): CombinedAddress
public function addressWithUnsupportedCharacters(): CombinedAddress
{
return CombinedAddress::create(
'Team «We are the Champions!»',
'Team «We ♥ tests!»',
'Rue examplaire 22a',
'1000 Lausanne',
'CH'
Expand Down
22 changes: 11 additions & 11 deletions tests/QrCode/QrCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ public static function replacementCharactersProvider(): array
{
return [
'replaceSpecificUnsupportedCharacters' => [
'providedString' => '«This is a test!»',
'providedString' => 'We ♥ tests!',
'replacements' => [
'«' => '"',
'»' => '"'
'♥' => '<3',
],
'expectedString' => '"This is a test!"'
'expectedString' => 'We <3 tests!'
],
'ignoreReplacementsOfSupportedCharacters' => [
'providedString' => '«This is a test!»',
'replacements' => [
't' => 'a',
'«' => '"',
'»' => '"',
],
'expectedString' => 'This is a test!'
'expectedString' => '«This is a test!»'
],
];
}
Expand All @@ -158,13 +158,13 @@ public function testItRemovesUnsupportedCharacters(string $providedString, strin
public static function unsupportedCharactersProvider(): array
{
return [
'keepAllAllowedCharacters' => [
'providedString' => 'a-zA-Z0-9.,;:\'+-/()?*[]{}|`´~!"#%&<>÷=@_$£^àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑ',
'expectedString' => 'a-zA-Z0-9.,;:\'+-/()?*[]{}|`´~!"#%&<>÷=@_$£^àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑ'
'keepAllowedCharacters' => [
'providedString' => 'a-zA-Z0-9.,;:\'+-/()?*[]{}|`´~!"#%&<>÷=@_$£^àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑȘșȚț€©',
'expectedString' => 'a-zA-Z0-9.,;:\'+-/()?*[]{}|`´~!"#%&<>÷=@_$£^àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑȘșȚț€©'
],
'removeUnallowedCharacters' => [
'providedString' => '«This is a test!»',
'expectedString' => 'This is a test!'
'providedString' => 'We ♥ tests!',
'expectedString' => 'We tests!'
],
];
}
Expand Down
Binary file modified tests/TestData/FpdfOutput/qr-additional-information.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-additional-information.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-additional-information.scissors.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-alternative-schemes.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-alternative-schemes.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-alternative-schemes.scissors.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-full-set.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-full-set.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-full-set.scissors.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-full-set.svg.scissorsdown.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-full-set.svg.textarrows.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-international-ultimate-debtor.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-minimal-setup.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-minimal-setup.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-minimal-setup.scissors.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-minimal-setup.svg.scissorsdown.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-minimal-setup.svg.textarrows.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-information-zero-amount.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-reference-non.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-reference-non.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-reference-non.scissors.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-reference-scor.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-reference-scor.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-payment-reference-scor.scissors.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-ultimate-debtor.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-ultimate-debtor.print.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-ultimate-debtor.scissors.pdf
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-ultimate-debtor.svg.textarrows.pdf
Binary file not shown.
Binary file modified tests/TestData/FpdfOutput/qr-utf8.svg.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-additional-information.svg.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-alternative-schemes.svg.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-alternative-schemes.svg.print.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-full-set.svg.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-full-set.svg.print.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-full-set.svg.scissors.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-full-set.svg.scissorsdown.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-full-set.svg.textarrows.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-minimal-setup.svg.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-minimal-setup.svg.print.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-minimal-setup.svg.scissors.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-minimal-setup.svg.scissorsdown.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-minimal-setup.svg.textarrows.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-payment-reference-non.svg.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-payment-reference-scor.svg.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-ultimate-debtor.svg.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-ultimate-debtor.svg.print.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-ultimate-debtor.svg.scissors.pdf
Binary file not shown.
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-ultimate-debtor.svg.textarrows.pdf
Binary file not shown.
Binary file modified tests/TestData/TcPdfOutput/qr-utf8.svg.pdf
Binary file not shown.
Loading