Skip to content

Commit

Permalink
StatsDAdapterServiceProviderTest (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech authored Jul 7, 2024
1 parent 8bcbc4e commit bee4e17
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/StatsDAdapterServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Cosmastech\LaravelStatsDAdapter\Tests;

use Cosmastech\StatsDClientAdapter\Adapters\Datadog\DatadogStatsDClientAdapter;
use Cosmastech\StatsDClientAdapter\Adapters\InMemory\InMemoryClientAdapter;
use Cosmastech\StatsDClientAdapter\Adapters\StatsDClientAdapter;
use Cosmastech\StatsDClientAdapter\Clients\Datadog\DatadogLoggingClient;
use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;

class StatsDAdapterServiceProviderTest extends AbstractTestCase
{
#[Test]
public function makeStatsDClientAdapter_returnsDefaultInstance(): void
{
// Given application is booted

// And
Config::set("statsd-adapter.default", "log_datadog");

// When
$clientAdapter = $this->app->make(StatsDClientAdapter::class);

// Then
self::assertInstanceOf(DatadogStatsDClientAdapter::class, $clientAdapter);
self::assertInstanceOf(DatadogLoggingClient::class, $clientAdapter->getClient());
}

#[Test]
public function makeStatsDClientAdapter_returnsSingleton(): void
{
// Given application is booted

// When
$clientAdapter = $this->app->make(StatsDClientAdapter::class);

// Then
self::assertInstanceOf(InMemoryClientAdapter::class, $clientAdapter);

// And
self::assertSame($clientAdapter, $this->app->make(StatsDClientAdapter::class));
}
}

0 comments on commit bee4e17

Please sign in to comment.