* upgrade patches for oracle 1.17->1.19
[mediawiki.git] / tests / phpunit / includes / MWFunctionTest.php
blobed5e76029655e92205f4cc747f41ee352aec2df6
1 <?php
3 class MWFunctionTest extends MediaWikiTestCase {
5 function testCallUserFuncWorkarounds() {
7 $this->assertEquals(
8 call_user_func( array( 'MWFunctionTest', 'someMethod' ) ),
9 MWFunction::call( 'MWFunctionTest::someMethod' )
11 $this->assertEquals(
12 call_user_func( array( 'MWFunctionTest', 'someMethod' ), 'foo', 'bar', 'baz' ),
13 MWFunction::call( 'MWFunctionTest::someMethod', 'foo', 'bar', 'baz' )
18 $this->assertEquals(
19 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array() ),
20 MWFunction::callArray( 'MWFunctionTest::someMethod', array() )
22 $this->assertEquals(
23 call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array( 'foo', 'bar', 'baz' ) ),
24 MWFunction::callArray( 'MWFunctionTest::someMethod', array( 'foo', 'bar', 'baz' ) )
29 function testNewObjFunction() {
31 $arg1 = 'Foo';
32 $arg2 = 'Bar';
33 $arg3 = array( 'Baz' );
34 $arg4 = new ExampleObject;
36 $args = array( $arg1, $arg2, $arg3, $arg4 );
38 $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 );
40 $this->assertEquals(
41 MWFunction::newObj( 'MWBlankClass', $args )->args,
42 $newObject->args
45 $this->assertEquals(
46 MWFunction::newObj( 'MWBlankClass', $args, true )->args,
47 $newObject->args,
48 'Works even with PHP version < 5.1.3'
53 /**
54 * @expectedException MWException
56 function testCallingParentFails() {
58 MWFunction::call( 'parent::foo' );
61 /**
62 * @expectedException MWException
64 function testCallingSelfFails() {
66 MWFunction::call( 'self::foo' );
69 public static function someMethod() {
70 return func_get_args();
75 class MWBlankClass {
77 public $args = array();
79 function __construct( $arg1, $arg2, $arg3, $arg4 ) {
80 $this->args = array( $arg1, $arg2, $arg3, $arg4 );
85 class ExampleObject {