forked from theorchard/monolog-cascade
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to PHPUnit 8.5 (theorchard#103)
* Update PHPUnit to 8.5 This is required in order to run tests with Monolog 2. Otherwise this error occurs: PHPUnit 4.8.36 by Sebastian Bergmann and contributors. ..................PHP Fatal error: Declaration of Mock_TestHandler_bc3472b7::setFormatter(Monolog\Formatter\FormatterInterface $formatter) must be compatible with Monolog\Handler\AbstractProcessingHandler::setFormatter(Monolog\Formatter\FormatterInterface $formatter): Monolog\Handler\HandlerInterface in /home/danilo/monolog-cascade/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php(290) : eval()'d code on line 11 * Fix TestCase inheritance Fixes this type of error: `Fatal error: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in /home/danilo/monolog-cascade/tests/Config/Loader/FileLoader/FileLoaderAbstractTest.php:26` * Use TestCase::getMockBuilder instead of TestCase::getMock Fixes this type of error: `Error: Call to undefined method Cascade\Tests\Config\Loader\FileLoader\FileLoaderAbstractTest::getMock()` * Fix HandlerLoaderTest::testHandlerForProcessor ProcessableHandlerInterface::pushProcessor expects the $callback argument to be a callable. Fixes the following error: `Cascade\Tests\Config\Loader\ClassLoader\HandlerLoaderTest::testHandlerForProcessor TypeError: Argument 1 passed to Mock_TestHandler_aac1a74a::pushProcessor() must be callable, string given, called in /home/danilo/monolog-cascade/src/Config/Loader/ClassLoader/HandlerLoader.php on line 187` * Remove usages of @ExpectedException annotations Fixes this warning: `The @ExpectedException, @expectedExceptionCode, @expectedExceptionMessage, and @expectedExceptionMessageRegExp annotations are deprecated. They will be removed in PHPUnit 9. Refactor your test to use expectException(), expectExceptionCode(), expectExceptionMessage(), or expectExceptionMessageMatches() instead.` Co-authored-by: Danilo Azevedo <[email protected]>
- Loading branch information
Showing
17 changed files
with
106 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,16 @@ | |
use Monolog\Registry; | ||
|
||
use Cascade\Cascade; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class CascadeTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class CascadeTest extends \PHPUnit_Framework_TestCase | ||
class CascadeTest extends TestCase | ||
{ | ||
public function teardown() | ||
public function teardown(): void | ||
{ | ||
Registry::clear(); | ||
parent::teardown(); | ||
|
@@ -47,11 +48,10 @@ public function testRegistry() | |
$this->assertSame($logger, $logger2); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testRegistryWithInvalidName() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
Cascade::getLogger(null); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,27 +12,28 @@ | |
|
||
use Cascade\Config\ConfigLoader; | ||
use Cascade\Tests\Fixtures; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class ConfigLoaderTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class ConfigLoaderTest extends \PHPUnit_Framework_TestCase | ||
class ConfigLoaderTest extends TestCase | ||
{ | ||
/** | ||
* Loader to test against | ||
* @var ConfigLoader | ||
*/ | ||
protected $loader = null; | ||
|
||
public function setUp() | ||
public function setUp(): void | ||
{ | ||
parent::setup(); | ||
$this->loader = new ConfigLoader(); | ||
} | ||
|
||
public function tearDown() | ||
public function tearDown(): void | ||
{ | ||
$this->loader = null; | ||
parent::tearDown(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,19 @@ | |
namespace Cascade\Tests\Config\Loader\ClassLoader; | ||
|
||
use Cascade\Config\Loader\ClassLoader\FormatterLoader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class FormatterLoaderTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class FormatterLoaderTest extends \PHPUnit_Framework_TestCase | ||
class FormatterLoaderTest extends TestCase | ||
{ | ||
/** | ||
* Set up function | ||
*/ | ||
public function setUp() | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
new FormatterLoader(array()); | ||
|
@@ -31,7 +32,7 @@ public function setUp() | |
/** | ||
* Tear down function | ||
*/ | ||
public function tearDown() | ||
public function tearDown(): void | ||
{ | ||
FormatterLoader::$extraOptionHandlers = array(); | ||
parent::tearDown(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,14 @@ | |
use Monolog\Formatter\LineFormatter; | ||
|
||
use Cascade\Config\Loader\ClassLoader\HandlerLoader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class HandlerLoaderTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class HandlerLoaderTest extends \PHPUnit_Framework_TestCase | ||
class HandlerLoaderTest extends TestCase | ||
{ | ||
public function testHandlerLoader() | ||
{ | ||
|
@@ -53,11 +54,10 @@ public function testHandlerLoaderWithNoOptions() | |
$this->assertEquals($original, $options); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testHandlerLoaderWithInvalidFormatter() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
$options = array( | ||
'formatter' => 'test_formatter' | ||
); | ||
|
@@ -66,11 +66,10 @@ public function testHandlerLoaderWithInvalidFormatter() | |
$loader = new HandlerLoader($options, $formatters); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testHandlerLoaderWithInvalidProcessor() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
$dummyClosure = function () { | ||
// Empty function | ||
}; | ||
|
@@ -83,11 +82,10 @@ public function testHandlerLoaderWithInvalidProcessor() | |
$loader = new HandlerLoader($options, $formatters, $processors); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testHandlerLoaderWithInvalidHandler() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
$dummyClosure = function () { | ||
// Empty function | ||
}; | ||
|
@@ -101,11 +99,10 @@ public function testHandlerLoaderWithInvalidHandler() | |
$loader = new HandlerLoader($options, $formatters, $processors, $handlers); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testHandlerLoaderWithInvalidHandlers() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
$dummyClosure = function () { | ||
// Empty function | ||
}; | ||
|
@@ -244,8 +241,14 @@ public function testHandlerForProcessor() | |
{ | ||
$options = array(); | ||
|
||
$mockProcessor1 = '123'; | ||
$mockProcessor2 = '456'; | ||
$mockProcessor1 = function($record) { | ||
$record['extra']['dummy'] = 'Hello world 1!'; | ||
return $record; | ||
}; | ||
$mockProcessor2 = function($record) { | ||
$record['extra']['dummy'] = 'Hello world 1!'; | ||
return $record; | ||
}; | ||
$processorsArray = array($mockProcessor1, $mockProcessor2); | ||
|
||
// Setup mock and expectations | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,18 +15,19 @@ | |
use Monolog\Registry; | ||
|
||
use Cascade\Config\Loader\ClassLoader\LoggerLoader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class LoggerLoaderTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class LoggerLoaderTest extends \PHPUnit_Framework_TestCase | ||
class LoggerLoaderTest extends TestCase | ||
{ | ||
/** | ||
* Tear down function | ||
*/ | ||
public function tearDown() | ||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
Registry::clear(); | ||
|
@@ -56,11 +57,10 @@ public function testResolveHandlers() | |
); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testResolveHandlersWithMismatch() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
$options = array( | ||
'handlers' => array('unexisting_handler', 'test_handler_2') | ||
); | ||
|
@@ -95,11 +95,10 @@ public function testResolveProcessors() | |
); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testResolveProcessorsWithMismatch() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
|
||
$dummyClosure = function () { | ||
// Empty function | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,14 @@ | |
use Monolog\Processor\WebProcessor; | ||
|
||
use Cascade\Config\Loader\ClassLoader\ProcessorLoader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class ProcessorLoaderTest | ||
* | ||
* @author Kate Burdon <[email protected]> | ||
*/ | ||
class ProcessorLoaderTest extends \PHPUnit_Framework_TestCase | ||
class ProcessorLoaderTest extends TestCase | ||
{ | ||
public function testProcessorLoader() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,17 @@ | |
use Cascade\Util; | ||
use Cascade\Config\Loader\ClassLoader\Resolver\ConstructorResolver; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony; | ||
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; | ||
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; | ||
|
||
/** | ||
* Class ConstructorResolverTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class ConstructorResolverTest extends \PHPUnit_Framework_TestCase | ||
class ConstructorResolverTest extends TestCase | ||
{ | ||
/** | ||
* Reflection class for which you want to resolve extra options | ||
|
@@ -37,7 +40,7 @@ class ConstructorResolverTest extends \PHPUnit_Framework_TestCase | |
/** | ||
* Set up function | ||
*/ | ||
public function setUp() | ||
public function setUp(): void | ||
{ | ||
$this->class = 'Cascade\Tests\Fixtures\SampleClass'; | ||
$this->resolver = new ConstructorResolver(new \ReflectionClass($this->class)); | ||
|
@@ -47,7 +50,7 @@ public function setUp() | |
/** | ||
* Tear down function | ||
*/ | ||
public function tearDown() | ||
public function tearDown(): void | ||
{ | ||
$this->resolver = null; | ||
$this->class = null; | ||
|
@@ -183,10 +186,11 @@ public function missingOptionsProvider() | |
* | ||
* @param array $incompleteOptions Array of invalid options | ||
* @dataProvider missingOptionsProvider | ||
* @expectedException Symfony\Component\OptionsResolver\Exception\MissingOptionsException | ||
*/ | ||
public function testResolveWithMissingOptions(array $incompleteOptions) | ||
{ | ||
$this->expectException(MissingOptionsException::class); | ||
|
||
$this->resolver->resolve($incompleteOptions); | ||
} | ||
|
||
|
@@ -222,10 +226,11 @@ public function invalidOptionsProvider() | |
* | ||
* @param array $invalidOptions Array of invalid options | ||
* @dataProvider invalidOptionsProvider | ||
* @expectedException Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException | ||
*/ | ||
public function testResolveWithInvalidOptions($invalidOptions) | ||
{ | ||
$this->expectException(UndefinedOptionsException::class); | ||
|
||
$this->resolver->resolve($invalidOptions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,16 @@ | |
|
||
use Cascade\Config\Loader\ClassLoader\Resolver\ExtraOptionsResolver; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony; | ||
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; | ||
|
||
/** | ||
* Class ExtraOptionsResolverTest | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
class ExtraOptionsResolverTest extends \PHPUnit_Framework_TestCase | ||
class ExtraOptionsResolverTest extends TestCase | ||
{ | ||
/** | ||
* Reflection class for which you want to resolve extra options | ||
|
@@ -36,7 +38,7 @@ class ExtraOptionsResolverTest extends \PHPUnit_Framework_TestCase | |
/** | ||
* Set up function | ||
*/ | ||
public function setUp() | ||
public function setUp(): void | ||
{ | ||
$this->class = 'Cascade\Tests\Fixtures\SampleClass'; | ||
$this->params = array('optionalA', 'optionalB'); | ||
|
@@ -50,7 +52,7 @@ public function setUp() | |
/** | ||
* Tear down function | ||
*/ | ||
public function tearDown() | ||
public function tearDown(): void | ||
{ | ||
$this->resolver = null; | ||
$this->class = null; | ||
|
@@ -168,10 +170,11 @@ public function invalidOptionsProvider() | |
* | ||
* @param array $invalidOptions Array of invalid options | ||
* @dataProvider invalidOptionsProvider | ||
* @expectedException Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException | ||
*/ | ||
public function testResolveWithInvalidOptions($invalidOptions) | ||
{ | ||
$this->expectException(UndefinedOptionsException::class); | ||
|
||
$this->resolver->resolve($invalidOptions); | ||
} | ||
} |
Oops, something went wrong.