Skip to content

Commit

Permalink
update psalm to 5.16
Browse files Browse the repository at this point in the history
  • Loading branch information
kpicaza committed Dec 3, 2023
1 parent 93af355 commit c823f22
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"roave/infection-static-analysis-plugin": "^1.18",
"squizlabs/php_codesniffer": "^3.4",
"symfony/var-dumper": "^4.2 || ^5.0 || ^6.0",
"vimeo/psalm": "^4.4"
"vimeo/psalm": "^4.4|^5.16"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 8 additions & 2 deletions src/Read/ChainSegmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ public function create(string $segmentId, string $segmentType, array $criteria):

public function types(): array
{
return array_merge(
...array_map(static fn(SegmentFactory $segmentFactory) => $segmentFactory->types(), $this->segmentFactories)
/** @psalm-suppress NamedArgumentNotAllowed */
return array_unique(
array_merge(
...array_map(
static fn(SegmentFactory $segmentFactory) => $segmentFactory->types(),
$this->segmentFactories
)
)
);
}
}
1 change: 1 addition & 0 deletions src/Read/ChainToggleStrategyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function create(string $strategyId, string $strategyType, ?Segments $segm

public function types(): array
{
/** @psalm-suppress NamedArgumentNotAllowed */
return array_unique(
array_merge(
...array_map(
Expand Down
20 changes: 20 additions & 0 deletions test/Read/ChainSegmentFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,24 @@ public function testItShouldBeCreatedWithAtLeastOneSegmentFactoryInstance(): voi
$this->assertSame($expectedSegment, $current);
$this->assertSame([self::SEGMENT_TYPE], $chainSegmentFactory->types());
}

public function testItShouldCorrectlyMergeTheStrategyTypes(): void
{
$segmentFactory = $this->createMock(SegmentFactory::class);
$segmentFactory->expects(self::once())
->method('types')
->willReturn(['a', 'b']);
$otherSegmentFactory = $this->createMock(SegmentFactory::class);
$otherSegmentFactory->expects(self::once())
->method('types')
->willReturn(['c', 'b']);

$chainSegmentFactory = new ChainSegmentFactory(
$segmentFactory,
$otherSegmentFactory
);

$this->assertSame(['a', 'b', 'c'], $chainSegmentFactory->types());
}

}
21 changes: 21 additions & 0 deletions test/Read/ChainToggleStrategyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,25 @@ public function testItShouldBeCreatedWithAtLeastOneToggleStrategyFactoryInstance
$this->assertSame($expectedStrategy, $current);
$this->assertSame([self::STRATEGY_TYPE, 'other_type'], $chainToggleStrategyFactory->types());
}

public function testItShouldCorrectlyMergeTheStrategyTypes(): void
{
$segmentFactory = $this->createMock(SegmentFactory::class);
$toggleStrategyFactory = $this->createMock(ToggleStrategyFactory::class);
$toggleStrategyFactory->expects(self::once())
->method('types')
->willReturn(['a', 'b']);
$otherToggleStrategyFactory = $this->createMock(ToggleStrategyFactory::class);
$otherToggleStrategyFactory->expects(self::once())
->method('types')
->willReturn(['c', 'b']);

$chainToggleStrategyFactory = new ChainToggleStrategyFactory(
$segmentFactory,
$toggleStrategyFactory,
$otherToggleStrategyFactory
);

$this->assertSame(['a', 'b', 'c'], $chainToggleStrategyFactory->types());
}
}
6 changes: 3 additions & 3 deletions test/Write/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ public function testItShouldStoreAFeatureWasCreatedEventWhenNewFeatureIsCreated(

public function testItShouldStoreAFeatureWasRemovedWhenItIsRemoved(): void
{
$feature = $this->createFeature();
$feature = Feature::withId(FeatureId::fromString(self::FEATURE_ID));
$feature->remove();

$events = $feature->release();
$this->assertCount(1, $events);
$this->assertCount(2, $events);
$this->assertEventIsRecorded(FeatureWasRemoved::class, $events);

$featureWasRemovedEvent = $events[0];
$featureWasRemovedEvent = $events[1];
$this->assertSame(self::FEATURE_ID, $featureWasRemovedEvent->featureId()->value());
$this->assertInstanceOf(DatetimeImmutable::class, $featureWasRemovedEvent->occurredAt());
}
Expand Down

0 comments on commit c823f22

Please sign in to comment.