mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 23:17:47 +01:00
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Flasher\Prime\Tests\Manager;
|
|
|
|
use Flasher\Prime\Flasher;
|
|
use Flasher\Prime\Tests\TestCase;
|
|
|
|
final class ManagerTest extends TestCase
|
|
{
|
|
public function testDefaultDriver()
|
|
{
|
|
$config = $this->getMockBuilder('Flasher\Prime\Config\ConfigInterface')->getMock();
|
|
$config->method('get')
|
|
->with('default')
|
|
->willReturn('default_notifier');
|
|
|
|
$manager = new Flasher($config);
|
|
$this->assertEquals('default_notifier', $manager->getDefaultDriver());
|
|
}
|
|
|
|
public function testMakeDriver()
|
|
{
|
|
$config = $this->getMockBuilder('Flasher\Prime\Config\ConfigInterface')->getMock();
|
|
$config->method('get')
|
|
->with('default')
|
|
->willReturn('default_notifier');
|
|
|
|
$manager = new Flasher($config);
|
|
|
|
$producer = $this->getMockBuilder('Flasher\Prime\Factory\FlasherFactoryInterface')->getMock();
|
|
$producer->method('supports')->willReturn(true);
|
|
$manager->addDriver($producer);
|
|
|
|
$this->assertSame($producer, $manager->make('fake'));
|
|
}
|
|
|
|
public function testDriverNotSupported()
|
|
{
|
|
$this->setExpectedException('InvalidArgumentException', 'Driver [test_driver] not supported.');
|
|
|
|
$config = $this->getMockBuilder('Flasher\Prime\Config\ConfigInterface')->getMock();
|
|
$config->method('get')
|
|
->with('default')
|
|
->willReturn('default_notifier');
|
|
|
|
$manager = new Flasher($config);
|
|
|
|
$producer = $this->getMockBuilder('Flasher\Prime\Factory\FlasherFactoryInterface')->getMock();
|
|
$manager->addDriver($producer);
|
|
|
|
$manager->make('test_driver');
|
|
}
|
|
}
|