mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-16 14:39:37 +00:00
Ran rector and made tests final
This commit is contained in:
parent
43d72faf48
commit
b21d294cf8
162 changed files with 407 additions and 393 deletions
|
|
@ -27,7 +27,7 @@ use App\Entity\Attachments\AttachmentType;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class AttachmentTypeController extends AbstractAdminController
|
||||
final class AttachmentTypeController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/attachment_type';
|
||||
protected static string $entity_class = AttachmentType::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Entity\Parts\Category;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class CategoryController extends AbstractAdminController
|
||||
final class CategoryController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/category';
|
||||
protected static string $entity_class = Category::class;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use App\Entity\Parts\Manufacturer;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class CurrencyController extends AbstractAdminController
|
||||
final class CurrencyController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/currency';
|
||||
protected static string $entity_class = Currency::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Entity\Parts\Footprint;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class FootprintController extends AbstractAdminController
|
||||
final class FootprintController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/footprint';
|
||||
protected static string $entity_class = Footprint::class;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ use PHPUnit\Framework\Attributes\Group;
|
|||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
class LabelProfileController extends AbstractAdminController
|
||||
final class LabelProfileController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/label_profile';
|
||||
protected static string $entity_class = LabelProfile::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Entity\Parts\Manufacturer;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class ManufacturerController extends AbstractAdminController
|
||||
final class ManufacturerController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/manufacturer';
|
||||
protected static string $entity_class = Manufacturer::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Entity\Parts\MeasurementUnit;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class MeasurementUnitController extends AbstractAdminController
|
||||
final class MeasurementUnitController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/measurement_unit';
|
||||
protected static string $entity_class = MeasurementUnit::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use PHPUnit\Framework\Attributes\Group;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class PartCustomStateControllerTest extends AbstractAdminController
|
||||
final class PartCustomStateControllerTest extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/part_custom_state';
|
||||
protected static string $entity_class = PartCustomState::class;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use App\Entity\ProjectSystem\Project;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class ProjectController extends AbstractAdminController
|
||||
final class ProjectController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/project';
|
||||
protected static string $entity_class = Project::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Entity\Parts\StorageLocation;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class StorelocationController extends AbstractAdminController
|
||||
final class StorelocationController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/store_location';
|
||||
protected static string $entity_class = StorageLocation::class;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Entity\Parts\Supplier;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class SupplierController extends AbstractAdminController
|
||||
final class SupplierController extends AbstractAdminController
|
||||
{
|
||||
protected static string $base_path = '/en/supplier';
|
||||
protected static string $entity_class = Supplier::class;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Services\InfoProviderSystem\BulkInfoProviderService;
|
||||
use App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO;
|
||||
use App\Entity\InfoProviderSystem\BulkImportJobStatus;
|
||||
use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob;
|
||||
use App\Entity\Parts\Part;
|
||||
|
|
@ -36,7 +38,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
|
||||
#[Group("slow")]
|
||||
#[Group("DB")]
|
||||
class BulkInfoProviderImportControllerTest extends WebTestCase
|
||||
final class BulkInfoProviderImportControllerTest extends WebTestCase
|
||||
{
|
||||
public function testStep1WithoutIds(): void
|
||||
{
|
||||
|
|
@ -174,8 +176,8 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
|
||||
// Verify the template rendered the source_field and source_keyword correctly
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertStringContainsString('test_field', $content);
|
||||
$this->assertStringContainsString('test_keyword', $content);
|
||||
$this->assertStringContainsString('test_field', (string) $content);
|
||||
$this->assertStringContainsString('test_keyword', (string) $content);
|
||||
|
||||
// Clean up - find by ID to avoid detached entity issues
|
||||
$jobId = $job->getId();
|
||||
|
|
@ -607,7 +609,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
}
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
$this->assertStringContainsString('Bulk Info Provider Import', $client->getResponse()->getContent());
|
||||
$this->assertStringContainsString('Bulk Info Provider Import', (string) $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testStep1FormSubmissionWithErrors(): void
|
||||
|
|
@ -630,7 +632,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
}
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
$this->assertStringContainsString('Bulk Info Provider Import', $client->getResponse()->getContent());
|
||||
$this->assertStringContainsString('Bulk Info Provider Import', (string) $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testBulkInfoProviderServiceKeywordExtraction(): void
|
||||
|
|
@ -647,18 +649,18 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
}
|
||||
|
||||
// Test that the service can extract keywords from parts
|
||||
$bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class);
|
||||
$bulkService = $client->getContainer()->get(BulkInfoProviderService::class);
|
||||
|
||||
// Create field mappings to verify the service works
|
||||
$fieldMappings = [
|
||||
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('name', ['test'], 1),
|
||||
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('mpn', ['test'], 2)
|
||||
new BulkSearchFieldMappingDTO('name', ['test'], 1),
|
||||
new BulkSearchFieldMappingDTO('mpn', ['test'], 2)
|
||||
];
|
||||
|
||||
// The service may return an empty result or throw when no results are found
|
||||
try {
|
||||
$result = $bulkService->performBulkSearch([$part], $fieldMappings, false);
|
||||
$this->assertInstanceOf(\App\Services\InfoProviderSystem\DTOs\BulkSearchResponseDTO::class, $result);
|
||||
$this->assertInstanceOf(BulkSearchResponseDTO::class, $result);
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->assertStringContainsString('No search results found', $e->getMessage());
|
||||
}
|
||||
|
|
@ -725,12 +727,12 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
}
|
||||
|
||||
// Test that the service can handle supplier part number fields
|
||||
$bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class);
|
||||
$bulkService = $client->getContainer()->get(BulkInfoProviderService::class);
|
||||
|
||||
// Create field mappings with supplier SPN field mapping
|
||||
$fieldMappings = [
|
||||
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('invalid_field', ['test'], 1),
|
||||
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2)
|
||||
new BulkSearchFieldMappingDTO('invalid_field', ['test'], 1),
|
||||
new BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2)
|
||||
];
|
||||
|
||||
// The service should be able to process the request and throw an exception when no results are found
|
||||
|
|
@ -756,11 +758,11 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
}
|
||||
|
||||
// Test that the service can handle batch processing
|
||||
$bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class);
|
||||
$bulkService = $client->getContainer()->get(BulkInfoProviderService::class);
|
||||
|
||||
// Create field mappings with multiple keywords
|
||||
$fieldMappings = [
|
||||
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('empty', ['test'], 1)
|
||||
new BulkSearchFieldMappingDTO('empty', ['test'], 1)
|
||||
];
|
||||
|
||||
// The service should be able to process the request and throw an exception when no results are found
|
||||
|
|
@ -786,7 +788,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
}
|
||||
|
||||
// Test that the service can handle prefetch details
|
||||
$bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class);
|
||||
$bulkService = $client->getContainer()->get(BulkInfoProviderService::class);
|
||||
|
||||
// Create empty search results to test prefetch method
|
||||
$searchResults = new BulkSearchResponseDTO([
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\DataFixtures\APITokenFixtures;
|
|||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class KiCadApiControllerTest extends WebTestCase
|
||||
final class KiCadApiControllerTest extends WebTestCase
|
||||
{
|
||||
private const BASE_URL = '/en/kicad-api/v1';
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
|
||||
#[Group("slow")]
|
||||
#[Group("DB")]
|
||||
class PartControllerTest extends WebTestCase
|
||||
final class PartControllerTest extends WebTestCase
|
||||
{
|
||||
public function testShowPart(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||
|
||||
#[Group('slow')]
|
||||
#[Group('DB')]
|
||||
class RedirectControllerTest extends WebTestCase
|
||||
final class RedirectControllerTest extends WebTestCase
|
||||
{
|
||||
protected EntityManagerInterface $em;
|
||||
protected UserRepository $userRepo;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace App\Tests\Controller;
|
|||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class ScanControllerTest extends WebTestCase
|
||||
final class ScanControllerTest extends WebTestCase
|
||||
{
|
||||
|
||||
private ?KernelBrowser $client = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue