test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / MWFunctionTest.php
blobbecf5075ee86e7aee8097f4fffca4eccd8db993a
1 <?php
3 class MWFunctionTest extends MediaWikiTestCase {
4 function testCallUserFuncWorkarounds() {
5 $this->assertEquals(
6 call_user_func( array( 'MWFunctionTest', 'someMethod' ) ),
7 MWFunction::call( 'MWFunctionTest::someMethod' )
8 );
9 $this->assertEquals(
10 call_user_func( array( 'MWFunctionTest', 'someMethod' ), 'foo', 'bar', 'baz' ),
11 MWFunction::call( 'MWFunctionTest::someMethod', 'foo', 'bar', 'baz' )
14 $this->assertEquals(
15 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array() ),
16 MWFunction::callArray( 'MWFunctionTest::someMethod', array() )
18 $this->assertEquals(
19 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array( 'foo', 'bar', 'baz' ) ),
20 MWFunction::callArray( 'MWFunctionTest::someMethod', array( 'foo', 'bar', 'baz' ) )
24 function testNewObjFunction() {
25 $arg1 = 'Foo';
26 $arg2 = 'Bar';
27 $arg3 = array( 'Baz' );
28 $arg4 = new ExampleObject;
30 $args = array( $arg1, $arg2, $arg3, $arg4 );
32 $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 );
33 $this->assertEquals(
34 MWFunction::newObj( 'MWBlankClass', $args )->args,
35 $newObject->args
38 $this->assertEquals(
39 MWFunction::newObj( 'MWBlankClass', $args, true )->args,
40 $newObject->args,
41 'Works even with PHP version < 5.1.3'
45 /**
46 * @expectedException MWException
48 function testCallingParentFails() {
49 MWFunction::call( 'parent::foo' );
52 /**
53 * @expectedException MWException
55 function testCallingSelfFails() {
56 MWFunction::call( 'self::foo' );
59 public static function someMethod() {
60 return func_get_args();
64 class MWBlankClass {
66 public $args = array();
68 function __construct( $arg1, $arg2, $arg3, $arg4 ) {
69 $this->args = array( $arg1, $arg2, $arg3, $arg4 );
73 class ExampleObject {