From 21ce4e90d3b86594bfa542cd3d78b9ee78c92296 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 23 Apr 2017 21:28:44 +0000 Subject: [PATCH] Build/Test Tools: Only perform an assertion for deprecated calls and wrongdoings if any are expected. This avoids masking risky tests that don't otherwise perform an assertion. See #40538 git-svn-id: https://develop.svn.wordpress.org/trunk@40541 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 554de7e578..45fcdebcd7 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -388,7 +388,10 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { $errors[] = "Unexpected incorrect usage notice for $unexpected"; } - $this->assertEmpty( $errors, implode( "\n", $errors ) ); + // Perform an assertion, but only if there are expected deprecated calls or expected wrongdoings + if ( ! empty( $this->expected_deprecated ) || ! empty( $this->expected_doing_it_wrong ) ) { + $this->assertEmpty( $errors, implode( "\n", $errors ) ); + } } /**