Skip to content

Commit 717223d

Browse files
committed
Add more precise types in reusable test cases
1 parent d131e43 commit 717223d

File tree

8 files changed

+32
-6
lines changed

8 files changed

+32
-6
lines changed

Test/FormIntegrationTestCase.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
namespace Symfony\Component\Form\Test;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Form\FormExtensionInterface;
1516
use Symfony\Component\Form\FormFactoryInterface;
1617
use Symfony\Component\Form\Forms;
18+
use Symfony\Component\Form\FormTypeExtensionInterface;
19+
use Symfony\Component\Form\FormTypeGuesserInterface;
20+
use Symfony\Component\Form\FormTypeInterface;
1721

1822
/**
1923
* @author Bernhard Schussek <[email protected]>
@@ -32,21 +36,33 @@ protected function setUp(): void
3236
->getFormFactory();
3337
}
3438

39+
/**
40+
* @return FormExtensionInterface[]
41+
*/
3542
protected function getExtensions()
3643
{
3744
return [];
3845
}
3946

47+
/**
48+
* @return FormTypeExtensionInterface[]
49+
*/
4050
protected function getTypeExtensions()
4151
{
4252
return [];
4353
}
4454

55+
/**
56+
* @return FormTypeInterface[]
57+
*/
4558
protected function getTypes()
4659
{
4760
return [];
4861
}
4962

63+
/**
64+
* @return FormTypeGuesserInterface[]
65+
*/
5066
protected function getTypeGuessers()
5167
{
5268
return [];

Test/TypeTestCase.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1515
use Symfony\Component\Form\FormBuilder;
16+
use Symfony\Component\Form\FormExtensionInterface;
1617
use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait;
1718

1819
abstract class TypeTestCase extends FormIntegrationTestCase
@@ -28,6 +29,9 @@ protected function setUp(): void
2829
$this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory);
2930
}
3031

32+
/**
33+
* @return FormExtensionInterface[]
34+
*/
3135
protected function getExtensions()
3236
{
3337
$extensions = [];
@@ -39,11 +43,17 @@ protected function getExtensions()
3943
return $extensions;
4044
}
4145

46+
/**
47+
* @return void
48+
*/
4249
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
4350
{
4451
self::assertEquals($expected->format('c'), $actual->format('c'));
4552
}
4653

54+
/**
55+
* @return void
56+
*/
4757
public static function assertDateIntervalEquals(\DateInterval $expected, \DateInterval $actual)
4858
{
4959
self::assertEquals($expected->format('%RP%yY%mM%dDT%hH%iM%sS'), $actual->format('%RP%yY%mM%dDT%hH%iM%sS'));

Tests/Extension/Core/Type/ChoiceTypeTranslationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ChoiceTypeTranslationTest extends TypeTestCase
2727
'Roman' => 'e',
2828
];
2929

30-
protected function getExtensions()
30+
protected function getExtensions(): array
3131
{
3232
$translator = $this->createMock(TranslatorInterface::class);
3333
$translator->expects($this->any())->method('trans')

Tests/Extension/Core/Type/FileTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FileTypeTest extends BaseTypeTestCase
2323
{
2424
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\FileType';
2525

26-
protected function getExtensions()
26+
protected function getExtensions(): array
2727
{
2828
return array_merge(parent::getExtensions(), [new CoreExtension(null, null, new IdentityTranslator())]);
2929
}

Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function setUp(): void
4242
parent::setUp();
4343
}
4444

45-
protected function getExtensions()
45+
protected function getExtensions(): array
4646
{
4747
return array_merge(parent::getExtensions(), [
4848
new CsrfExtension($this->tokenManager, new IdentityTranslator()),

Tests/Extension/HtmlSanitizer/Type/TextTypeHtmlSanitizerExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class TextTypeHtmlSanitizerExtensionTest extends TypeTestCase
2222
{
23-
protected function getExtensions()
23+
protected function getExtensions(): array
2424
{
2525
$fooSanitizer = $this->createMock(HtmlSanitizerInterface::class);
2626
$fooSanitizer->expects($this->once())

Tests/Extension/PasswordHasher/Type/PasswordTypePasswordHasherExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function setUp(): void
4040
parent::setUp();
4141
}
4242

43-
protected function getExtensions()
43+
protected function getExtensions(): array
4444
{
4545
return array_merge(parent::getExtensions(), [
4646
new PasswordHasherExtension(new PasswordHasherListener($this->passwordHasher)),

Tests/Extension/Validator/Constraints/FormValidatorPerformanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class FormValidatorPerformanceTest extends FormPerformanceTestCase
2222
{
23-
protected function getExtensions()
23+
protected function getExtensions(): array
2424
{
2525
return [
2626
new ValidatorExtension(Validation::createValidator(), false),

0 commit comments

Comments
 (0)