diff --git a/composer.json b/composer.json index 67f0bed..753a8d4 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "graylog2/gelf-php": "~1.1", - "phpunit/phpunit": "~5.4", + "phpunit/phpunit": "^6.0.12", "satooshi/php-coveralls": "dev-master" }, "autoload": { diff --git a/tests/Factory/FormatterPluginManagerFactoryTest.php b/tests/Factory/FormatterPluginManagerFactoryTest.php index f3d49d6..adaf4ca 100644 --- a/tests/Factory/FormatterPluginManagerFactoryTest.php +++ b/tests/Factory/FormatterPluginManagerFactoryTest.php @@ -4,10 +4,10 @@ use MonologModule\Factory\FormatterPluginManagerFactory; use MonologModule\Formatter\FormatterPluginManager; use Monolog\Formatter\FormatterInterface; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Zend\ServiceManager\ServiceLocatorInterface; -class FormatterPluginManagerFactoryTest extends PHPUnit_Framework_TestCase +class FormatterPluginManagerFactoryTest extends TestCase { public function testRetrieveFormatterInstance() { diff --git a/tests/Factory/HandlerPluginManagerFactoryTest.php b/tests/Factory/HandlerPluginManagerFactoryTest.php index 3c8fdb8..f297e3b 100644 --- a/tests/Factory/HandlerPluginManagerFactoryTest.php +++ b/tests/Factory/HandlerPluginManagerFactoryTest.php @@ -4,10 +4,10 @@ use MonologModule\Factory\HandlerPluginManagerFactory; use MonologModule\Handler\HandlerPluginManager; use Monolog\Handler\HandlerInterface; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Zend\ServiceManager\ServiceLocatorInterface; -class HandlerPluginManagerFactoryTest extends PHPUnit_Framework_TestCase +class HandlerPluginManagerFactoryTest extends TestCase { public function testRetrieveHandlerInstance() { diff --git a/tests/Factory/LoggerAbstractFactoryTest.php b/tests/Factory/LoggerAbstractFactoryTest.php index 5c01d08..e01d585 100644 --- a/tests/Factory/LoggerAbstractFactoryTest.php +++ b/tests/Factory/LoggerAbstractFactoryTest.php @@ -5,10 +5,10 @@ use Monolog\Logger; use MonologModule\Factory\LoggerAbstractFactory; use MonologModule\Factory\LoggerFactory; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Zend\ServiceManager\ServiceLocatorInterface; -class LoggerAbstractFactoryTest extends PHPUnit_Framework_TestCase +class LoggerAbstractFactoryTest extends TestCase { public function canCreateServiceWithNameProvider() { diff --git a/tests/Factory/LoggerFactoryTest.php b/tests/Factory/LoggerFactoryTest.php index 6dbc4d3..f7b9b9f 100644 --- a/tests/Factory/LoggerFactoryTest.php +++ b/tests/Factory/LoggerFactoryTest.php @@ -8,10 +8,10 @@ use MonologModule\Factory\LoggerFactory; use MonologModule\Formatter\FormatterPluginManager; use MonologModule\Handler\HandlerPluginManager; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Zend\ServiceManager\ServiceLocatorInterface; -class LoggerFactoryTest extends PHPUnit_Framework_TestCase +class LoggerFactoryTest extends TestCase { protected $factory; diff --git a/tests/Formatter/FormatterPluginManagerTest.php b/tests/Formatter/FormatterPluginManagerTest.php index a9e4449..a036c27 100644 --- a/tests/Formatter/FormatterPluginManagerTest.php +++ b/tests/Formatter/FormatterPluginManagerTest.php @@ -3,30 +3,36 @@ use Monolog\Formatter\FormatterInterface; use MonologModule\Formatter\FormatterPluginManager; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use stdClass; +use Zend\ServiceManager\Exception\InvalidServiceException; use Zend\ServiceManager\ServiceLocatorInterface; -class FormatterPluginManagerTest extends PHPUnit_Framework_TestCase +class FormatterPluginManagerTest extends TestCase { - public function testValidatePlugin() + public function testRetrievePlugin() { + $formatter = $this->createMock(FormatterInterface::class); + $serviceLocator = $this->createMock(ServiceLocatorInterface::class); - $handlerPluginManager = new FormatterPluginManager($serviceLocator); + $formatterPluginManager = new FormatterPluginManager($serviceLocator, [ + 'services' => [ + FormatterInterface::class => $formatter, + ], + ]); - $handler = $this->createMock(FormatterInterface::class); - $handlerPluginManager->validatePlugin($handler); + $formatterReturned = $formatterPluginManager->get(FormatterInterface::class); + $this->assertSame($formatter, $formatterReturned); } - /** - * @expectedException \Zend\ServiceManager\Exception\InvalidServiceException - */ public function testValidateInvalidPlugin() { $serviceLocator = $this->createMock(ServiceLocatorInterface::class); - $handlerPluginManager = new FormatterPluginManager($serviceLocator); + $formatterPluginManager = new FormatterPluginManager($serviceLocator); + + $this->expectException(InvalidServiceException::class); - $handler = new stdClass; - $handlerPluginManager->validatePlugin($handler); + $formatter = new stdClass; + $formatterPluginManager->validatePlugin($formatter); } } diff --git a/tests/Handler/Factory/GelfHandlerFactoryTest.php b/tests/Handler/Factory/GelfHandlerFactoryTest.php index 7b350f5..3e2c1b4 100644 --- a/tests/Handler/Factory/GelfHandlerFactoryTest.php +++ b/tests/Handler/Factory/GelfHandlerFactoryTest.php @@ -3,10 +3,10 @@ use MonologModule\Handler\Factory\GelfHandlerFactory; use Monolog\Handler\GelfHandler; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Zend\ServiceManager\ServiceLocatorInterface; -class GelfHandlerFactoryTest extends PHPUnit_Framework_TestCase +class GelfHandlerFactoryTest extends TestCase { public function testInstantiateGelfHandler() { diff --git a/tests/Handler/HandlerPluginManagerTest.php b/tests/Handler/HandlerPluginManagerTest.php index 142daed..9a49d37 100644 --- a/tests/Handler/HandlerPluginManagerTest.php +++ b/tests/Handler/HandlerPluginManagerTest.php @@ -3,29 +3,35 @@ use Monolog\Handler\HandlerInterface; use MonologModule\Handler\HandlerPluginManager; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use stdClass; +use Zend\ServiceManager\Exception\InvalidServiceException; use Zend\ServiceManager\ServiceLocatorInterface; -class HandlerPluginManagerTest extends PHPUnit_Framework_TestCase +class HandlerPluginManagerTest extends TestCase { - public function testValidatePlugin() + public function testRetrievePlugin() { + $handler = $this->createMock(HandlerInterface::class); + $serviceLocator = $this->createMock(ServiceLocatorInterface::class); - $handlerPluginManager = new HandlerPluginManager($serviceLocator); + $handlerPluginManager = new HandlerPluginManager($serviceLocator, [ + 'services' => [ + HandlerInterface::class => $handler, + ], + ]); - $handler = $this->createMock(HandlerInterface::class); - $handlerPluginManager->validatePlugin($handler); + $handlerReturned = $handlerPluginManager->get(HandlerInterface::class); + $this->assertSame($handler, $handlerReturned); } - /** - * @expectedException \Zend\ServiceManager\Exception\InvalidServiceException - */ public function testValidateInvalidPlugin() { $serviceLocator = $this->createMock(ServiceLocatorInterface::class); $handlerPluginManager = new HandlerPluginManager($serviceLocator); + $this->expectException(InvalidServiceException::class); + $handler = new stdClass; $handlerPluginManager->validatePlugin($handler); }