Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib/Client/DaprClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,31 +385,31 @@ abstract public function deleteState(
/**
* @param string $storeName
* @param string $key
* @param string $etag
* @param string|null $etag
* @param Consistency|null $consistency
* @param array<array-key, string> $metadata
* @return PromiseInterface<bool>
*/
abstract public function tryDeleteStateAsync(
string $storeName,
string $key,
string $etag,
string|null $etag,
Consistency|null $consistency = null,
array $metadata = []
): PromiseInterface;

/**
* @param string $storeName
* @param string $key
* @param string $etag
* @param string|null $etag
* @param Consistency|null $consistency
* @param array<array-key, string> $metadata
* @return bool
*/
abstract public function tryDeleteState(
string $storeName,
string $key,
string $etag,
string|null $etag,
Consistency|null $consistency = null,
array $metadata = []
): bool;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Client/HttpStateTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function deleteStateAsync(
public function tryDeleteStateAsync(
string $storeName,
string $key,
string $etag,
string|null $etag,
Consistency|null $consistency = null,
array $metadata = []
): PromiseInterface {
Expand Down Expand Up @@ -269,7 +269,7 @@ public function tryDeleteStateAsync(
public function tryDeleteState(
string $storeName,
string $key,
string $etag,
string|null $etag,
Consistency|null $consistency = null,
array $metadata = []
): bool {
Expand Down
37 changes: 37 additions & 0 deletions tests/DeleteStateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use GuzzleHttp\Psr7\Response;

require_once __DIR__ . '/DaprTests.php';

/**
* Class DeleteStateTest
*/
class DeleteStateTest extends DaprTests
{
public function testDeleteStateWithoutEtag(): void
{
$stack = $this->get_http_client_stack([new Response(204)]);
$client = $this->get_new_client_with_http($stack->client);

$client->deleteState(storeName: 'store', key: 'key');

$request = $this->get_last_request($stack);
$this->assertRequestMethod('DELETE', $request);
$this->assertRequestUri('/v1.0/state/store/key', $request);
$this->assertFalse($request->hasHeader('If-Match'));
}

public function testTryDeleteStateWithEtag(): void
{
$stack = $this->get_http_client_stack([new Response(204)]);
$client = $this->get_new_client_with_http($stack->client);

$client->tryDeleteState(storeName: 'store', key: 'key', etag: 'abc123');

$request = $this->get_last_request($stack);
$this->assertRequestMethod('DELETE', $request);
$this->assertRequestUri('/v1.0/state/store/key', $request);
$this->assertRequestHasHeaders(['If-Match' => 'abc123'], $request);
}
}