Skip to content

Commit 44be5f1

Browse files
minor symfony#57961 [Form] Replace class-string by ::class for BaseTypeTestCase::TESTED_TYPE (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- [Form] Replace class-string by `::class` for `BaseTypeTestCase::TESTED_TYPE` | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT This change seems to be already operated on the most recent types (Color, Uuid, Ulid, Enum, ...). I propose to put it all together and use `::class` notation for `BaseTypeTestCase::TESTED_TYPE` overriders. Commits ------- ba006c1 [Form] Replace class-string by `::class` for `BaseTypeTestCase::TESTED_TYPE`
2 parents dd9fa15 + ba006c1 commit 44be5f1

26 files changed

+61
-35
lines changed

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242

4343
class EntityTypeTest extends BaseTypeTestCase
4444
{
45-
public const TESTED_TYPE = 'Symfony\Bridge\Doctrine\Form\Type\EntityType';
46-
47-
private const ITEM_GROUP_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity';
48-
private const SINGLE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity';
49-
private const SINGLE_IDENT_NO_TO_STRING_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity';
50-
private const SINGLE_STRING_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity';
51-
private const SINGLE_ASSOC_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleAssociationToIntIdEntity';
52-
private const SINGLE_STRING_CASTABLE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity';
53-
private const COMPOSITE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity';
54-
private const COMPOSITE_STRING_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeStringIdEntity';
45+
public const TESTED_TYPE = EntityType::class;
46+
47+
private const ITEM_GROUP_CLASS = GroupableEntity::class;
48+
private const SINGLE_IDENT_CLASS = SingleIntIdEntity::class;
49+
private const SINGLE_IDENT_NO_TO_STRING_CLASS = SingleIntIdNoToStringEntity::class;
50+
private const SINGLE_STRING_IDENT_CLASS = SingleStringIdEntity::class;
51+
private const SINGLE_ASSOC_IDENT_CLASS = SingleAssociationToIntIdEntity::class;
52+
private const SINGLE_STRING_CASTABLE_IDENT_CLASS = SingleStringCastableIdEntity::class;
53+
private const COMPOSITE_IDENT_CLASS = CompositeIntIdEntity::class;
54+
private const COMPOSITE_STRING_IDENT_CLASS = CompositeStringIdEntity::class;
5555

5656
private EntityManager $em;
5757
private MockObject&ManagerRegistry $emRegistry;

src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
1415
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
1516

1617
/**
1718
* @author Stepan Anchugov <kixxx1@gmail.com>
1819
*/
1920
class BirthdayTypeTest extends DateTypeTest
2021
{
21-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\BirthdayType';
22+
public const TESTED_TYPE = BirthdayType::class;
2223

2324
public function testSetInvalidYearsOption()
2425
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
use Symfony\Component\Form\Button;
1515
use Symfony\Component\Form\Exception\BadMethodCallException;
1616
use Symfony\Component\Form\Exception\LogicException;
17+
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
1718
use Symfony\Component\Form\Extension\Core\Type\FormType;
1819

1920
/**
2021
* @author Bernhard Schussek <bschussek@gmail.com>
2122
*/
2223
class ButtonTypeTest extends BaseTypeTestCase
2324
{
24-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\ButtonType';
25+
public const TESTED_TYPE = ButtonType::class;
2526

2627
public function testCreateButtonInstances()
2728
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\CallbackTransformer;
15+
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
1516
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
1617

1718
class CheckboxTypeTest extends BaseTypeTestCase
1819
{
19-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CheckboxType';
20+
public const TESTED_TYPE = CheckboxType::class;
2021

2122
public function testDataIsFalseByDefault()
2223
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
1616
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
1717
use Symfony\Component\Form\Exception\TransformationFailedException;
18+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
1819
use Symfony\Component\Form\FormInterface;
1920
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
2021

2122
class ChoiceTypeTest extends BaseTypeTestCase
2223
{
23-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType';
24+
public const TESTED_TYPE = ChoiceType::class;
2425

2526
private array $choices = [
2627
'Bernhard' => 'a',

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTranslationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\Extension\Core\CoreExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
1516
use Symfony\Component\Form\Test\TypeTestCase;
1617
use Symfony\Contracts\Translation\TranslatorInterface;
1718

1819
class ChoiceTypeTranslationTest extends TypeTestCase
1920
{
20-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType';
21+
public const TESTED_TYPE = ChoiceType::class;
2122

2223
private array $choices = [
2324
'Bernhard' => 'a',

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1515
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
16+
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
1617
use Symfony\Component\Form\Form;
1718
use Symfony\Component\Form\Tests\Fixtures\Author;
1819
use Symfony\Component\Form\Tests\Fixtures\AuthorType;
1920
use Symfony\Component\Form\Tests\Fixtures\BlockPrefixedFooTextType;
2021

2122
class CollectionTypeTest extends BaseTypeTestCase
2223
{
23-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CollectionType';
24+
public const TESTED_TYPE = CollectionType::class;
2425

2526
public function testContainsNoChildByDefault()
2627
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
15+
use Symfony\Component\Form\Extension\Core\Type\CountryType;
1516
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
class CountryTypeTest extends BaseTypeTestCase
1819
{
19-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CountryType';
20+
public const TESTED_TYPE = CountryType::class;
2021

2122
protected function setUp(): void
2223
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
15+
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
1516
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
class CurrencyTypeTest extends BaseTypeTestCase
1819
{
19-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CurrencyType';
20+
public const TESTED_TYPE = CurrencyType::class;
2021

2122
protected function setUp(): void
2223
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\Exception\LogicException;
15+
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
1516
use Symfony\Component\Form\FormError;
1617
use Symfony\Component\Form\FormInterface;
1718

1819
class DateTimeTypeTest extends BaseTypeTestCase
1920
{
20-
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateTimeType';
21+
public const TESTED_TYPE = DateTimeType::class;
2122

2223
private string $defaultLocale;
2324

0 commit comments

Comments
 (0)