Skip to content

Commit

Permalink
[#8] Bump deps to pheature-flags 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kpicaza committed Nov 21, 2021
1 parent a197249 commit 4128512
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -17,8 +17,8 @@
],
"require": {
"php": "^7.4|>=8.0",
"pheature/toggle-core": "^0.2",
"pheature/toggle-crud": "^0.2",
"pheature/toggle-core": "^0.3",
"pheature/toggle-crud": "^0.3",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
Expand All @@ -27,7 +27,7 @@
"require-dev": {
"icanhazstring/composer-unused": "^0.7.5",
"infection/infection": "^0.25",
"pheature/inmemory-toggle": "^0.2.0",
"pheature/inmemory-toggle": "^0.3",
"phpcompatibility/php-compatibility": "^9.3",
"phpro/grumphp": "^1.0",
"phpstan/extension-installer": "^1.1",
Expand Down
6 changes: 5 additions & 1 deletion src/PatchRequest.php
Expand Up @@ -11,6 +11,9 @@
use Psr\Http\Message\ServerRequestInterface;
use Webmozart\Assert\Assert;

/**
* @psalm-import-type WriteSegment from \Pheature\Core\Toggle\Write\Segment
*/
final class PatchRequest
{
private const ACTION_ENABLE_FEATURE = 'enable_feature';
Expand Down Expand Up @@ -45,7 +48,7 @@ public function setStrategyCommand(): SetStrategy
Assert::keyExists($this->requestData, 'strategy_type');
Assert::string($this->requestData['strategy_id']);
Assert::string($this->requestData['strategy_type']);
/** @var array<array<string, mixed>>|null $segments */
/** @var array<array<string, array<string, mixed>|string>>|null $segments */
$segments = $this->requestData['segments'] ?? [];
Assert::isArray($segments);
foreach ($segments as $segment) {
Expand All @@ -55,6 +58,7 @@ public function setStrategyCommand(): SetStrategy
Assert::string($segment['segment_id']);
Assert::string($segment['segment_type']);
Assert::isArray($segment['criteria']);
/** @var WriteSegment $segment */
}

return SetStrategy::withIdTypeAndSegments(
Expand Down
8 changes: 7 additions & 1 deletion test/DeleteFeatureTest.php
Expand Up @@ -4,6 +4,7 @@

namespace Pheature\Test\Crud\Psr7\Toggle;

use Pheature\Core\Toggle\Write\Event\FeatureWasRemoved;
use Pheature\Core\Toggle\Write\Feature;
use Pheature\Core\Toggle\Write\FeatureId;
use Pheature\Core\Toggle\Write\FeatureRepository;
Expand Down Expand Up @@ -46,6 +47,7 @@ public function testItShouldHandleRequestAndReturnNoContentResponse(): void

$featureRepository = new InMemoryFeatureRepository();
$featureRepository->save(new Feature(FeatureId::fromString('some_id'), false, []));
$feature = $featureRepository->get(FeatureId::fromString('some_id'));

$response = $this->createMock(ResponseInterface::class);
$responseFactory = $this->createMock(ResponseFactoryInterface::class);
Expand All @@ -54,8 +56,12 @@ public function testItShouldHandleRequestAndReturnNoContentResponse(): void
->with(204)
->willReturn($response);


$handler = new DeleteFeature(new RemoveFeature($featureRepository), $responseFactory);
$handler->handle($request);

$events = $feature->release();
self::assertCount(1, $events);
$event = reset($events);
self::assertInstanceOf(FeatureWasRemoved::class, $event);
}
}

0 comments on commit 4128512

Please sign in to comment.