mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-01 12:59:36 +00:00
Add KiCadHelper unit tests and fix PDF detection for external URLs
- Add comprehensive KiCadHelperTest with 14 test cases covering: - Stock quantity calculation (zero, single lot, multiple lots) - Stock exclusion of expired and unknown-quantity lots - Storage location display (present, absent, multiple) - Datasheet URL resolution by type name, attachment name, PDF extension - Datasheet fallback to Part-DB URL when no match - "Data sheet" (with space) name variant matching - Fix PDF extension detection for external attachments (getExtension() returns null for external-only attachments, now also parses URL path)
This commit is contained in:
parent
cc77007b49
commit
6422fa62d1
2 changed files with 372 additions and 3 deletions
|
|
@ -439,9 +439,16 @@ class KiCadHelper
|
|||
return $this->getAttachmentUrl($attachment);
|
||||
}
|
||||
|
||||
//Track first PDF as fallback
|
||||
if ($firstPdf === null && $attachment->getExtension() === 'pdf') {
|
||||
$firstPdf = $attachment;
|
||||
//Track first PDF as fallback (check internal extension or external URL path)
|
||||
if ($firstPdf === null) {
|
||||
$extension = $attachment->getExtension();
|
||||
if ($extension === null && $attachment->hasExternal()) {
|
||||
$urlPath = parse_url($attachment->getExternalPath(), PHP_URL_PATH) ?? '';
|
||||
$extension = strtolower(pathinfo($urlPath, PATHINFO_EXTENSION));
|
||||
}
|
||||
if ($extension === 'pdf') {
|
||||
$firstPdf = $attachment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue