Page MenuHomePhorge

No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None
diff --git a/tests/phpunit/unit/includes/libs/Stats/MetricTest.php b/tests/phpunit/unit/includes/libs/Stats/MetricTest.php
index e5d5b017d90..3786eb5e71e 100644
--- a/tests/phpunit/unit/includes/libs/Stats/MetricTest.php
+++ b/tests/phpunit/unit/includes/libs/Stats/MetricTest.php
@@ -397,15 +397,23 @@ class MetricTest extends TestCase {
/**
* PHPUnit 10 compatible replacement for expectWarning().
*
+ * Default uses assertStringContainsString().
+ * When $strict = true, uses assertSame().
+ *
* @param string $msg
* @param callable $callback
+ * @param bool $strict
* @return void
*/
- private function expectPHPWarning( string $msg, callable $callback ): void {
+ private function expectPHPWarning( string $msg, callable $callback, bool $strict = false ): void {
try {
$errorEmitted = false;
- set_error_handler( function ( $_, $actualMsg ) use ( $msg, &$errorEmitted ) {
- $this->assertStringContainsString( $msg, $actualMsg );
+ set_error_handler( function ( $_, $actualMsg ) use ( $msg, &$errorEmitted, $strict ) {
+ if ( $strict ) {
+ $this->assertSame( $msg, $actualMsg );
+ } else {
+ $this->assertStringContainsString( $msg, $actualMsg );
+ }
$errorEmitted = true;
}, E_USER_WARNING );
$callback();

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:32 AM (7 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227503
Default Alt Text
(1 KB)

Event Timeline