Ran rector and made tests final

This commit is contained in:
Jan Böhmer 2026-02-14 23:32:43 +01:00
parent 43d72faf48
commit b21d294cf8
162 changed files with 407 additions and 393 deletions

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
*/
namespace App\Tests\Services\ImportExportSystem;
use App\Entity\PriceInformations\Orderdetail;
use App\Entity\Parts\Category;
use App\Entity\Parts\Part;
use App\Entity\Parts\Supplier;
use App\Entity\ProjectSystem\Project;
@ -31,7 +33,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\File\File;
class BOMImporterTest extends WebTestCase
final class BOMImporterTest extends WebTestCase
{
/**
@ -391,7 +393,7 @@ class BOMImporterTest extends WebTestCase
// Check first entry
$this->assertEquals('R1,R2', $bom_entries[0]->getMountnames());
$this->assertEquals(2.0, $bom_entries[0]->getQuantity());
$this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON);
$this->assertEquals('CRCW080510K0FKEA (R_0805_2012Metric)', $bom_entries[0]->getName());
$this->assertStringContainsString('Value: 10k', $bom_entries[0]->getComment());
$this->assertStringContainsString('MPN: CRCW080510K0FKEA', $bom_entries[0]->getComment());
@ -402,7 +404,7 @@ class BOMImporterTest extends WebTestCase
// Check second entry
$this->assertEquals('C1', $bom_entries[1]->getMountnames());
$this->assertEquals(1.0, $bom_entries[1]->getQuantity());
$this->assertEqualsWithDelta(1.0, $bom_entries[1]->getQuantity(), PHP_FLOAT_EPSILON);
$this->assertStringContainsString('LCSC SPN: C789012', $bom_entries[1]->getComment());
$this->assertStringContainsString('Mouser SPN: 80-CL21A104KOCLRNC', $bom_entries[1]->getComment());
@ -542,7 +544,7 @@ class BOMImporterTest extends WebTestCase
$this->assertCount(1, $bom_entries); // Should merge into one entry
$this->assertEquals('R1,R2', $bom_entries[0]->getMountnames());
$this->assertEquals(2.0, $bom_entries[0]->getQuantity());
$this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON);
$this->assertEquals('CRCW080510K0FKEA', $bom_entries[0]->getName());
}
@ -630,7 +632,7 @@ class BOMImporterTest extends WebTestCase
$this->entityManager->persist($part);
// Create orderdetail linking the part to a supplier SPN
$orderdetail = new \App\Entity\PriceInformations\Orderdetail();
$orderdetail = new Orderdetail();
$orderdetail->setPart($part);
$orderdetail->setSupplier($lcscSupplier);
$orderdetail->setSupplierpartnr('C123456');
@ -664,7 +666,7 @@ class BOMImporterTest extends WebTestCase
$this->assertSame($part, $bom_entries[0]->getPart());
$this->assertEquals('Test Resistor 10k 0805', $bom_entries[0]->getName());
$this->assertEquals('R1,R2', $bom_entries[0]->getMountnames());
$this->assertEquals(2.0, $bom_entries[0]->getQuantity());
$this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON);
$this->assertStringContainsString('LCSC SPN: C123456', $bom_entries[0]->getComment());
$this->assertStringContainsString('Part-DB ID: ' . $part->getID(), $bom_entries[0]->getComment());
@ -691,7 +693,7 @@ class BOMImporterTest extends WebTestCase
$part1->setCategory($this->getDefaultCategory($this->entityManager));
$this->entityManager->persist($part1);
$orderdetail1 = new \App\Entity\PriceInformations\Orderdetail();
$orderdetail1 = new Orderdetail();
$orderdetail1->setPart($part1);
$orderdetail1->setSupplier($lcscSupplier);
$orderdetail1->setSupplierpartnr('C123456');
@ -703,7 +705,7 @@ class BOMImporterTest extends WebTestCase
$part2->setCategory($this->getDefaultCategory($this->entityManager));
$this->entityManager->persist($part2);
$orderdetail2 = new \App\Entity\PriceInformations\Orderdetail();
$orderdetail2 = new Orderdetail();
$orderdetail2->setPart($part2);
$orderdetail2->setSupplier($mouserSupplier);
$orderdetail2->setSupplierpartnr('789-CAP100NF');
@ -794,12 +796,12 @@ class BOMImporterTest extends WebTestCase
private function getDefaultCategory(EntityManagerInterface $entityManager)
{
// Get the first available category or create a default one
$categoryRepo = $entityManager->getRepository(\App\Entity\Parts\Category::class);
$categoryRepo = $entityManager->getRepository(Category::class);
$categories = $categoryRepo->findAll();
if (empty($categories)) {
// Create a default category if none exists
$category = new \App\Entity\Parts\Category();
$category = new Category();
$category->setName('Default Category');
$entityManager->persist($category);
$entityManager->flush();

View file

@ -32,18 +32,16 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see \App\Services\ImportExportSystem\BOMValidationService
*/
class BOMValidationServiceTest extends WebTestCase
final class BOMValidationServiceTest extends WebTestCase
{
private BOMValidationService $validationService;
private EntityManagerInterface $entityManager;
private TranslatorInterface $translator;
protected function setUp(): void
{
self::bootKernel();
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
$this->translator = self::getContainer()->get(TranslatorInterface::class);
$this->validationService = new BOMValidationService($this->entityManager, $this->translator);
$entityManager = self::getContainer()->get(EntityManagerInterface::class);
$translator = self::getContainer()->get(TranslatorInterface::class);
$this->validationService = new BOMValidationService($entityManager, $translator);
}
public function testValidateBOMEntryWithValidData(): void
@ -244,7 +242,7 @@ class BOMValidationServiceTest extends WebTestCase
$this->assertTrue($result['is_valid']);
$this->assertCount(1, $result['info']);
$this->assertStringContainsString('library prefix', $result['info'][0]);
$this->assertStringContainsString('library prefix', (string) $result['info'][0]);
}
public function testValidateBOMEntriesWithMultipleEntries(): void
@ -314,7 +312,7 @@ class BOMValidationServiceTest extends WebTestCase
$this->assertEquals(2, $stats['error_count']);
$this->assertEquals(1, $stats['warning_count']);
$this->assertEquals(2, $stats['info_count']);
$this->assertEquals(80.0, $stats['success_rate']);
$this->assertEqualsWithDelta(80.0, $stats['success_rate'], PHP_FLOAT_EPSILON);
}
public function testGetErrorMessage(): void
@ -344,6 +342,6 @@ class BOMValidationServiceTest extends WebTestCase
$message = $this->validationService->getErrorMessage($validation_result);
$this->assertEquals('', $message);
$this->assertSame('', $message);
}
}

View file

@ -28,7 +28,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
use PhpOffice\PhpSpreadsheet\IOFactory;
class EntityExporterTest extends WebTestCase
final class EntityExporterTest extends WebTestCase
{
/**
* @var EntityExporter
@ -111,6 +111,6 @@ class EntityExporterTest extends WebTestCase
$response = $this->service->exportEntityFromRequest($entities, $request);
$this->assertSame('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
$this->assertStringContainsString('export_Category_simple.xlsx', $response->headers->get('Content-Disposition'));
$this->assertStringContainsString('export_Category_simple.xlsx', (string) $response->headers->get('Content-Disposition'));
}
}

View file

@ -41,7 +41,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
#[Group('DB')]
class EntityImporterTest extends WebTestCase
final class EntityImporterTest extends WebTestCase
{
/**
* @var EntityImporter