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

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,18 +20,18 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Services\InfoProviderSystem\Providers\InfoProviderInterface;
use App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO;
use PHPUnit\Framework\TestCase;
class BulkSearchFieldMappingDTOTest extends TestCase
final class BulkSearchFieldMappingDTOTest extends TestCase
{
public function testProviderInstanceNormalization(): void
{
$mockProvider = $this->createMock(\App\Services\InfoProviderSystem\Providers\InfoProviderInterface::class);
$mockProvider = $this->createMock(InfoProviderInterface::class);
$mockProvider->method('getProviderKey')->willReturn('mock_provider');
$fieldMapping = new BulkSearchFieldMappingDTO(field: 'mpn', providers: ['provider1', $mockProvider], priority: 5);

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,46 +20,47 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Entity\Parts\Part;
use App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO;
use App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO;
use PHPUnit\Framework\TestCase;
class BulkSearchPartResultsDTOTest extends TestCase
final class BulkSearchPartResultsDTOTest extends TestCase
{
public function testHasErrors(): void
{
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []);
$this->assertFalse($test->hasErrors());
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], ['error1']);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], ['error1']);
$this->assertTrue($test->hasErrors());
}
public function testGetErrorCount(): void
{
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []);
$this->assertCount(0, $test->errors);
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], ['error1', 'error2']);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], ['error1', 'error2']);
$this->assertCount(2, $test->errors);
}
public function testHasResults(): void
{
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []);
$this->assertFalse($test->hasResults());
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [ $this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class) ], []);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [ $this->createStub(BulkSearchPartResultDTO::class) ], []);
$this->assertTrue($test->hasResults());
}
public function testGetResultCount(): void
{
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []);
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []);
$this->assertCount(0, $test->searchResults);
$test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [
$this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class),
$this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class)
$test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [
$this->createStub(BulkSearchPartResultDTO::class),
$this->createStub(BulkSearchPartResultDTO::class)
], []);
$this->assertCount(2, $test->searchResults);
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Entity\Parts\Part;
@ -29,7 +31,7 @@ use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class BulkSearchResponseDTOTest extends KernelTestCase
final class BulkSearchResponseDTOTest extends KernelTestCase
{
private EntityManagerInterface $entityManager;

View file

@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\InfoProviderSystem\DTOs\FileDTO;
use PHPUnit\Framework\TestCase;
class FileDTOTest extends TestCase
final class FileDTOTest extends TestCase
{

View file

@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
use PHPUnit\Framework\TestCase;
class ParameterDTOTest extends TestCase
final class ParameterDTOTest extends TestCase
{
public static function parseValueFieldDataProvider(): \Generator

View file

@ -26,7 +26,7 @@ use App\Services\InfoProviderSystem\DTOs\PriceDTO;
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
use PHPUnit\Framework\TestCase;
class PurchaseInfoDTOTest extends TestCase
final class PurchaseInfoDTOTest extends TestCase
{
public function testThrowOnInvalidType(): void
{

View file

@ -25,7 +25,7 @@ namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
use PHPUnit\Framework\TestCase;
class SearchResultDTOTest extends TestCase
final class SearchResultDTOTest extends TestCase
{
public function testPreviewImageURL(): void
{