add unit tests

This commit is contained in:
Matthew Goslett 2017-07-27 14:11:46 +02:00
parent 00cb369d0b
commit 9c2453f0e4
8 changed files with 508 additions and 22 deletions

View file

@ -0,0 +1,43 @@
<?php
namespace Tests;
use Mockery;
use PHPUnit\Framework\TestCase;
use Prometheus\Storage\APC;
use Prometheus\Storage\InMemory;
use Prometheus\Storage\Redis;
use Superbalist\LaravelPrometheusExporter\StorageAdapterFactory;
class StorageAdapterFactoryTest extends TestCase
{
public function testMakeMemoryAdapter()
{
$factory = new StorageAdapterFactory();
$adapter = $factory->make('memory');
$this->assertInstanceOf(InMemory::class, $adapter);
}
public function testMakeApcAdapter()
{
$factory = new StorageAdapterFactory();
$adapter = $factory->make('apc');
$this->assertInstanceOf(APC::class, $adapter);
}
public function testMakeRedisAdapter()
{
$factory = new StorageAdapterFactory();
$adapter = $factory->make('redis');
$this->assertInstanceOf(Redis::class, $adapter);
}
public function testMakeInvalidAdapter()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The driver [moo] is not supported.');
$factory = new StorageAdapterFactory();
$factory->make('moo');
}
}