0

I'm not sure if it's the proper place for such question since it's rather theoretical than the specific code sample but I'll ask anyway.

So, at some point PHP introduced type constrains in function definition (except basic types of course), i.e.

class A {
   public $value;
}

function foo($someInt, A $a) {...}

What make me wondering is if PHPUnit mocks can be used in such situation:

class functionTest extends PHPUnit_Framework_TestCase {
    public function testFoo() {
       $mockA = $this->getMockBuilder('A')->getMock();

       $this->assertEquals('some result', foo(1, $mockA));
    }
}

Would such call be accepted when the test runs (ofc. I skipped includes and stuff to keep it simple).

And the more interesting question: if yes, then how is it implemented?

1 Answer 1

2

Yes it will be working, PHPUnit will mock your object. This mocked object will dynamically extends the base Object you want to mock.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.