Skip to content

refactor(test-utilities): generic-type AggregateRootTestCase - #260

Open
maartenpaauw wants to merge 1 commit into
EventSaucePHP:mainfrom
maartenpaauw:feat/aggregate-root-test-case-templating
Open

refactor(test-utilities): generic-type AggregateRootTestCase#260
maartenpaauw wants to merge 1 commit into
EventSaucePHP:mainfrom
maartenpaauw:feat/aggregate-root-test-case-templating

Conversation

@maartenpaauw

Copy link
Copy Markdown

PHPStan couldn't narrow aggregateRootId(), retrieveAggregateRoot(), and persistAggregateRoot() past the AggregateRootId/AggregateRoot interfaces, so subclasses relied on @method docblock overrides and manual @var casts to get concrete types back in their test bodies.

Bind AggregateRootIdType and AggregateRootType via @template on the base class so concrete test cases only need to declare @extends AggregateRootTestCase<Id, AggregateRoot> to propagate the narrowed types everywhere, and drop the now-redundant workarounds from the classes that extend it.

PHPStan couldn't narrow aggregateRootId(), retrieveAggregateRoot(),
and persistAggregateRoot() past the AggregateRootId/AggregateRoot
interfaces, so subclasses relied on @method docblock overrides and
manual @var casts to get concrete types back in their test bodies.

Bind AggregateRootIdType and AggregateRootType via @template on the
base class so concrete test cases only need to declare
@extends AggregateRootTestCase<Id, AggregateRoot> to propagate the
narrowed types everywhere, and drop the now-redundant workarounds
from the classes that extend it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant