Skip to content

Prepare usage of PHPUnit12 #731

@llaville

Description

@llaville

Hello,

I know there is no hurry, but to prepare usage of PHPUnit12 we need to fix at least PHPUnit deprecations.

For example, if your invoke this command :

vendor/bin/phpunit tests/Unit/Aggregate/ --display-phpunit-deprecations

You'll get those output :

There were 8 PHPUnit test runner deprecations:

1) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\AggregateHeaderTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

2) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\AggregateRootIdNotSupportedTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

3) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\AggregateRootTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

4) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\ApplyMethodNotFoundTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

5) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\CustomIdTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

6) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\MetadataNotPossibleTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

7) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\UuidTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

8) Metadata found in doc-comment for class Patchlevel\EventSourcing\Tests\Unit\Aggregate\AggregateRootTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

WARNINGS!
Tests: 20, Assertions: 68, Warnings: 1, PHPUnit Deprecations: 8.

As they are more than an hundred to fix in tests folder, I've used PHP-CS-Fixer with such configuration file .php-cs-fixer.dist.php :

<?php

$finder = (new PhpCsFixer\Finder())
    ->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
;

return (new PhpCsFixer\Config())
    ->setRules([
        'php_unit_attributes' => true,
    ])
    ->setFinder($finder)
;

And run first attempt to check before to fix

devilbox@php-8.2.28 in /shared/backups/forks/event-sourcing $ /shared/backups/php/php-cs-fixer-3.75.phar check
PHP CS Fixer 3.75.0 (e44b8f9) Persian Successor by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.2.28
Running analysis on 1 core sequentially.
You can enable parallel runner and speed up the analysis! Please see usage docs for more information.
Loaded config default from "/shared/backups/forks/event-sourcing/.php-cs-fixer.dist.php".
Using cache file ".php-cs-fixer.cache".
 276/276 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

   1) tests/Unit/Message/PipeTest.php
   2) tests/Unit/Message/HeaderNotFoundTest.php
   3) tests/Unit/Message/MessageTest.php
   4) tests/Unit/Message/ReducerTest.php
   5) tests/Unit/Message/Serializer/DefaultHeadersSerializerTest.php
   6) tests/Unit/Message/Translator/UntilEventTranslatorTest.php
   7) tests/Unit/Message/Translator/FilterEventTranslatorTest.php
   8) tests/Unit/Message/Translator/ExcludeEventWithHeaderTranslatorTest.php
   9) tests/Unit/Message/Translator/ExcludeEventTranslatorTest.php
  10) tests/Unit/Message/Translator/RecalculatePlayheadTranslatorTest.php
  11) tests/Unit/Message/Translator/ChainTranslatorTest.php
  12) tests/Unit/Message/Translator/ReplaceEventTranslatorTest.php
  13) tests/Unit/Message/Translator/AggregateToStreamHeaderTranslatorTest.php
  14) tests/Unit/Message/Translator/IncludeEventTranslatorTest.php
  15) tests/Unit/Message/Translator/ClosureTranslatorTest.php
  16) tests/Unit/Message/Translator/IncludeEventWithHeaderTranslatorTest.php
  17) tests/Unit/Repository/MessageDecorator/ChainMessageDecoratorTest.php
  18) tests/Unit/Repository/MessageDecorator/SplitStreamDecoratorTest.php
  19) tests/Unit/Repository/DefaultRepositoryManagerTest.php
  20) tests/Unit/Repository/DefaultRepositoryTest.php
  21) tests/Unit/Store/Crtieria/CriteriaTest.php
  22) tests/Unit/Store/Crtieria/CriteriaBuilderTest.php
  23) tests/Unit/Store/DoctrineDbalStoreTest.php
  24) tests/Unit/Store/ReadOnlyStoreTest.php
  25) tests/Unit/Store/InMemoryStoreTest.php
  26) tests/Unit/Store/StreamDoctrineDbalStreamTest.php
  27) tests/Unit/Store/ArrayStreamTest.php
  28) tests/Unit/Store/StreamDoctrineDbalStoreTest.php
  29) tests/Unit/Store/StreamReadOnlyStoreTest.php
  30) tests/Unit/Store/DoctrineDbalStreamTest.php
  31) tests/Unit/Attribute/SuppressMissingApplyTest.php
  32) tests/Unit/Attribute/IdTest.php
  33) tests/Unit/Attribute/SubscriberTest.php
  34) tests/Unit/Attribute/EventTest.php
  35) tests/Unit/Attribute/SplitStreamTest.php
  36) tests/Unit/Attribute/AggregateTest.php
  37) tests/Unit/Attribute/SubscribeTest.php
  38) tests/Unit/Attribute/HeaderTest.php
  39) tests/Unit/Attribute/SnapshotTest.php
  40) tests/Unit/Attribute/TeardownTest.php
  41) tests/Unit/Attribute/ApplyTest.php
  42) tests/Unit/Attribute/SetupTest.php
  43) tests/Unit/Clock/SystemClockTest.php
  44) tests/Unit/Clock/FrozenClockTest.php
  45) tests/Unit/Snapshot/Adapter/Psr16SnapshotAdapterTest.php
  46) tests/Unit/Snapshot/Adapter/InMemorySnapshotAdapterTest.php
  47) tests/Unit/Snapshot/Adapter/SnapshotNotFoundTest.php
  48) tests/Unit/Snapshot/Adapter/Psr6SnapshotAdapterTest.php
  49) tests/Unit/Snapshot/ArrayAdapterRepositoryTest.php
  50) tests/Unit/Snapshot/SnapshotVersionInvalidTest.php
  51) tests/Unit/Snapshot/DefaultSnapshotStoreTest.php
  52) tests/Unit/Snapshot/AdapterNotFoundTest.php
  53) tests/Unit/Snapshot/SnapshotNotConfiguredTest.php
  54) tests/Unit/Snapshot/SnapshotTest.php
  55) tests/Unit/Snapshot/SnapshotNotFoundTest.php
  56) tests/Unit/Test/IncrementalRamseyUuidFactoryTest.php
  57) tests/Unit/CommandBus/ChainHandlerProviderTest.php
  58) tests/Unit/CommandBus/HandlerFinderTest.php
  59) tests/Unit/CommandBus/ServiceLocatorTest.php
  60) tests/Unit/CommandBus/Handler/CreateAggregateHandlerTest.php
  61) tests/Unit/CommandBus/Handler/DefaultParameterResolverTest.php
  62) tests/Unit/CommandBus/Handler/UpdateAggregateHandlerTest.php
  63) tests/Unit/CommandBus/AggregateHandlerProviderTest.php
  64) tests/Unit/CommandBus/HandlerDescriptorTest.php
  65) tests/Unit/CommandBus/SyncCommandBusTest.php
  66) tests/Unit/CommandBus/ServiceHandlerProviderTest.php
  67) tests/Unit/Aggregate/AggregateRootIdNotSupportedTest.php
  68) tests/Unit/Aggregate/MetadataNotPossibleTest.php
  69) tests/Unit/Aggregate/ApplyMethodNotFoundTest.php
  70) tests/Unit/Aggregate/UuidTest.php
  71) tests/Unit/Aggregate/AggregateRootTest.php
  72) tests/Unit/Aggregate/AggregateHeaderTest.php
  73) tests/Unit/Aggregate/CustomIdTest.php
  74) tests/Unit/Console/InvalidArgumentGivenTest.php
  75) tests/Unit/Console/OutputStyleTest.php
  76) tests/Unit/Console/InputHelperTest.php
  77) tests/Unit/Console/DoctrineHelperTest.php
  78) tests/Unit/Console/Command/DatabaseCreateCommandTest.php
  79) tests/Unit/Console/Command/SchemaUpdateCommandTest.php
  80) tests/Unit/Console/Command/SchemaDropCommandTest.php
  81) tests/Unit/Console/Command/ShowAggregateCommandTest.php
  82) tests/Unit/Console/Command/DatabaseDropCommandTest.php
  83) tests/Unit/Console/Command/SchemaCreateCommandTest.php
  84) tests/Unit/Serializer/DefaultEventSerializerTest.php
  85) tests/Unit/Serializer/Upcast/UpcastTest.php
  86) tests/Unit/Serializer/Upcast/UpcasterChainTest.php
  87) tests/Unit/Serializer/Encoder/EncodeNotPossibleTest.php
  88) tests/Unit/Serializer/Encoder/DecodeNotPossibleTest.php
  89) tests/Unit/Serializer/Encoder/JsonEncoderTest.php
  90) tests/Unit/Serializer/SerializedEventTest.php
  91) tests/Unit/Schema/DoctrineSchemaListenerTest.php
  92) tests/Unit/Schema/DoctrineSchemaDirectorTest.php
  93) tests/Unit/Schema/DoctrineSchemaSubscriberTest.php
  94) tests/Unit/Schema/ChainDoctrineSchemaConfiguratorTest.php
  95) tests/Unit/Schema/DoctrineMigrationSchemaProviderTest.php
  96) tests/Unit/EventBus/ListenerDescriptorTest.php
  97) tests/Unit/EventBus/DefaultEventBusTest.php
  98) tests/Unit/EventBus/Psr14EventBusTest.php
  99) tests/Unit/EventBus/AttributeListenerProviderTest.php
 100) tests/Unit/EventBus/DefaultConsumerTest.php
 101) tests/Unit/Subscription/SubscriptionTest.php
 102) tests/Unit/Subscription/RetryStrategy/NoRetryStrategyTest.php
 103) tests/Unit/Subscription/RetryStrategy/ClockBasedRetryStrategyTest.php
 104) tests/Unit/Subscription/Engine/CatchUpSubscriptionEngineTest.php
 105) tests/Unit/Subscription/Engine/SubscriptionManagerTest.php
 106) tests/Unit/Subscription/Engine/ErrorDetectedTest.php
 107) tests/Unit/Subscription/Engine/DefaultSubscriptionEngineTest.php
 108) tests/Unit/Subscription/Engine/ThrowOnErrorSubscriptionEngineTest.php
 109) tests/Unit/Subscription/Repository/RunSubscriptionEngineRepositoryManagerTest.php
 110) tests/Unit/Subscription/Repository/RunSubscriptionEngineRepositoryTest.php
 111) tests/Unit/Subscription/SubscriptionErrorTest.php
 112) tests/Unit/Subscription/Store/SubscriptionCriteriaTest.php
 113) tests/Unit/Subscription/Store/SubscriptionAlreadyExistsTest.php
 114) tests/Unit/Subscription/Store/SubscriptionNotFoundTest.php
 115) tests/Unit/Subscription/Store/ErrorContextTest.php
 116) tests/Unit/Subscription/Store/InMemorySubscriptionStoreTest.php
 117) tests/Unit/Subscription/Lookup/LookupTest.php
 118) tests/Unit/Subscription/Subscriber/MetadataSubscriberAccessorRepositoryTest.php
 119) tests/Unit/Subscription/Subscriber/SubscriberHelperTest.php
 120) tests/Unit/Subscription/Subscriber/MetadataSubscriberAccessorTest.php
 121) tests/Unit/Subscription/Subscriber/ArgumentResolver/MessageArgumentResolverTest.php
 122) tests/Unit/Subscription/Subscriber/ArgumentResolver/LookupResolverTest.php
 123) tests/Unit/Subscription/Subscriber/ArgumentResolver/RecordedOnArgumentResolverTest.php
 124) tests/Unit/Subscription/Subscriber/ArgumentResolver/AggregateIdArgumentResolverTest.php
 125) tests/Unit/Subscription/Subscriber/ArgumentResolver/EventArgumentResolverTest.php
 126) tests/Unit/Metadata/ClassFinderTest.php
 127) tests/Unit/Metadata/Aggregate/AggregateRootRegistryTest.php
 128) tests/Unit/Metadata/Aggregate/AttributeAggregateRootRegistryFactoryTest.php
 129) tests/Unit/Metadata/Aggregate/AttributeAggregateMetadataFactoryTest.php
 130) tests/Unit/Metadata/Event/AttributeEventMetadataFactoryTest.php
 131) tests/Unit/Metadata/Event/AttributeEventRegistryFactoryTest.php
 132) tests/Unit/Metadata/Event/EventRegistryTest.php
 133) tests/Unit/Metadata/Subscriber/AttributeSubscriberMetadataFactoryTest.php
 134) tests/Integration/Store/DoctrineDbalStoreTest.php
 135) tests/Integration/Store/StreamDoctrineDbalStoreTest.php
 136) tests/Integration/PersonalData/PersonalDataTest.php
 137) tests/Integration/ChildAggregate/ChildAggregateIntegrationTest.php
 138) tests/Integration/MicroAggregate/MicroAggregateIntegrationTest.php
 139) tests/Integration/Subscription/SubscriptionTest.php
 140) tests/Integration/BasicImplementation/BasicIntegrationTest.php
 141) tests/Integration/BankAccountSplitStream/IntegrationTest.php

Found 141 of 276 files that can be fixed in 3.492 seconds, 31.12 MB memo1ry used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions