mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-25 16:47:40 +01:00
Made EIGP114 parsing less strict (#1321)
* Enhance barcode format checking in isFormat06Code Updated isFormat06Code method to handle additional barcode formats for compatibility with older Mouser parts and Eyoyo barcode scanners that don't omit the record separator character * Added tests --------- Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This commit is contained in:
@@ -93,6 +93,13 @@ final class EIGP114BarcodeScanResultTest extends TestCase
|
||||
|
||||
//Valid code (digikey, without trailer)
|
||||
$this->assertTrue(EIGP114BarcodeScanResult::isFormat06Code("[)>\x1e06\x1dPQ1045-ND\x1d1P364019-01\x1d30PQ1045-ND\x1dK12432 TRAVIS FOSS P\x1d1K85732873\x1d10K103332956\x1d9D231013\x1d1TQJ13P\x1d11K1\x1d4LTW\x1dQ3\x1d11ZPICK\x1d12Z7360988\x1d13Z999999\x1d20Z0000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
|
||||
|
||||
//Valid code (without record separator)
|
||||
$this->assertTrue(EIGP114BarcodeScanResult::isFormat06Code("[)>06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04"));
|
||||
|
||||
//Old mouser format
|
||||
$this->assertTrue(EIGP114BarcodeScanResult::isFormat06Code(">[)>06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04"));
|
||||
|
||||
}
|
||||
|
||||
public function testParseFormat06CodeInvalid(): void
|
||||
@@ -101,6 +108,32 @@ final class EIGP114BarcodeScanResultTest extends TestCase
|
||||
EIGP114BarcodeScanResult::parseFormat06Code('');
|
||||
}
|
||||
|
||||
public function testParseWithoutRecordSeparator(): void
|
||||
{
|
||||
$barcode = EIGP114BarcodeScanResult::parseFormat06Code("[)>06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04");
|
||||
$this->assertSame([
|
||||
'P' => '596-777A1-ND',
|
||||
'1P' => 'XAF4444',
|
||||
'Q' => '3',
|
||||
'10D' => '1452',
|
||||
'1T' => 'BF1103',
|
||||
'4L' => 'US',
|
||||
], $barcode->data);
|
||||
}
|
||||
|
||||
public function testParseOldMouserFormat(): void
|
||||
{
|
||||
$barcode = EIGP114BarcodeScanResult::parseFormat06Code(">[)>06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04");
|
||||
$this->assertSame([
|
||||
'P' => '596-777A1-ND',
|
||||
'1P' => 'XAF4444',
|
||||
'Q' => '3',
|
||||
'10D' => '1452',
|
||||
'1T' => 'BF1103',
|
||||
'4L' => 'US',
|
||||
], $barcode->data);
|
||||
}
|
||||
|
||||
public function testParseFormat06Code(): void
|
||||
{
|
||||
$barcode = EIGP114BarcodeScanResult::parseFormat06Code("[)>\x1E06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04");
|
||||
|
||||
Reference in New Issue
Block a user