| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class WfGetCallerTest extends MediaWikiUnitTestCase { |
| 8 |
public function testZero() { |
| 9 |
$this->assertEquals( 'WfGetCallerTest->testZero', wfGetCaller( 1 ) ); |
| 10 |
} |
| 11 |
|
| 12 |
public function callerOne() { |
| 13 |
return wfGetCaller(); |
| 14 |
} |
| 15 |
|
| 16 |
public function testOne() { |
| 17 |
$this->assertEquals( 'WfGetCallerTest->testOne', self::callerOne() ); |
| 18 |
} |
| 19 |
|
| 20 |
public static function intermediateFunction( $level = 2, $n = 0 ) { |
| 21 |
if ( $n > 0 ) { |
| 22 |
return self::intermediateFunction( $level, $n - 1 ); |
| 23 |
} |
| 24 |
|
| 25 |
return wfGetCaller( $level ); |
| 26 |
} |
| 27 |
|
| 28 |
public function testTwo() { |
| 29 |
$this->assertEquals( 'WfGetCallerTest->testTwo', self::intermediateFunction() ); |
| 30 |
} |
| 31 |
|
| 32 |
public function testN() { |
| 33 |
$this->assertEquals( 'WfGetCallerTest->testN', self::intermediateFunction( 2, 0 ) ); |
| 34 |
$this->assertEquals( |
| 35 |
'WfGetCallerTest::intermediateFunction', |
| 36 |
self::intermediateFunction( 1, 0 ) |
| 37 |
); |
| 38 |
|
| 39 |
for ( $i = 0; $i < 10; $i++ ) { |
| 40 |
$this->assertEquals( |
| 41 |
'WfGetCallerTest::intermediateFunction', |
| 42 |
self::intermediateFunction( $i + 1, $i ) |
| 43 |
); |
| 44 |
} |
| 45 |
} |
| 46 |
} |