mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-02 07:21:33 +00:00
Fixed tests
This commit is contained in:
parent
7f8f5990a7
commit
13b98cc0b1
3 changed files with 11 additions and 8 deletions
|
|
@ -110,9 +110,8 @@ class StructuralElementDenormalizer implements DenormalizerInterface, Denormaliz
|
||||||
//Check if we already have the entity in the database (via path)
|
//Check if we already have the entity in the database (via path)
|
||||||
/** @var StructuralDBElementRepository<T> $repo */
|
/** @var StructuralDBElementRepository<T> $repo */
|
||||||
$repo = $this->entityManager->getRepository($type);
|
$repo = $this->entityManager->getRepository($type);
|
||||||
$deserialized_entity = $entity;
|
|
||||||
|
|
||||||
$path = $deserialized_entity->getFullPath(AbstractStructuralDBElement::PATH_DELIMITER_ARROW);
|
$path = $entity->getFullPath(AbstractStructuralDBElement::PATH_DELIMITER_ARROW);
|
||||||
$db_elements = $repo->getEntityByPath($path, AbstractStructuralDBElement::PATH_DELIMITER_ARROW);
|
$db_elements = $repo->getEntityByPath($path, AbstractStructuralDBElement::PATH_DELIMITER_ARROW);
|
||||||
if ($db_elements !== []) {
|
if ($db_elements !== []) {
|
||||||
//We already have the entity in the database, so we can return it
|
//We already have the entity in the database, so we can return it
|
||||||
|
|
@ -128,7 +127,7 @@ class StructuralElementDenormalizer implements DenormalizerInterface, Denormaliz
|
||||||
$entity = $this->object_cache[$type][$path];
|
$entity = $this->object_cache[$type][$path];
|
||||||
} else {
|
} else {
|
||||||
//Save the entity in the cache
|
//Save the entity in the cache
|
||||||
$this->object_cache[$type][$path] = $deserialized_entity;
|
$this->object_cache[$type][$path] = $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
//In the next step we can denormalize the children, and add our children to the entity.
|
//In the next step we can denormalize the children, and add our children to the entity.
|
||||||
|
|
@ -142,9 +141,9 @@ class StructuralElementDenormalizer implements DenormalizerInterface, Denormaliz
|
||||||
}
|
}
|
||||||
|
|
||||||
//We don't have the entity in the database, so we have to persist it
|
//We don't have the entity in the database, so we have to persist it
|
||||||
$this->entityManager->persist($deserialized_entity);
|
$this->entityManager->persist($entity);
|
||||||
|
|
||||||
return $deserialized_entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportedTypes(?string $format): array
|
public function getSupportedTypes(?string $format): array
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,8 @@ readonly class EIGP114BarcodeScanResult implements BarcodeScanResultInterface
|
||||||
*/
|
*/
|
||||||
public static function parseFormat06Code(string $input): self
|
public static function parseFormat06Code(string $input): self
|
||||||
{
|
{
|
||||||
|
$rawInput = $input;
|
||||||
|
|
||||||
//Ensure that the input is a valid format06 code
|
//Ensure that the input is a valid format06 code
|
||||||
if (!self::isFormat06Code($input)) {
|
if (!self::isFormat06Code($input)) {
|
||||||
throw new \InvalidArgumentException("The given input is not a valid format06 code");
|
throw new \InvalidArgumentException("The given input is not a valid format06 code");
|
||||||
|
|
@ -306,7 +308,7 @@ readonly class EIGP114BarcodeScanResult implements BarcodeScanResultInterface
|
||||||
$results[$key] = $fieldValue;
|
$results[$key] = $fieldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($results, $input);
|
return new self($results, $rawInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDecodedForInfoMode(): array
|
public function getDecodedForInfoMode(): array
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,8 @@ final class BarcodeScanHelperTest extends WebTestCase
|
||||||
yield [new LocalBarcodeScanResult(LabelSupportedElement::PART_LOT, 2,BarcodeSourceType::USER_DEFINED),
|
yield [new LocalBarcodeScanResult(LabelSupportedElement::PART_LOT, 2,BarcodeSourceType::USER_DEFINED),
|
||||||
'lot2_vendor_barcode'];
|
'lot2_vendor_barcode'];
|
||||||
|
|
||||||
|
|
||||||
|
$input = "[)>\x1E06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04";
|
||||||
$eigp114Result = new EIGP114BarcodeScanResult([
|
$eigp114Result = new EIGP114BarcodeScanResult([
|
||||||
'P' => '596-777A1-ND',
|
'P' => '596-777A1-ND',
|
||||||
'1P' => 'XAF4444',
|
'1P' => 'XAF4444',
|
||||||
|
|
@ -122,9 +124,9 @@ final class BarcodeScanHelperTest extends WebTestCase
|
||||||
'10D' => '1452',
|
'10D' => '1452',
|
||||||
'1T' => 'BF1103',
|
'1T' => 'BF1103',
|
||||||
'4L' => 'US',
|
'4L' => 'US',
|
||||||
]);
|
], $input);
|
||||||
|
|
||||||
yield [$eigp114Result, "[)>\x1E06\x1DP596-777A1-ND\x1D1PXAF4444\x1DQ3\x1D10D1452\x1D1TBF1103\x1D4LUS\x1E\x04"];
|
yield [$eigp114Result, $input];
|
||||||
|
|
||||||
$lcscInput = '{pc:C138033,pm:RC0402FR-071ML,qty:10}';
|
$lcscInput = '{pc:C138033,pm:RC0402FR-071ML,qty:10}';
|
||||||
$lcscResult = new LCSCBarcodeScanResult(
|
$lcscResult = new LCSCBarcodeScanResult(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue