0

I want to add test coverage to a method inside a PHP class which invokes a PHP-built-in method. To be able to mock copy(), I had to create a wrapper class. Is there a better way to mock PHP's built-in methods? By "better", I mean that I do not want to introduce a wrapper class just for the sake of the unit testing.

I've checked these docs but could not find an answer.

I use PHP and PHPUnit only for a side project, therefore I might overlook something obvious?

1 Answer 1

1

To verify filesystem operations in a unit test I usually rely on vfsStream. It's a virtual filesystem wrapper that allows you to test all operations on an in-memory filesystem.

If you just want to mock a built-in function, there's php-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.