summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
blob: 58cf6b95d9d0fa8c6131024226f6dffc15d712c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

class WfGetCallerTest extends MediaWikiTestCase {

	function testZero() {
		$this->assertEquals( __METHOD__, wfGetCaller( 1 ) );
	}

	function callerOne() {
		return wfGetCaller();
	}

	function testOne() {
		$this->assertEquals( 'WfGetCallerTest::testOne', self::callerOne() );
	}

	function intermediateFunction( $level = 2, $n = 0 ) {
		if ( $n > 0 ) {
			return self::intermediateFunction( $level, $n - 1 );
		}
		return wfGetCaller( $level );
	}

	function testTwo() {
		$this->assertEquals( 'WfGetCallerTest::testTwo', self::intermediateFunction() );
	}

	function testN() {
		$this->assertEquals( 'WfGetCallerTest::testN', self::intermediateFunction( 2, 0 ) );
		$this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( 1, 0 ) );

		for ( $i = 0; $i < 10; $i++ )
			$this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( $i + 1, $i ) );
	}
}