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

service provider tests #2

Merged
merged 1 commit into from
Jul 7, 2024
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
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));
}
}
Loading