MediaWiki  REL1_22
wfGetCallerTest.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class WfGetCallerTest extends MediaWikiTestCase {
00007 
00008     public function testZero() {
00009         $this->assertEquals( __METHOD__, wfGetCaller( 1 ) );
00010     }
00011 
00012     function callerOne() {
00013         return wfGetCaller();
00014     }
00015 
00016     public function testOne() {
00017         $this->assertEquals( 'WfGetCallerTest::testOne', self::callerOne() );
00018     }
00019 
00020     function intermediateFunction( $level = 2, $n = 0 ) {
00021         if ( $n > 0 ) {
00022             return self::intermediateFunction( $level, $n - 1 );
00023         }
00024 
00025         return wfGetCaller( $level );
00026     }
00027 
00028     public function testTwo() {
00029         $this->assertEquals( 'WfGetCallerTest::testTwo', self::intermediateFunction() );
00030     }
00031 
00032     public function testN() {
00033         $this->assertEquals( 'WfGetCallerTest::testN', self::intermediateFunction( 2, 0 ) );
00034         $this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( 1, 0 ) );
00035 
00036         for ( $i = 0; $i < 10; $i++ ) {
00037             $this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( $i + 1, $i ) );
00038         }
00039     }
00040 }