3 class MWFunctionTest
extends MediaWikiTestCase
{
4 function testCallUserFuncWorkarounds() {
6 call_user_func( array( 'MWFunctionTest', 'someMethod' ) ),
7 MWFunction
::call( 'MWFunctionTest::someMethod' )
10 call_user_func( array( 'MWFunctionTest', 'someMethod' ), 'foo', 'bar', 'baz' ),
11 MWFunction
::call( 'MWFunctionTest::someMethod', 'foo', 'bar', 'baz' )
15 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array() ),
16 MWFunction
::callArray( 'MWFunctionTest::someMethod', array() )
19 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array( 'foo', 'bar', 'baz' ) ),
20 MWFunction
::callArray( 'MWFunctionTest::someMethod', array( 'foo', 'bar', 'baz' ) )
24 function testNewObjFunction() {
27 $arg3 = array( 'Baz' );
28 $arg4 = new ExampleObject
;
30 $args = array( $arg1, $arg2, $arg3, $arg4 );
32 $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 );
34 MWFunction
::newObj( 'MWBlankClass', $args )->args
,
39 MWFunction
::newObj( 'MWBlankClass', $args, true )->args
,
41 'Works even with PHP version < 5.1.3'
46 * @expectedException MWException
48 function testCallingParentFails() {
49 MWFunction
::call( 'parent::foo' );
53 * @expectedException MWException
55 function testCallingSelfFails() {
56 MWFunction
::call( 'self::foo' );
59 public static function someMethod() {
60 return func_get_args();
66 public $args = array();
68 function __construct( $arg1, $arg2, $arg3, $arg4 ) {
69 $this->args
= array( $arg1, $arg2, $arg3, $arg4 );