diff --git a/composer.json b/composer.json
index de3afb1e55..3678c8eb62 100644
--- a/composer.json
+++ b/composer.json
@@ -92,7 +92,7 @@
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
- "phpunit/phpunit": "^8.5 || ^9.0",
+ "phpunit/phpunit": "^8.5 || ^9.0 || ^10.0",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
diff --git a/src/PhpSpreadsheet/Helper/Handler.php b/src/PhpSpreadsheet/Helper/Handler.php
new file mode 100644
index 0000000000..d05197cef0
--- /dev/null
+++ b/src/PhpSpreadsheet/Helper/Handler.php
@@ -0,0 +1,46 @@
+', $actualXml);
+ self::assertSame('', $actualXml);
}
}
}
@@ -153,7 +153,7 @@ public function testLineChartFillIgnoresColorArray(): void
if ($actualXml === false) {
self::fail('Failure saving the spPr element as xml string!');
} else {
- self::assertXmlStringEqualsXmlString('', $actualXml);
+ self::assertSame('', $actualXml);
}
}
}
diff --git a/tests/PhpSpreadsheetTests/Helper/HandlerTest.php b/tests/PhpSpreadsheetTests/Helper/HandlerTest.php
new file mode 100644
index 0000000000..b0c432d1b9
--- /dev/null
+++ b/tests/PhpSpreadsheetTests/Helper/HandlerTest.php
@@ -0,0 +1,83 @@
+getMessage());
+ }
+ }
+ }
+
+ public function testNotice(): void
+ {
+ try {
+ Handler::notice('invalidtz');
+ self::fail('Expected error/exception did not happen');
+ } catch (Throwable $e) {
+ self::assertStringContainsString('Timezone', $e->getMessage());
+ }
+ }
+
+ public function testWarning(): void
+ {
+ try {
+ Handler::warning();
+ self::fail('Expected error/exception did not happen');
+ } catch (Throwable $e) {
+ self::assertStringContainsString('ailed to open stream', $e->getMessage());
+ }
+ }
+
+ public function testUserDeprecated(): void
+ {
+ if (method_exists(\PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
+ self::assertTrue(true);
+ } else {
+ try {
+ Handler::userDeprecated();
+ self::fail('Expected error/exception did not happen');
+ } catch (Throwable $e) {
+ self::assertStringContainsString('hello', $e->getMessage());
+ }
+ }
+ }
+
+ public function testUserNotice(): void
+ {
+ try {
+ Handler::userNotice();
+ self::fail('Expected error/exception did not happen');
+ } catch (Throwable $e) {
+ self::assertStringContainsString('userNotice', $e->getMessage());
+ }
+ }
+
+ public function testUserWarning(): void
+ {
+ try {
+ Handler::userWarning();
+ self::fail('Expected error/exception did not happen');
+ } catch (Throwable $e) {
+ self::assertStringContainsString('userWarning', $e->getMessage());
+ }
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 9ebd3f2623..fef59a5a7e 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -4,3 +4,34 @@
// PHP 5.3 Compat
//date_default_timezone_set('Europe/London');
+
+function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
+{
+ $x = error_reporting() & $errno;
+ if (
+ in_array(
+ $errno,
+ [
+ E_DEPRECATED,
+ E_WARNING,
+ E_NOTICE,
+ E_USER_DEPRECATED,
+ E_USER_NOTICE,
+ E_USER_WARNING,
+ ],
+ true
+ )
+ ) {
+ if (0 === $x) {
+ return true; // message suppressed - stop error handling
+ }
+
+ throw new \Exception("$errstr $filename $lineno");
+ }
+
+ return false; // continue error handling
+}
+
+if (!method_exists(\PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
+ set_error_handler('phpunit10ErrorHandler');
+}