mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-07 11:39:30 +00:00
Add makefile to help with development setup, change part_ids in bulk import jobs to junction table and implement filtering based on bulk import jobs status and its associated parts' statuses.
This commit is contained in:
parent
9b4d5e9c27
commit
cc9d50a8fe
22 changed files with 1357 additions and 120 deletions
|
|
@ -140,7 +140,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
// Create a test job with search results that include source_field and source_keyword
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([$part->getId()]);
|
||||
$job->addPart($part);
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([
|
||||
[
|
||||
|
|
@ -230,10 +230,18 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Admin user not found in fixtures');
|
||||
}
|
||||
|
||||
// Get a test part
|
||||
$partRepository = $entityManager->getRepository(Part::class);
|
||||
$part = $partRepository->find(1);
|
||||
|
||||
if (!$part) {
|
||||
$this->markTestSkipped('Test part with ID 1 not found in fixtures');
|
||||
}
|
||||
|
||||
// Create a completed job
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([1]);
|
||||
$job->addPart($part);
|
||||
$job->setStatus(BulkImportJobStatus::COMPLETED);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -272,10 +280,15 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Admin user not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1]);
|
||||
|
||||
// Create an active job
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([1]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -306,10 +319,15 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Admin user not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1]);
|
||||
|
||||
// Create an active job
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([1]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -352,9 +370,14 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Admin user not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1, 2]);
|
||||
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([1, 2]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -387,9 +410,14 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Admin user not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1, 2]);
|
||||
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([1, 2]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -423,9 +451,14 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Admin user not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1]);
|
||||
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($user);
|
||||
$job->setPartIds([1]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -467,10 +500,15 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Required test users not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1]);
|
||||
|
||||
// Create job as admin
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($admin);
|
||||
$job->setPartIds([1]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::IN_PROGRESS);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -502,10 +540,15 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
$this->markTestSkipped('Required test users not found in fixtures');
|
||||
}
|
||||
|
||||
// Get test parts
|
||||
$parts = $this->getTestParts($entityManager, [1]);
|
||||
|
||||
// Create job as readonly user
|
||||
$job = new BulkInfoProviderImportJob();
|
||||
$job->setCreatedBy($readonly);
|
||||
$job->setPartIds([1]);
|
||||
foreach ($parts as $part) {
|
||||
$job->addPart($part);
|
||||
}
|
||||
$job->setStatus(BulkImportJobStatus::COMPLETED);
|
||||
$job->setSearchResults([]);
|
||||
|
||||
|
|
@ -534,4 +577,20 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
|
|||
|
||||
$client->loginUser($user);
|
||||
}
|
||||
|
||||
private function getTestParts($entityManager, array $ids): array
|
||||
{
|
||||
$partRepository = $entityManager->getRepository(Part::class);
|
||||
$parts = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$part = $partRepository->find($id);
|
||||
if (!$part) {
|
||||
$this->markTestSkipped("Test part with ID {$id} not found in fixtures");
|
||||
}
|
||||
$parts[] = $part;
|
||||
}
|
||||
|
||||
return $parts;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue