Applied rector to test files

This commit is contained in:
Jan Böhmer 2023-06-11 14:18:53 +02:00
parent 7ee01d9a05
commit 98dc553938
46 changed files with 42 additions and 102 deletions

View file

@ -30,6 +30,6 @@ use App\Entity\Attachments\AttachmentType;
*/
class AttachmentTypeControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/attachment_type';
protected static string $base_path = '/en/attachment_type';
protected static string $entity_class = AttachmentType::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Category;
*/
class CategoryControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/category';
protected static string $base_path = '/en/category';
protected static string $entity_class = Category::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Footprint;
*/
class FootprintControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/footprint';
protected static string $base_path = '/en/footprint';
protected static string $entity_class = Footprint::class;
}

View file

@ -46,7 +46,7 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class LabelProfileControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/label_profile';
protected static string $base_path = '/en/label_profile';
protected static string $entity_class = LabelProfile::class;
/**

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Manufacturer;
*/
class ManufacturerControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/manufacturer';
protected static string $base_path = '/en/manufacturer';
protected static string $entity_class = Manufacturer::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\MeasurementUnit;
*/
class MeasurementUnitControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/measurement_unit';
protected static string $base_path = '/en/measurement_unit';
protected static string $entity_class = MeasurementUnit::class;
}

View file

@ -31,6 +31,6 @@ use App\Entity\ProjectSystem\Project;
*/
class ProjectControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/project';
protected static string $base_path = '/en/project';
protected static string $entity_class = Project::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Storelocation;
*/
class StorelocationControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/store_location';
protected static string $base_path = '/en/store_location';
protected static string $entity_class = Storelocation::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Supplier;
*/
class SupplierControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en'.'/supplier';
protected static string $base_path = '/en/supplier';
protected static string $entity_class = Supplier::class;
}

View file

@ -75,7 +75,7 @@ class RedirectControllerTest extends WebTestCase
$this->client->request('GET', $url);
$response = $this->client->getResponse();
if ($expect_redirect) {
$this->assertSame(302, $response->getStatusCode());
$this->assertResponseStatusCodeSame(302);
}
$this->assertSame($expect_redirect, $response->isRedirect());
}
@ -104,10 +104,6 @@ class RedirectControllerTest extends WebTestCase
* @dataProvider urlAddLocaleDataProvider
* @group slow
* @depends testUrlMatch
*
* @param string|null $user_locale
* @param string $input_path
* @param string $redirect_path
*/
public function testAddLocale(?string $user_locale, string $input_path, string $redirect_path): void
{
@ -122,6 +118,6 @@ class RedirectControllerTest extends WebTestCase
$this->client->followRedirects(false);
$this->client->request('GET', $input_path);
$this->assertSame($redirect_path, $this->client->getResponse()->headers->get('Location'));
$this->assertResponseRedirects($redirect_path);
}
}

View file

@ -54,16 +54,8 @@ class CompoundFilterTraitTest extends TestCase
$filter = new class($f1, $f2, $f3, null) {
use CompoundFilterTrait;
protected $filter1;
private $filter2;
public $filter3;
protected $filter4;
public function __construct($f1, $f2, $f3, $f4) {
$this->filter1 = $f1;
$this->filter2 = $f2;
$this->filter3 = $f3;
$this->filter4 = $f4;
public function __construct(protected $filter1, private $filter2, public $filter3, protected $filter4)
{
}
public function _findAllChildFilters()
@ -104,16 +96,8 @@ class CompoundFilterTraitTest extends TestCase
$filter = new class($f1, $f2, $f3, null) {
use CompoundFilterTrait;
protected $filter1;
private $filter2;
public $filter3;
protected $filter4;
public function __construct($f1, $f2, $f3, $f4) {
$this->filter1 = $f1;
$this->filter2 = $f2;
$this->filter3 = $f3;
$this->filter4 = $f4;
public function __construct(protected $filter1, private $filter2, public $filter3, protected $filter4)
{
}
public function _applyAllChildFilters(QueryBuilder $queryBuilder): void

View file

@ -282,7 +282,7 @@ class AttachmentTest extends TestCase
* @param string $property - property on instance being modified
* @param mixed $value - new value of the property being modified
*/
public function setProtectedProperty(object $object, string $property, $value): void
public function setProtectedProperty(object $object, string $property, mixed $value): void
{
$reflection = new ReflectionClass($object);
$reflection_property = $reflection->getProperty($property);

View file

@ -42,7 +42,7 @@ class AbstractStructuralDBElementTest extends TestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Build a simple hierachy
$this->root = new AttachmentType();

View file

@ -104,9 +104,9 @@ class PartTest extends TestCase
$this->assertSame(13.141, $part->getAmountSum());
//1 billion part lot
$part->addPartLot((new PartLot())->setAmount(1000000000));
$this->assertSame(1000000013.141, $part->getAmountSum());
$part->addPartLot((new PartLot())->setAmount(1_000_000_000));
$this->assertSame(1_000_000_013.141, $part->getAmountSum());
$measurement_unit->setIsInteger(true);
$this->assertSame(1000000013.0, $part->getAmountSum());
$this->assertSame(1_000_000_013.0, $part->getAmountSum());
}
}

View file

@ -43,10 +43,8 @@ class ProjectBuildRequestTest extends TestCase
/** @var ProjectBOMEntry */
private ProjectBOMEntry $bom_entry1c;
/** @var PartLot $lot1a */
private $lot1a;
/** @var PartLot $lot1b */
private $lot1b;
private \App\Entity\Parts\PartLot $lot1a;
private \App\Entity\Parts\PartLot $lot1b;
private PartLot $lot2;
/** @var Part */

View file

@ -47,7 +47,7 @@ class SamlUserFactoryTest extends WebTestCase
$this->assertInstanceOf(User::class, $user);
$this->assertEquals('sso_user', $user->getUsername());
$this->assertEquals('sso_user', $user->getUserIdentifier());
//User must not change his password
$this->assertFalse($user->isNeedPwChange());
//And must not be disabled

View file

@ -33,7 +33,6 @@ class BigNumberNormalizerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get an service instance.
self::bootKernel();
$this->service = self::getContainer()->get(BigNumberNormalizer::class);

View file

@ -34,7 +34,6 @@ class PartNormalizerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(PartNormalizer::class);

View file

@ -32,7 +32,6 @@ class StructuralElementDenormalizerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(StructuralElementDenormalizer::class);

View file

@ -32,7 +32,6 @@ class StructuralElementFromNameDenormalizerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(StructuralElementFromNameDenormalizer::class);

View file

@ -36,7 +36,6 @@ class StructuralElementNormalizerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get an service instance.
self::bootKernel();
$this->service = self::getContainer()->get(StructuralElementNormalizer::class);

View file

@ -40,8 +40,6 @@ class AttachmentPathResolverTest extends WebTestCase
public function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
@ -161,7 +159,6 @@ class AttachmentPathResolverTest extends WebTestCase
/**
* @dataProvider germanFootprintPathdDataProvider
* @return void
*/
public function testConversionOfGermanFootprintPaths(string $expected, string $input): void
{

View file

@ -41,8 +41,6 @@ class ElementTypeNameGeneratorTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get an service instance.
$this->service = self::getContainer()->get(ElementTypeNameGenerator::class);
}

View file

@ -36,7 +36,7 @@ class AmountFormatterTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();
@ -47,7 +47,7 @@ class AmountFormatterTest extends WebTestCase
{
$this->assertSame('2', $this->service->format(2.321));
$this->assertSame('1002', $this->service->format(1002.356));
$this->assertSame('1000454', $this->service->format(1000454.0));
$this->assertSame('1000454', $this->service->format(1_000_454.0));
$this->assertSame('0', $this->service->format(0.01));
$this->assertSame('0', $this->service->format(0));
}

View file

@ -36,8 +36,6 @@ class BOMImporterTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(BOMImporter::class);

View file

@ -34,7 +34,6 @@ class EntityExporterTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->service = self::getContainer()->get(EntityExporter::class);
}

View file

@ -42,8 +42,6 @@ class EntityImporterTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(EntityImporter::class);

View file

@ -49,10 +49,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class BarcodeContentGeneratorTest extends KernelTestCase
{
/**
* @var BarcodeContentGenerator
*/
private $service;
private ?object $service = null;
protected function setUp(): void
{

View file

@ -75,14 +75,14 @@ class BarcodeNormalizerTest extends WebTestCase
[['lot', 10], 'Lß000010'],
[['part', 123], 'P-000123'],
[['location', 123], 'S-000123'],
[['lot', 12345678], 'L-12345678'],
[['lot', 12_345_678], 'L-12345678'],
//Legacy storelocation format
[['location', 336], '$L00336'],
[['location', 12345678], '$L12345678'],
[['location', 12_345_678], '$L12345678'],
//Legacy Part format
[['part', 123], '0000123'],
[['part', 123], '00001236'],
[['part', 1234567], '12345678'],
[['part', 1_234_567], '12345678'],
];
}

View file

@ -47,10 +47,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class BarcodeRedirectorTest extends KernelTestCase
{
/**
* @var BarcodeRedirector
*/
private $service;
private ?object $service = null;
protected function setUp(): void
{
@ -81,7 +78,7 @@ class BarcodeRedirectorTest extends KernelTestCase
{
$this->expectException(EntityNotFoundException::class);
//If we encounter an invalid lot, we must throw an exception
$this->service->getRedirectURL('lot', 12345678);
$this->service->getRedirectURL('lot', 12_345_678);
}
public function testInvalidType(): void

View file

@ -60,8 +60,6 @@ class LabelTextReplacerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(LabelTextReplacer::class);

View file

@ -51,10 +51,7 @@ use Twig\Sandbox\SecurityError;
class SandboxedTwigProviderTest extends WebTestCase
{
/**
* @var SandboxedTwigProvider
*/
private $service;
private ?object $service = null;
protected function setUp(): void
{

View file

@ -53,7 +53,7 @@ class EventCommentHelperTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();

View file

@ -56,7 +56,7 @@ class EventLoggerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();

View file

@ -34,7 +34,7 @@ class FAIconGeneratorTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();

View file

@ -51,7 +51,6 @@ class ParameterExtractorTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(ParameterExtractor::class);

View file

@ -46,7 +46,6 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(PartLotWithdrawAddHelper::class);

View file

@ -38,7 +38,6 @@ class PricedetailHelperTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
//Get a service instance.
self::bootKernel();
$this->service = self::getContainer()->get(PricedetailHelper::class);

View file

@ -34,7 +34,6 @@ class ProjectBuildHelperTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->service = self::getContainer()->get(ProjectBuildHelper::class);
}

View file

@ -31,7 +31,6 @@ class ProjectBuildPartHelperTest extends WebTestCase
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->service = self::getContainer()->get(ProjectBuildPartHelper::class);
}

View file

@ -42,7 +42,7 @@ class TreeViewGeneratorTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();

View file

@ -43,7 +43,7 @@ class PermissionManagerTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();

View file

@ -27,11 +27,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class TestPermissionHolder implements HasPermissionsInterface
{
private PermissionData $perm_data;
public function __construct(PermissionData $perm_data)
public function __construct(private readonly PermissionData $perm_data)
{
$this->perm_data = $perm_data;
}
public function getPermissions(): PermissionData
@ -49,7 +46,6 @@ class PermissionSchemaUpdaterTest extends WebTestCase
public function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->service = self::getContainer()->get(PermissionSchemaUpdater::class);

View file

@ -43,7 +43,7 @@ class EntityExtensionTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get a service instance.
self::bootKernel();

View file

@ -31,7 +31,7 @@ class TwigCoreExtensionTest extends WebTestCase
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
//Get an service instance.
self::bootKernel();
@ -52,8 +52,8 @@ class TwigCoreExtensionTest extends WebTestCase
$obj = new class {
public $test = 1;
protected $test2 = 3;
private $test3 = 5;
private $test4 = 7;
private int $test3 = 5;
private int $test4 = 7;
public function getTest4(): int
{

View file

@ -44,9 +44,6 @@ class UserExtensionTest extends WebTestCase
/**
* @dataProvider removeeLocaleFromPathDataSet
* @param string $expected
* @param string $input
* @return void
*/
public function testRemoveLocaleFromPath(string $expected, string $input): void
{