MediaWiki REL1_33
XhprofTest.php
Go to the documentation of this file.
1<?php
21class XhprofTest extends PHPUnit\Framework\TestCase {
22
23 use MediaWikiCoversValidator;
24
33 public function testEnable() {
34 $xhprof = new ReflectionClass( Xhprof::class );
35 $enabled = $xhprof->getProperty( 'enabled' );
36 $enabled->setAccessible( true );
37 $enabled->setValue( true );
38 $xhprof->getMethod( 'enable' )->invoke( null );
39 }
40
47 public function testCallAny( array $functions, array $args, $expectedResult ) {
48 $xhprof = new ReflectionClass( Xhprof::class );
49 $callAny = $xhprof->getMethod( 'callAny' );
50 $callAny->setAccessible( true );
51
52 $this->assertEquals( $expectedResult,
53 $callAny->invoke( null, $functions, $args ) );
54 }
55
59 public function provideCallAny() {
60 return [
61 [
62 [ 'wfTestCallAny_func1', 'wfTestCallAny_func2', 'wfTestCallAny_func3' ],
63 [ 3, 4 ],
64 12
65 ],
66 [
67 [ 'wfTestCallAny_nosuchfunc1', 'wfTestCallAny_func2', 'wfTestCallAny_func3' ],
68 [ 3, 4 ],
69 7
70 ],
71 [
72 [ 'wfTestCallAny_nosuchfunc1', 'wfTestCallAny_nosuchfunc2', 'wfTestCallAny_func3' ],
73 [ 3, 4 ],
74 -1
75 ]
76
77 ];
78 }
79
87 public function testCallAnyNoneAvailable() {
88 $xhprof = new ReflectionClass( Xhprof::class );
89 $callAny = $xhprof->getMethod( 'callAny' );
90 $callAny->setAccessible( true );
91
92 $callAny->invoke( $xhprof, [
93 'wfTestCallAny_nosuchfunc1',
94 'wfTestCallAny_nosuchfunc2',
95 'wfTestCallAny_nosuchfunc3'
96 ] );
97 }
98}
99
101function wfTestCallAny_func1( $a, $b ) {
102 return $a * $b;
103}
104
106function wfTestCallAny_func2( $a, $b ) {
107 return $a + $b;
108}
109
111function wfTestCallAny_func3( $a, $b ) {
112 return $a - $b;
113}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfTestCallAny_func3( $a, $b)
Test function #3 for XhprofTest::testCallAny.
wfTestCallAny_func1( $a, $b)
Test function #1 for XhprofTest::testCallAny.
wfTestCallAny_func2( $a, $b)
Test function #2 for XhprofTest::testCallAny.
if( $line===false) $args
Definition cdb.php:64
testEnable()
Trying to enable Xhprof when it is already enabled causes an exception to be thrown.
testCallAny(array $functions, array $args, $expectedResult)
callAny() calls the first function of the list.
provideCallAny()
Data provider for testCallAny().
testCallAnyNoneAvailable()
callAny() throws an exception when all functions are unavailable.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))