mirror of
https://github.com/symfony/error-handler.git
synced 2026-03-24 00:02:09 +01:00
run tests using PHPUnit 11.5
This commit is contained in:
committed by
Christian Flothmann
parent
f9dd6ae18d
commit
0c9f6a7cd1
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\Tests;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
@@ -37,6 +39,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$r->setValue(null, 0);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testRegister()
|
||||
{
|
||||
$handler = ErrorHandler::register();
|
||||
@@ -67,6 +70,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testErrorGetLast()
|
||||
{
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
@@ -89,6 +93,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testNotice()
|
||||
{
|
||||
ErrorHandler::register();
|
||||
@@ -125,6 +130,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$that->assertSame('', $foo.$foo.$bar);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testFailureCall()
|
||||
{
|
||||
$this->expectException(\ErrorException::class);
|
||||
@@ -133,6 +139,7 @@ class ErrorHandlerTest extends TestCase
|
||||
ErrorHandler::call('fopen', 'unknown.txt', 'r');
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testCallRestoreErrorHandler()
|
||||
{
|
||||
$prev = set_error_handler('var_dump');
|
||||
@@ -149,6 +156,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$this->assertSame('var_dump', $prev);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testCallErrorExceptionInfo()
|
||||
{
|
||||
try {
|
||||
@@ -167,6 +175,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testSuccessCall()
|
||||
{
|
||||
touch($filename = tempnam(sys_get_temp_dir(), 'sf_error_handler_'));
|
||||
@@ -176,6 +185,7 @@ class ErrorHandlerTest extends TestCase
|
||||
unlink($filename);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testConstruct()
|
||||
{
|
||||
try {
|
||||
@@ -188,6 +198,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testDefaultLogger()
|
||||
{
|
||||
try {
|
||||
@@ -225,6 +236,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleError()
|
||||
{
|
||||
try {
|
||||
@@ -330,6 +342,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleErrorWithAnonymousClass()
|
||||
{
|
||||
$anonymousObject = new class extends \stdClass {
|
||||
@@ -348,6 +361,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$this->assertSame('User Warning: foo stdClass@anonymous bar', $e->getMessage());
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleDeprecation()
|
||||
{
|
||||
$logArgCheck = function ($level, $message, $context) {
|
||||
@@ -370,9 +384,8 @@ class ErrorHandlerTest extends TestCase
|
||||
@$handler->handleError(\E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider handleExceptionProvider
|
||||
*/
|
||||
#[DataProvider('handleExceptionProvider')]
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleException(string $expectedMessage, \Throwable $exception, ?string $enhancedMessage = null)
|
||||
{
|
||||
try {
|
||||
@@ -433,6 +446,7 @@ class ErrorHandlerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testBootstrappingLogger()
|
||||
{
|
||||
$bootLogger = new BufferingLogger();
|
||||
@@ -487,6 +501,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$handler->setLoggers([\E_DEPRECATED => [$mockLogger, LogLevel::WARNING]]);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testSettingLoggerWhenExceptionIsBuffered()
|
||||
{
|
||||
$bootLogger = new BufferingLogger();
|
||||
@@ -506,6 +521,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$handler->handleException($exception);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleFatalError()
|
||||
{
|
||||
try {
|
||||
@@ -541,6 +557,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleErrorException()
|
||||
{
|
||||
$exception = new \Error("Class 'IReallyReallyDoNotExistAnywhereInTheRepositoryISwear' not found");
|
||||
@@ -556,6 +573,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$this->assertStringStartsWith("Attempted to load class \"IReallyReallyDoNotExistAnywhereInTheRepositoryISwear\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage());
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testCustomExceptionHandler()
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
@@ -568,6 +586,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$handler->handleException(new \Exception());
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testRenderException()
|
||||
{
|
||||
$handler = new ErrorHandler();
|
||||
@@ -580,9 +599,8 @@ class ErrorHandlerTest extends TestCase
|
||||
self::assertStringContainsString('Class Foo not found', $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider errorHandlerWhenLoggingProvider
|
||||
*/
|
||||
#[DataProvider('errorHandlerWhenLoggingProvider')]
|
||||
#[WithoutErrorHandler]
|
||||
public function testErrorHandlerWhenLogging(bool $previousHandlerWasDefined, bool $loggerSetsAnotherHandler, bool $nextHandlerIsDefined)
|
||||
{
|
||||
try {
|
||||
@@ -634,6 +652,7 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testAssertQuietEval()
|
||||
{
|
||||
if ('-1' === \ini_get('zend.assertions')) {
|
||||
@@ -675,6 +694,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$this->assertSame('Warning: assert(): assert(false) failed', $logs[0][1]);
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleTriggerDeprecation()
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnDeprecation="true"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
@@ -18,7 +19,7 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<coverage>
|
||||
<source ignoreSuppressionOfDeprecations="true">
|
||||
<include>
|
||||
<directory>./</directory>
|
||||
</include>
|
||||
@@ -26,5 +27,9 @@
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</coverage>
|
||||
</source>
|
||||
|
||||
<extensions>
|
||||
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension" />
|
||||
</extensions>
|
||||
</phpunit>
|
||||
|
||||
Reference in New Issue
Block a user