Skip to content

Commit

Permalink
Upgrade PHPUnit to ^6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
neeckeloo committed Oct 23, 2017
1 parent 022b2e1 commit 59b8a79
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 32 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions tests/Factory/FormatterPluginManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Factory/HandlerPluginManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Factory/LoggerAbstractFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Factory/LoggerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
30 changes: 18 additions & 12 deletions tests/Formatter/FormatterPluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions tests/Handler/Factory/GelfHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
24 changes: 15 additions & 9 deletions tests/Handler/HandlerPluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 59b8a79

Please sign in to comment.