Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): Fix storage testing section #12

Merged
merged 1 commit into from
Oct 29, 2023
Merged
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
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,32 @@ Example can be found in [InMemoryStorage](PrometheusClient/Storage/InMemoryStora

#### Storage Testing

There is a simple [trait](PrometheusClient/Storage/StorageTesting.php) to tests any storage you want. Here is an example:
There are four useful traits to simplify your storage testing:

1. [CounterStorageTesting](./src/Storage/Testing/CounterStorageTesting.php)
2. [GaugeStorageTesting](./src/Storage/Testing/GaugeStorageTesting.php)
3. [HistogramStorageTesting](./src/Storage/Testing/HistogramStorageTesting.php)
4. [SummaryStorageTesting](./src/Storage/Testing/SummaryStorageTesting.php)

They provide you a set of tests to check your storage implementation to be compatible with the library.

Example:

```php
class InMemoryStorageTest extends TestCase
<?php

use PHPUnit\Framework\TestCase;
use Zlodes\PrometheusClient\Storage\Contracts\CounterStorage;
use Zlodes\PrometheusClient\Storage\InMemory\InMemoryCounterStorage;
use Zlodes\PrometheusClient\Storage\Testing\CounterStorageTesting;

class InMemoryCounterStorageTest extends TestCase
{
use StorageTesting;
use CounterStorageTesting;

private function createStorage(): Storage
private function createStorage(): CounterStorage
{
return new InMemoryStorage();
return new InMemoryCounterStorage();
}
}
```
Loading