3 class MWFunctionTest
extends MediaWikiTestCase
{
5 function testCallUserFuncWorkarounds() {
8 call_user_func( array( 'MWFunctionTest', 'someMethod' ) ),
9 MWFunction
::call( 'MWFunctionTest::someMethod' )
12 call_user_func( array( 'MWFunctionTest', 'someMethod' ), 'foo', 'bar', 'baz' ),
13 MWFunction
::call( 'MWFunctionTest::someMethod', 'foo', 'bar', 'baz' )
19 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array() ),
20 MWFunction
::callArray( 'MWFunctionTest::someMethod', array() )
23 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array( 'foo', 'bar', 'baz' ) ),
24 MWFunction
::callArray( 'MWFunctionTest::someMethod', array( 'foo', 'bar', 'baz' ) )
29 function testNewObjFunction() {
33 $arg3 = array( 'Baz' );
34 $arg4 = new ExampleObject
;
36 $args = array( $arg1, $arg2, $arg3, $arg4 );
38 $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 );
41 MWFunction
::newObj( 'MWBlankClass', $args )->args
,
46 MWFunction
::newObj( 'MWBlankClass', $args, true )->args
,
48 'Works even with PHP version < 5.1.3'
54 * @expectedException MWException
56 function testCallingParentFails() {
58 MWFunction
::call( 'parent::foo' );
62 * @expectedException MWException
64 function testCallingSelfFails() {
66 MWFunction
::call( 'self::foo' );
69 public static function someMethod() {
70 return func_get_args();
77 public $args = array();
79 function __construct( $arg1, $arg2, $arg3, $arg4 ) {
80 $this->args
= array( $arg1, $arg2, $arg3, $arg4 );