Skip to content

Commit

Permalink
test: use storage stubs instead of mocks
Browse files Browse the repository at this point in the history
In cases when stub is enough
  • Loading branch information
zlodes committed Apr 21, 2024
1 parent e413527 commit c3a67a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion tests/Collector/ByType/CounterCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Zlodes\PrometheusClient\Metric\Counter;
use Zlodes\PrometheusClient\Storage\Commands\IncrementCounter;
use Zlodes\PrometheusClient\Storage\Contracts\CounterStorage;
use Zlodes\PrometheusClient\Tests\Stubs\CounterStorageStub;

class CounterCollectorTest extends TestCase
{
Expand Down Expand Up @@ -79,7 +80,7 @@ public function testIncrementWithBadValues(int $value): void
{
$collector = new CounterCollector(
new Counter('mileage', 'Mileage in kilometres'),
Mockery::mock(CounterStorage::class),
new CounterStorageStub(),
new NullLogger()
);

Expand Down
17 changes: 8 additions & 9 deletions tests/Collector/CollectorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Zlodes\PrometheusClient\Tests\Collector;

use a;
use Mockery;
use PHPUnit\Framework\TestCase;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
Expand All @@ -16,10 +15,10 @@
use Zlodes\PrometheusClient\Metric\Histogram;
use Zlodes\PrometheusClient\Metric\Summary;
use Zlodes\PrometheusClient\Registry\Registry;
use Zlodes\PrometheusClient\Storage\Contracts\CounterStorage;
use Zlodes\PrometheusClient\Storage\Contracts\GaugeStorage;
use Zlodes\PrometheusClient\Storage\Contracts\HistogramStorage;
use Zlodes\PrometheusClient\Storage\Contracts\SummaryStorage;
use Zlodes\PrometheusClient\Tests\Stubs\CounterStorageStub;
use Zlodes\PrometheusClient\Tests\Stubs\GaugeStorageStub;
use Zlodes\PrometheusClient\Tests\Stubs\HistogramStorageStub;
use Zlodes\PrometheusClient\Tests\Stubs\SummaryStorageStub;

class CollectorFactoryTest extends TestCase
{
Expand Down Expand Up @@ -149,10 +148,10 @@ private function createCollectorFactory(Registry $registry): CollectorFactory
{
return new CollectorFactory(
$registry,
Mockery::mock(CounterStorage::class),
Mockery::mock(GaugeStorage::class),
Mockery::mock(HistogramStorage::class),
Mockery::mock(SummaryStorage::class),
new CounterStorageStub(),
new GaugeStorageStub(),
new HistogramStorageStub(),
new SummaryStorageStub(),
new NullLogger(),
);
}
Expand Down

0 comments on commit c3a67a4

Please sign in to comment.