From 98a34a522452d32485dfda8eaf5fc9c02aa6f53b Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Thu, 13 Nov 2014 13:18:08 -0700 Subject: [PATCH] Work around test provider running before setUp() If the xhprof extension is not present we skip running the test, but phpunit runs the test provider function before that check so we need to guard against missing constants to avoid spurious warnings in the test output. Change-Id: I5541a062ff0c47ca8802315554b3f32dfd01dcd0 --- tests/phpunit/includes/libs/XhprofTest.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/includes/libs/XhprofTest.php b/tests/phpunit/includes/libs/XhprofTest.php index e0e68e0d32..cc81abac4f 100644 --- a/tests/phpunit/includes/libs/XhprofTest.php +++ b/tests/phpunit/includes/libs/XhprofTest.php @@ -69,14 +69,23 @@ class XhprofTest extends PHPUnit_Framework_TestCase { } public function provideRawData() { - return array( + $tests = array( array( 0, array( 'ct', 'wt' ) ), - array( XHPROF_FLAGS_MEMORY, array( 'ct', 'wt', 'mu', 'pmu' ) ), - array( XHPROF_FLAGS_CPU, array( 'ct', 'wt', 'cpu' ) ), - array( XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU, array( - 'ct', 'wt', 'mu', 'pmu', 'cpu', - ) ), ); + + if ( defined( 'XHPROF_FLAGS_CPU' ) && defined( 'XHPROF_FLAGS_CPU' ) ) { + $tests[] = array( XHPROF_FLAGS_MEMORY, array( + 'ct', 'wt', 'mu', 'pmu', + ) ); + $tests[] = array( XHPROF_FLAGS_CPU, array( + 'ct', 'wt', 'cpu', + ) ); + $tests[] = array( XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU, array( + 'ct', 'wt', 'mu', 'pmu', 'cpu', + ) ); + } + + return $tests; } /** -- 2.20.1