3 class MWFunctionTest
extends MediaWikiTestCase
{
5 function testCallUserFuncWorkarounds() {
7 call_user_func( array( 'MWFunctionTest', 'someMethod' ) ),
8 MWFunction
::call( 'MWFunctionTest::someMethod' )
11 call_user_func( array( 'MWFunctionTest', 'someMethod' ), 'foo', 'bar', 'baz' ),
12 MWFunction
::call( 'MWFunctionTest::someMethod', 'foo', 'bar', 'baz' )
16 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array() ),
17 MWFunction
::callArray( 'MWFunctionTest::someMethod', array() )
20 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array( 'foo', 'bar', 'baz' ) ),
21 MWFunction
::callArray( 'MWFunctionTest::someMethod', array( 'foo', 'bar', 'baz' ) )
25 function testNewObjFunction() {
28 $arg3 = array( 'Baz' );
29 $arg4 = new ExampleObject
;
31 $args = array( $arg1, $arg2, $arg3, $arg4 );
33 $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 );
35 MWFunction
::newObj( 'MWBlankClass', $args )->args
,
40 MWFunction
::newObj( 'MWBlankClass', $args, true )->args
,
42 'Works even with PHP version < 5.1.3'
47 * @expectedException MWException
49 function testCallingParentFails() {
50 MWFunction
::call( 'parent::foo' );
54 * @expectedException MWException
56 function testCallingSelfFails() {
57 MWFunction
::call( 'self::foo' );
60 public static function someMethod() {
61 return func_get_args();
68 public $args = array();
70 function __construct( $arg1, $arg2, $arg3, $arg4 ) {
71 $this->args
= array( $arg1, $arg2, $arg3, $arg4 );