8000 [RateLimiter] Fix delete method of the cache storage by GregOriol · Pull Request #38661 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/Symfony/Component/RateLimiter/Storage/CacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public function fetch(string $limiterStateId): ?LimiterStateInterface

public function delete(string $limiterStateId): void
{
$this->pool->deleteItem($limiterStateId);
$this->pool->deleteItem(sha1($limiterStateId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@ public function testFetchNonExistingState()

$this->assertNull($this->storage->fetch('test'));
}

public function testDelete()
{
$this->pool->expects($this->once())->method('deleteItem')->with(sha1('test'))->willReturn(true);
Copy link
Member
@Nyholm Nyholm Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line uses $this->pool which is a mock created in setUp().

We say that we "expect" that "once" the "method deleteItem" is called with sha1('test'). We also return true.

If what we expect does not happen, then the test will fail


$this->storage->delete('test');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just calling the storage

}
}
0