From: Bryan Davis Date: Thu, 13 Nov 2014 20:18:08 +0000 (-0700) Subject: Work around test provider running before setUp() X-Git-Tag: 1.31.0-rc.0~13310 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27user_edit%27%2C%20userid=session.user.id%29%20%7D%7D?a=commitdiff_plain;h=98a34a522452d32485dfda8eaf5fc9c02aa6f53b;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; } /**