From 08defcade232fb9b0d28f1f1e0a98087307ba258 Mon Sep 17 00:00:00 2001 From: BrocksiNet Date: Fri, 25 Sep 2026 13:22:45 +0200 Subject: [PATCH] fix(test): keep resolver cache assertions PHPStan 2.2 safe PHPStan 2.2 reports a second assertSame() on the same resolve() call expression as always true, because the first assertion narrowed that expression. Store both results before asserting; the single repository read is still proven by expectedReads. --- .../SalesChannel/SalesChannelTypeResolverTest.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/Unit/System/SalesChannel/SalesChannelTypeResolverTest.php b/tests/Unit/System/SalesChannel/SalesChannelTypeResolverTest.php index d62085b8..14dc4b9a 100644 --- a/tests/Unit/System/SalesChannel/SalesChannelTypeResolverTest.php +++ b/tests/Unit/System/SalesChannel/SalesChannelTypeResolverTest.php @@ -70,8 +70,11 @@ public function testItReadsEachSalesChannelOnlyOnce(): void expectedReads: 1, )); - static::assertSame(SalesChannelTypeClassification::Storefront, $resolver->resolve('storefront-channel')); - static::assertSame(SalesChannelTypeClassification::Storefront, $resolver->resolve('storefront-channel')); + $first = $resolver->resolve('storefront-channel'); + $second = $resolver->resolve('storefront-channel'); + + static::assertSame(SalesChannelTypeClassification::Storefront, $first); + static::assertSame(SalesChannelTypeClassification::Storefront, $second); static::assertSame( ['storefront-channel' => SalesChannelTypeClassification::Storefront], $resolver->resolveMany(['storefront-channel', 'storefront-channel']), @@ -82,8 +85,11 @@ public function testItRemembersThatASalesChannelIsUnknown(): void { $resolver = new SalesChannelTypeResolver($this->repository([], expectedReads: 1)); - static::assertSame(SalesChannelTypeClassification::Other, $resolver->resolve('feed-channel')); - static::assertSame(SalesChannelTypeClassification::Other, $resolver->resolve('feed-channel')); + $first = $resolver->resolve('feed-channel'); + $second = $resolver->resolve('feed-channel'); + + static::assertSame(SalesChannelTypeClassification::Other, $first); + static::assertSame(SalesChannelTypeClassification::Other, $second); } public function testItReadsOnlyTheIdsItHasNotSeenYet(): void