Fix TestingAccessWrapper::__call
authorAdam Roses Wight <awight@wikimedia.org>
Thu, 26 Mar 2015 08:57:33 +0000 (01:57 -0700)
committerAwight <awight@wikimedia.org>
Thu, 26 Mar 2015 09:26:01 +0000 (09:26 +0000)
We were only passing the first parameter to the wrapped object's methods.

Change-Id: I27a69d1cc1b2d048e44514af8b4ac79d7ee1fb85

tests/phpunit/data/helpers/WellProtectedClass.php
tests/phpunit/includes/TestingAccessWrapper.php
tests/phpunit/includes/TestingAccessWrapperTest.php

index 7114cc9..99c7f64 100644 (file)
@@ -14,4 +14,8 @@ class WellProtectedClass {
        public function getProperty() {
                return $this->property;
        }
+
+       protected function whatSecondArg( $a, $b = false ) {
+               return $b;
+       }
 }
index d4ad363..84c0f9b 100644 (file)
@@ -31,7 +31,7 @@ class TestingAccessWrapper {
                $classReflection = new ReflectionClass( $this->object );
                $methodReflection = $classReflection->getMethod( $method );
                $methodReflection->setAccessible( true );
-               return $methodReflection->invoke( $this->object, $args );
+               return $methodReflection->invokeArgs( $this->object, $args );
        }
 
        public function __set( $name, $value ) {
index 8da8e42..7e5b91a 100644 (file)
@@ -27,4 +27,8 @@ class TestingAccessWrapperTest extends MediaWikiTestCase {
                $this->assertSame( 2, $this->wrapped->property );
                $this->assertSame( 2, $this->raw->getProperty() );
        }
+
+       function testCallMethodTwoArgs() {
+               $this->assertSame( 'two', $this->wrapped->whatSecondArg( 'one', 'two' ) );
+       }
 }