Skip to content

Commit ed6f16d

Browse files
committed
Uniformize tests
1 parent 4bda90d commit ed6f16d

File tree

11 files changed

+40
-52
lines changed

11 files changed

+40
-52
lines changed

tests/ConfigurableEnumTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Yokai\EnumBundle\ConfigurableEnum;
66

7+
/**
8+
* @author Yann Eugoné <[email protected]>
9+
*/
710
class ConfigurableEnumTest extends TestCase
811
{
912
public function testConfigurability(): void

tests/ConstantExtractorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use Yokai\EnumBundle\ConstantExtractor;
77
use Yokai\EnumBundle\Exception\CannotExtractConstantsException;
88

9+
/**
10+
* @author Yann Eugoné <[email protected]>
11+
*/
912
class ConstantExtractorTest extends TestCase
1013
{
1114
public function getExtractor(): ConstantExtractor

tests/ConstantListEnumTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use Yokai\EnumBundle\ConstantListEnum;
77
use Yokai\EnumBundle\Tests\Fixtures\Vehicle;
88

9+
/**
10+
* @author Yann Eugoné <[email protected]>
11+
*/
912
class ConstantListEnumTest extends TestCase
1013
{
1114
public function getEnum(string $pattern, string $name): ConstantListEnum

tests/ConstantListTranslatedEnumTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Yokai\EnumBundle\ConstantListTranslatedEnum;
99
use Yokai\EnumBundle\Tests\Fixtures\Vehicle;
1010

11+
/**
12+
* @author Yann Eugoné <[email protected]>
13+
*/
1114
class ConstantListTranslatedEnumTest extends TestCase
1215
{
1316
/**
@@ -20,11 +23,6 @@ protected function setUp(): void
2023
$this->translator = $this->prophesize(TranslatorInterface::class);
2124
}
2225

23-
protected function tearDown(): void
24-
{
25-
$this->translator = null;
26-
}
27-
2826
public function getEnum(string $pattern, string $name): ConstantListTranslatedEnum
2927
{
3028
return new ConstantListTranslatedEnum(

tests/DependencyInjection/CompilerPass/TaggedEnumCollectorCompilerPassTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Yokai\EnumBundle\Tests\DependencyInjection\CompilerPass;
44

5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\DependencyInjection\Definition;
57
use Symfony\Component\DependencyInjection\Reference;
68
use Yokai\EnumBundle\DependencyInjection\CompilerPass\TaggedEnumCollectorCompilerPass;
79
use Yokai\EnumBundle\Tests\TestCase;
@@ -21,31 +23,26 @@ protected function setUp(): void
2123
$this->compiler = new TaggedEnumCollectorCompilerPass;
2224
}
2325

24-
protected function tearDown(): void
25-
{
26-
unset($this->compiler);
27-
}
28-
2926
public function testCollectWhenServiceNotAvailable(): void
3027
{
31-
$compiler = $this->prophesize('Symfony\Component\DependencyInjection\ContainerBuilder');
28+
$compiler = $this->prophesize(ContainerBuilder::class);
3229
$compiler->hasDefinition('enum.registry')->shouldBeCalled()->willReturn(false);
3330

3431
$this->compiler->process($compiler->reveal());
3532
}
3633

3734
public function testCollectEnums(): void
3835
{
39-
$registry = $this->prophesize('Symfony\Component\DependencyInjection\Definition');
36+
$registry = $this->prophesize(Definition::class);
4037
$registry->addMethodCall('add', [new Reference('enum.gender')])->shouldBeCalled();
4138
$registry->addMethodCall('add', [new Reference('enum.type')])->shouldBeCalled();
4239

43-
$compiler = $this->prophesize('Symfony\Component\DependencyInjection\ContainerBuilder');
40+
$compiler = $this->prophesize(ContainerBuilder::class);
4441
$compiler->hasDefinition('enum.registry')->shouldBeCalled()->willReturn(true);
4542
$compiler->getDefinition('enum.registry')->shouldBeCalled()->willReturn($registry);
4643
$compiler->findTaggedServiceIds('enum')->shouldBeCalled()->willReturn([
47-
'enum.gender' => $this->prophesize('Symfony\Component\DependencyInjection\Definition')->reveal(),
48-
'enum.type' => $this->prophesize('Symfony\Component\DependencyInjection\Definition')->reveal(),
44+
'enum.gender' => $this->prophesize(Definition::class)->reveal(),
45+
'enum.type' => $this->prophesize(Definition::class)->reveal(),
4946
]);
5047

5148
$this->compiler->process($compiler->reveal());

tests/EnumRegistryTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ protected function setUp(): void
2727
$this->registry = new EnumRegistry;
2828
}
2929

30-
protected function tearDown(): void
31-
{
32-
unset($this->registry);
33-
}
34-
3530
public function testAddDuplicatedException(): void
3631
{
3732
$this->expectException(DuplicatedEnumException::class);

tests/Form/Extension/EnumTypeGuesserTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ protected function setUp(): void
5757

5858
$this->metadata = new ClassMetadata(self::TEST_CLASS);
5959
$this->metadata->addPropertyConstraint(self::TEST_PROPERTY, new Enum(['enum' => GenderEnum::class]));
60-
$this->metadataFactory = $this->prophesize(
61-
'Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface'
62-
);
60+
$this->metadataFactory = $this->prophesize(MetadataFactoryInterface::class);
6361
$this->metadataFactory->getMetadataFor(self::TEST_CLASS)
6462
->willReturn($this->metadata);
6563

tests/Form/Type/EnumTypeTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Prophecy\PhpUnit\ProphecyTrait;
66
use Symfony\Component\Form\FormInterface;
77
use Symfony\Component\Form\Test\TypeTestCase;
8+
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
9+
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
810
use Yokai\EnumBundle\EnumRegistry;
911
use Yokai\EnumBundle\Form\Type\EnumType;
1012
use Yokai\EnumBundle\Tests\Fixtures\GenderEnum;
@@ -31,13 +33,13 @@ protected function setUp(): void
3133

3234
public function testEnumOptionIsRequired(): void
3335
{
34-
$this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
36+
$this->expectException(MissingOptionsException::class);
3537
$this->createForm();
3638
}
3739

3840
public function testEnumOptionIsInvalid(): void
3941
{
40-
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
42+
$this->expectException(InvalidOptionsException::class);
4143
$this->createForm('state');
4244
}
4345

tests/TestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
66
use Prophecy\PhpUnit\ProphecyTrait;
77

8+
/**
9+
* @author Yann Eugoné <[email protected]>
10+
*/
811
abstract class TestCase extends PHPUnitTestCase
912
{
1013
use ProphecyTrait;

tests/Twig/Extension/EnumExtensionTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ protected function setUp(): void
2525
$this->registry = $this->prophesize(EnumRegistry::class);
2626
}
2727

28-
protected function tearDown(): void
29-
{
30-
unset(
31-
$this->registry
32-
);
33-
}
34-
3528
public function testEnumLabel(): void
3629
{
3730
$enum = $this->prophesize(EnumInterface::class);

0 commit comments

Comments
 (0)