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

@ -55,7 +55,7 @@ use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class AttachmentTest extends TestCase
final class AttachmentTest extends TestCase
{
public function testEmptyState(): void
{

View file

@ -28,7 +28,7 @@ use App\Entity\Attachments\UserAttachment;
use Doctrine\Common\Collections\Collection;
use PHPUnit\Framework\TestCase;
class AttachmentTypeTest extends TestCase
final class AttachmentTypeTest extends TestCase
{
public function testEmptyState(): void
{

View file

@ -31,7 +31,7 @@ use PHPUnit\Framework\TestCase;
* Test StructuralDBElement entities.
* Note: Because StructuralDBElement is abstract we use AttachmentType here as a placeholder.
*/
class AbstractStructuralDBElementTest extends TestCase
final class AbstractStructuralDBElementTest extends TestCase
{
protected AttachmentType $root;
protected AttachmentType $child1;

View file

@ -25,7 +25,7 @@ namespace App\Tests\Entity;
use App\Entity\InfoProviderSystem\BulkImportJobStatus;
use PHPUnit\Framework\TestCase;
class BulkImportJobStatusTest extends TestCase
final class BulkImportJobStatusTest extends TestCase
{
public function testEnumValues(): void
{

View file

@ -28,32 +28,27 @@ use App\Entity\InfoProviderSystem\BulkInfoProviderImportJobPart;
use App\Entity\Parts\Part;
use PHPUnit\Framework\TestCase;
class BulkInfoProviderImportJobPartTest extends TestCase
final class BulkInfoProviderImportJobPartTest extends TestCase
{
private BulkInfoProviderImportJob $job;
private Part $part;
private BulkInfoProviderImportJobPart $jobPart;
protected function setUp(): void
{
$this->job = $this->createMock(BulkInfoProviderImportJob::class);
$this->part = $this->createMock(Part::class);
$this->jobPart = new BulkInfoProviderImportJobPart($this->job, $this->part);
$this->jobPart = new BulkInfoProviderImportJobPart($this->createStub(BulkInfoProviderImportJob::class), $this->createStub(Part::class));
}
public function testConstructor(): void
{
$this->assertSame($this->job, $this->jobPart->getJob());
$this->assertSame($this->part, $this->jobPart->getPart());
$this->assertEquals(BulkImportPartStatus::PENDING, $this->jobPart->getStatus());
$this->assertSame($this->createStub(BulkInfoProviderImportJob::class), $this->jobPart->getJob());
$this->assertSame($this->createStub(Part::class), $this->jobPart->getPart());
$this->assertSame(BulkImportPartStatus::PENDING, $this->jobPart->getStatus());
$this->assertNull($this->jobPart->getReason());
$this->assertNull($this->jobPart->getCompletedAt());
}
public function testGetAndSetJob(): void
{
$newJob = $this->createMock(BulkInfoProviderImportJob::class);
$newJob = $this->createStub(BulkInfoProviderImportJob::class);
$result = $this->jobPart->setJob($newJob);
@ -63,7 +58,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
public function testGetAndSetPart(): void
{
$newPart = $this->createMock(Part::class);
$newPart = $this->createStub(Part::class);
$result = $this->jobPart->setPart($newPart);
@ -76,7 +71,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$result = $this->jobPart->setStatus(BulkImportPartStatus::COMPLETED);
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus());
$this->assertSame(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus());
}
public function testGetAndSetReason(): void
@ -86,7 +81,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$result = $this->jobPart->setReason($reason);
$this->assertSame($this->jobPart, $result);
$this->assertEquals($reason, $this->jobPart->getReason());
$this->assertSame($reason, $this->jobPart->getReason());
}
public function testGetAndSetCompletedAt(): void
@ -108,7 +103,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$afterTime = new \DateTimeImmutable();
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus());
$this->assertSame(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
$this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt());
$this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt());
@ -124,8 +119,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$afterTime = new \DateTimeImmutable();
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus());
$this->assertEquals($reason, $this->jobPart->getReason());
$this->assertSame(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus());
$this->assertSame($reason, $this->jobPart->getReason());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
$this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt());
$this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt());
@ -136,8 +131,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$result = $this->jobPart->markAsSkipped();
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus());
$this->assertEquals('', $this->jobPart->getReason());
$this->assertSame(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus());
$this->assertSame('', $this->jobPart->getReason());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
}
@ -151,8 +146,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$afterTime = new \DateTimeImmutable();
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::FAILED, $this->jobPart->getStatus());
$this->assertEquals($reason, $this->jobPart->getReason());
$this->assertSame(BulkImportPartStatus::FAILED, $this->jobPart->getStatus());
$this->assertSame($reason, $this->jobPart->getReason());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
$this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt());
$this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt());
@ -163,8 +158,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$result = $this->jobPart->markAsFailed();
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::FAILED, $this->jobPart->getStatus());
$this->assertEquals('', $this->jobPart->getReason());
$this->assertSame(BulkImportPartStatus::FAILED, $this->jobPart->getStatus());
$this->assertSame('', $this->jobPart->getReason());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
}
@ -176,7 +171,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
$result = $this->jobPart->markAsPending();
$this->assertSame($this->jobPart, $result);
$this->assertEquals(BulkImportPartStatus::PENDING, $this->jobPart->getStatus());
$this->assertSame(BulkImportPartStatus::PENDING, $this->jobPart->getStatus());
$this->assertNull($this->jobPart->getReason());
$this->assertNull($this->jobPart->getCompletedAt());
}
@ -281,7 +276,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
// After marking as skipped, should have reason and completion time
$this->jobPart->markAsSkipped('Skipped reason');
$this->assertEquals('Skipped reason', $this->jobPart->getReason());
$this->assertSame('Skipped reason', $this->jobPart->getReason());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
// After marking as pending, reason and completion time should be cleared
@ -291,7 +286,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase
// After marking as failed, should have reason and completion time
$this->jobPart->markAsFailed('Failed reason');
$this->assertEquals('Failed reason', $this->jobPart->getReason());
$this->assertSame('Failed reason', $this->jobPart->getReason());
$this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt());
// After marking as completed, should have completion time (reason may remain from previous state)

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
namespace App\Tests\Entity;
use App\Entity\Parts\Part;
use App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO;
use App\Entity\InfoProviderSystem\BulkImportJobStatus;
use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob;
use App\Entity\UserSystem\User;
@ -31,7 +33,7 @@ use App\Services\InfoProviderSystem\DTOs\BulkSearchResponseDTO;
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
use PHPUnit\Framework\TestCase;
class BulkInfoProviderImportJobTest extends TestCase
final class BulkInfoProviderImportJobTest extends TestCase
{
private BulkInfoProviderImportJob $job;
private User $user;
@ -45,9 +47,9 @@ class BulkInfoProviderImportJobTest extends TestCase
$this->job->setCreatedBy($this->user);
}
private function createMockPart(int $id): \App\Entity\Parts\Part
private function createMockPart(int $id): Part
{
$part = $this->createMock(\App\Entity\Parts\Part::class);
$part = $this->createMock(Part::class);
$part->method('getId')->willReturn($id);
$part->method('getName')->willReturn("Test Part {$id}");
return $part;
@ -58,7 +60,7 @@ class BulkInfoProviderImportJobTest extends TestCase
$job = new BulkInfoProviderImportJob();
$this->assertInstanceOf(\DateTimeImmutable::class, $job->getCreatedAt());
$this->assertEquals(BulkImportJobStatus::PENDING, $job->getStatus());
$this->assertSame(BulkImportJobStatus::PENDING, $job->getStatus());
$this->assertEmpty($job->getPartIds());
$this->assertEmpty($job->getFieldMappings());
$this->assertEmpty($job->getSearchResultsRaw());
@ -70,14 +72,14 @@ class BulkInfoProviderImportJobTest extends TestCase
public function testBasicGettersSetters(): void
{
$this->job->setName('Test Job');
$this->assertEquals('Test Job', $this->job->getName());
$this->assertSame('Test Job', $this->job->getName());
// Test with actual parts - this is what actually works
$parts = [$this->createMockPart(1), $this->createMockPart(2), $this->createMockPart(3)];
foreach ($parts as $part) {
$this->job->addPart($part);
}
$this->assertEquals([1, 2, 3], $this->job->getPartIds());
$this->assertSame([1, 2, 3], $this->job->getPartIds());
$fieldMappings = [new BulkSearchFieldMappingDTO(field: 'field1', providers: ['provider1', 'provider2'])];
$this->job->setFieldMappings($fieldMappings);
@ -98,24 +100,24 @@ class BulkInfoProviderImportJobTest extends TestCase
$this->assertFalse($this->job->isStopped());
$this->job->markAsInProgress();
$this->assertEquals(BulkImportJobStatus::IN_PROGRESS, $this->job->getStatus());
$this->assertSame(BulkImportJobStatus::IN_PROGRESS, $this->job->getStatus());
$this->assertTrue($this->job->isInProgress());
$this->assertFalse($this->job->isPending());
$this->job->markAsCompleted();
$this->assertEquals(BulkImportJobStatus::COMPLETED, $this->job->getStatus());
$this->assertSame(BulkImportJobStatus::COMPLETED, $this->job->getStatus());
$this->assertTrue($this->job->isCompleted());
$this->assertNotNull($this->job->getCompletedAt());
$job2 = new BulkInfoProviderImportJob();
$job2->markAsFailed();
$this->assertEquals(BulkImportJobStatus::FAILED, $job2->getStatus());
$this->assertSame(BulkImportJobStatus::FAILED, $job2->getStatus());
$this->assertTrue($job2->isFailed());
$this->assertNotNull($job2->getCompletedAt());
$job3 = new BulkInfoProviderImportJob();
$job3->markAsStopped();
$this->assertEquals(BulkImportJobStatus::STOPPED, $job3->getStatus());
$this->assertSame(BulkImportJobStatus::STOPPED, $job3->getStatus());
$this->assertTrue($job3->isStopped());
$this->assertNotNull($job3->getCompletedAt());
}
@ -139,7 +141,7 @@ class BulkInfoProviderImportJobTest extends TestCase
public function testPartCount(): void
{
$this->assertEquals(0, $this->job->getPartCount());
$this->assertSame(0, $this->job->getPartCount());
// Test with actual parts - setPartIds doesn't actually add parts
$parts = [
@ -152,31 +154,31 @@ class BulkInfoProviderImportJobTest extends TestCase
foreach ($parts as $part) {
$this->job->addPart($part);
}
$this->assertEquals(5, $this->job->getPartCount());
$this->assertSame(5, $this->job->getPartCount());
}
public function testResultCount(): void
{
$this->assertEquals(0, $this->job->getResultCount());
$this->assertSame(0, $this->job->getResultCount());
$searchResults = new BulkSearchResponseDTO([
new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO(
new BulkSearchPartResultsDTO(
part: $this->createMockPart(1),
searchResults: [new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '1234', name: 'Part 1', description: 'A part'))]
),
new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO(
new BulkSearchPartResultsDTO(
part: $this->createMockPart(2),
searchResults: [new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '1234', name: 'Part 2', description: 'A part')),
new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '5678', name: 'Part 2 Alt', description: 'Another part'))]
),
new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO(
new BulkSearchPartResultsDTO(
part: $this->createMockPart(3),
searchResults: []
)
]);
$this->job->setSearchResults($searchResults);
$this->assertEquals(3, $this->job->getResultCount());
$this->assertSame(3, $this->job->getResultCount());
}
public function testPartProgressTracking(): void
@ -222,21 +224,21 @@ class BulkInfoProviderImportJobTest extends TestCase
$this->job->addPart($part);
}
$this->assertEquals(0, $this->job->getCompletedPartsCount());
$this->assertEquals(0, $this->job->getSkippedPartsCount());
$this->assertSame(0, $this->job->getCompletedPartsCount());
$this->assertSame(0, $this->job->getSkippedPartsCount());
$this->job->markPartAsCompleted(1);
$this->job->markPartAsCompleted(2);
$this->job->markPartAsSkipped(3, 'Error');
$this->assertEquals(2, $this->job->getCompletedPartsCount());
$this->assertEquals(1, $this->job->getSkippedPartsCount());
$this->assertSame(2, $this->job->getCompletedPartsCount());
$this->assertSame(1, $this->job->getSkippedPartsCount());
}
public function testProgressPercentage(): void
{
$emptyJob = new BulkInfoProviderImportJob();
$this->assertEquals(100.0, $emptyJob->getProgressPercentage());
$this->assertEqualsWithDelta(100.0, $emptyJob->getProgressPercentage(), PHP_FLOAT_EPSILON);
// Test with actual parts - setPartIds doesn't actually add parts
$parts = [
@ -250,18 +252,18 @@ class BulkInfoProviderImportJobTest extends TestCase
$this->job->addPart($part);
}
$this->assertEquals(0.0, $this->job->getProgressPercentage());
$this->assertEqualsWithDelta(0.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON);
$this->job->markPartAsCompleted(1);
$this->job->markPartAsCompleted(2);
$this->assertEquals(40.0, $this->job->getProgressPercentage());
$this->assertEqualsWithDelta(40.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON);
$this->job->markPartAsSkipped(3, 'Error');
$this->assertEquals(60.0, $this->job->getProgressPercentage());
$this->assertEqualsWithDelta(60.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON);
$this->job->markPartAsCompleted(4);
$this->job->markPartAsCompleted(5);
$this->assertEquals(100.0, $this->job->getProgressPercentage());
$this->assertEqualsWithDelta(100.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON);
}
public function testIsAllPartsCompleted(): void
@ -301,8 +303,8 @@ class BulkInfoProviderImportJobTest extends TestCase
$this->job->addPart($part);
}
$this->assertEquals('info_providers.bulk_import.job_name_template', $this->job->getDisplayNameKey());
$this->assertEquals(['%count%' => 3], $this->job->getDisplayNameParams());
$this->assertSame('info_providers.bulk_import.job_name_template', $this->job->getDisplayNameKey());
$this->assertSame(['%count%' => 3], $this->job->getDisplayNameParams());
}
public function testFormattedTimestamp(): void

View file

@ -58,7 +58,7 @@ use App\Entity\UserSystem\Group;
use App\Entity\UserSystem\User;
use PHPUnit\Framework\TestCase;
class AbstractLogEntryTest extends TestCase
final class AbstractLogEntryTest extends TestCase
{
public function testSetGetTarget(): void
{

View file

@ -25,7 +25,7 @@ namespace App\Tests\Entity\LogSystem;
use App\Entity\LogSystem\LogLevel;
use PHPUnit\Framework\TestCase;
class LogLevelTest extends TestCase
final class LogLevelTest extends TestCase
{
public function testToPSR3LevelString(): void

View file

@ -30,7 +30,7 @@ use App\Entity\Parts\Category;
use App\Entity\UserSystem\User;
use PHPUnit\Framework\TestCase;
class LogTargetTypeTest extends TestCase
final class LogTargetTypeTest extends TestCase
{
public function testToClass(): void

View file

@ -45,7 +45,7 @@ use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parameters\PartParameter;
use PHPUnit\Framework\TestCase;
class PartParameterTest extends TestCase
final class PartParameterTest extends TestCase
{
public static function valueWithUnitDataProvider(): \Iterator
{

View file

@ -26,7 +26,7 @@ use App\Entity\Parts\InfoProviderReference;
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
use PHPUnit\Framework\TestCase;
class InfoProviderReferenceTest extends TestCase
final class InfoProviderReferenceTest extends TestCase
{
public function testNoProvider(): void
{

View file

@ -26,7 +26,7 @@ use App\Entity\Parts\AssociationType;
use App\Entity\Parts\PartAssociation;
use PHPUnit\Framework\TestCase;
class PartAssociationTest extends TestCase
final class PartAssociationTest extends TestCase
{
public function testGetTypeTranslationKey(): void

View file

@ -26,7 +26,7 @@ use App\Entity\Parts\PartLot;
use DateTime;
use PHPUnit\Framework\TestCase;
class PartLotTest extends TestCase
final class PartLotTest extends TestCase
{
public function testIsExpired(): void
{

View file

@ -29,7 +29,7 @@ use DateTime;
use Doctrine\Common\Collections\Collection;
use PHPUnit\Framework\TestCase;
class PartTest extends TestCase
final class PartTest extends TestCase
{
public function testAddRemovePartLot(): void
{

View file

@ -26,7 +26,7 @@ use App\Entity\PriceInformations\Currency;
use Brick\Math\BigDecimal;
use PHPUnit\Framework\TestCase;
class CurrencyTest extends TestCase
final class CurrencyTest extends TestCase
{
public function testGetInverseExchangeRate(): void
{

View file

@ -27,7 +27,7 @@ use App\Entity\PriceInformations\Pricedetail;
use Doctrine\Common\Collections\Collection;
use PHPUnit\Framework\TestCase;
class OrderdetailTest extends TestCase
final class OrderdetailTest extends TestCase
{
public function testAddRemovePricdetails(): void
{

View file

@ -28,7 +28,7 @@ use App\Entity\PriceInformations\Pricedetail;
use Brick\Math\BigDecimal;
use PHPUnit\Framework\TestCase;
class PricedetailTest extends TestCase
final class PricedetailTest extends TestCase
{
public function testGetPricePerUnit(): void
{

View file

@ -25,7 +25,7 @@ namespace App\Tests\Entity\UserSystem;
use App\Entity\UserSystem\ApiTokenType;
use PHPUnit\Framework\TestCase;
class ApiTokenTypeTest extends TestCase
final class ApiTokenTypeTest extends TestCase
{
public function testGetTokenPrefix(): void

View file

@ -25,7 +25,7 @@ namespace App\Tests\Entity\UserSystem;
use App\Entity\UserSystem\PermissionData;
use PHPUnit\Framework\TestCase;
class PermissionDataTest extends TestCase
final class PermissionDataTest extends TestCase
{
public function testGetSetIs(): void

View file

@ -31,7 +31,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Uuid;
use Webauthn\TrustPath\EmptyTrustPath;
class UserTest extends TestCase
final class UserTest extends TestCase
{
public function testGetFullName(): void
{