mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-14 14:19:33 +00:00
Füge Baugruppen hinzu
This commit is contained in:
parent
98b8c5b788
commit
5bd0741fba
128 changed files with 23830 additions and 109 deletions
|
|
@ -29,7 +29,7 @@ use App\Entity\ProjectSystem\ProjectBOMEntry;
|
|||
use App\Services\ImportExportSystem\BOMImporter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class BOMImporterTest extends WebTestCase
|
||||
{
|
||||
|
|
@ -62,15 +62,17 @@ class BOMImporterTest extends WebTestCase
|
|||
4;"C6";"CP_Radial_D6.3mm_P2.50mm";1;"47uF";;;
|
||||
CSV;
|
||||
|
||||
$file = $this->createMock(File::class);
|
||||
$file = $this->createMock(UploadedFile::class);
|
||||
$file->method('getContent')->willReturn($input);
|
||||
$file->method('getClientOriginalName')->willReturn('import.kicad_pcb');
|
||||
$file->method('getClientOriginalExtension')->willReturn('kicad_pcb');
|
||||
|
||||
$project = new Project();
|
||||
$this->assertCount(0, $project->getBOMEntries());
|
||||
|
||||
$bom_entries = $this->service->importFileIntoProject($file, $project, ['type' => 'kicad_pcbnew']);
|
||||
$this->assertContainsOnlyInstancesOf(ProjectBOMEntry::class, $bom_entries);
|
||||
$this->assertCount(4, $bom_entries);
|
||||
$importerResult = $this->service->importFileIntoProject($file, $project, ['type' => 'kicad_pcbnew']);
|
||||
$this->assertContainsOnlyInstancesOf(ProjectBOMEntry::class, $importerResult->getBomEntries());
|
||||
$this->assertCount(4, $importerResult->getBomEntries());
|
||||
|
||||
//Check that the BOM entries are added to the project
|
||||
$this->assertCount(4, $project->getBOMEntries());
|
||||
|
|
@ -87,7 +89,8 @@ class BOMImporterTest extends WebTestCase
|
|||
4;"C6";"CP_Radial_D6.3mm_P2.50mm";1;"47uF";;;
|
||||
CSV;
|
||||
|
||||
$bom = $this->service->stringToBOMEntries($input, ['type' => 'kicad_pcbnew']);
|
||||
$project = new Project();
|
||||
$bom = $this->service->stringToBOMEntries($project, $input, ['type' => 'kicad_pcbnew']);
|
||||
|
||||
$this->assertContainsOnlyInstancesOf(ProjectBOMEntry::class, $bom);
|
||||
$this->assertCount(4, $bom);
|
||||
|
|
@ -106,7 +109,8 @@ class BOMImporterTest extends WebTestCase
|
|||
4;"C6";"CP_Radial_D6.3mm_P2.50mm";1;"47uF";;;
|
||||
CSV;
|
||||
|
||||
$bom = $this->service->stringToBOMEntries($input, ['type' => 'kicad_pcbnew']);
|
||||
$project = new Project();
|
||||
$bom = $this->service->stringToBOMEntries($project, $input, ['type' => 'kicad_pcbnew']);
|
||||
|
||||
$this->assertContainsOnlyInstancesOf(ProjectBOMEntry::class, $bom);
|
||||
$this->assertCount(4, $bom);
|
||||
|
|
@ -126,7 +130,8 @@ class BOMImporterTest extends WebTestCase
|
|||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
$this->service->stringToBOMEntries($input, ['type' => 'kicad_pcbnew']);
|
||||
$project = new Project();
|
||||
$this->service->stringToBOMEntries($project, $input, ['type' => 'kicad_pcbnew']);
|
||||
}
|
||||
|
||||
public function testDetectFields(): void
|
||||
|
|
@ -370,7 +375,8 @@ class BOMImporterTest extends WebTestCase
|
|||
'Mouser SPN' => 'Mouser SPN'
|
||||
];
|
||||
|
||||
$bom_entries = $this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$bom_entries = $this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
@ -413,7 +419,8 @@ class BOMImporterTest extends WebTestCase
|
|||
'MPN2' => 2
|
||||
];
|
||||
|
||||
$bom_entries = $this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$bom_entries = $this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'field_priorities' => $field_priorities,
|
||||
|
|
@ -451,7 +458,8 @@ class BOMImporterTest extends WebTestCase
|
|||
'Quantity' => 'Quantity'
|
||||
];
|
||||
|
||||
$bom_entries = $this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$bom_entries = $this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
@ -483,7 +491,8 @@ class BOMImporterTest extends WebTestCase
|
|||
'Quantity' => 'Quantity'
|
||||
];
|
||||
|
||||
$bom_entries = $this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$bom_entries = $this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
@ -512,7 +521,8 @@ class BOMImporterTest extends WebTestCase
|
|||
'Quantity' => 'Quantity'
|
||||
];
|
||||
|
||||
$bom_entries = $this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$bom_entries = $this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
@ -541,7 +551,8 @@ class BOMImporterTest extends WebTestCase
|
|||
$this->expectException(\UnexpectedValueException::class);
|
||||
$this->expectExceptionMessage('Required field "Designator" is missing or empty');
|
||||
|
||||
$this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
@ -564,7 +575,8 @@ class BOMImporterTest extends WebTestCase
|
|||
$this->expectException(\UnexpectedValueException::class);
|
||||
$this->expectExceptionMessage('Mismatch between quantity and component references');
|
||||
|
||||
$this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
@ -585,7 +597,8 @@ class BOMImporterTest extends WebTestCase
|
|||
'Quantity' => 'Quantity'
|
||||
];
|
||||
|
||||
$bom_entries = $this->service->stringToBOMEntries($input, [
|
||||
$project = new Project();
|
||||
$bom_entries = $this->service->stringToBOMEntries($project, $input, [
|
||||
'type' => 'kicad_schematic',
|
||||
'field_mapping' => $field_mapping,
|
||||
'delimiter' => ','
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue