wiki.techinc.nl/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php
Umherirrender 5bd311b1a2 Add public as visibility in tests folder
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff

Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
2019-10-10 21:55:37 +02:00

46 lines
1.1 KiB
PHP

<?php
/**
* @group GlobalFunctions
* @covers ::wfGetCaller
*/
class WfGetCallerTest extends MediaWikiUnitTestCase {
public function testZero() {
$this->assertEquals( 'WfGetCallerTest->testZero', wfGetCaller( 1 ) );
}
public function callerOne() {
return wfGetCaller();
}
public function testOne() {
$this->assertEquals( 'WfGetCallerTest->testOne', self::callerOne() );
}
public static function intermediateFunction( $level = 2, $n = 0 ) {
if ( $n > 0 ) {
return self::intermediateFunction( $level, $n - 1 );
}
return wfGetCaller( $level );
}
public function testTwo() {
$this->assertEquals( 'WfGetCallerTest->testTwo', self::intermediateFunction() );
}
public 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 )
);
}
}
}