views:

210

answers:

2

Is there a good standalone mock framework for PHP? Currently I am using Simpletest framework for unit testing. I like the framework, but I dont like how you create and setup a mock in it. I then tried PHPMock, I like how it can be used, but it I encountered some bugs that get annoying over time ... Or would it be best to switch over to PHPUnit for unit testing and mocking?

What I would really like is something easy and yet powerful like the Moq framework for C# in PHP (no generics, lambdas etc. of course ;) ).

+1  A: 

I would go for PHPUnit.

  • I have positive experiences with it,
  • it is supported in IDEs (Zend studio, NetBeans),
  • and Zend framework (Doctrine ORM, etc.) developers use it also.
Steve
A: 

While I've not implemented a mock framework myself, I was impressed with Mockery.

Its a completely independent mock and stub framework that you should be able to integrate easily with any existing framework or just into your existing code base.

Noah Goodrich
Do you know if this is a progressed version of PHPMock? On the same blog there exists a post about PHPMock (http://blog.astrumfutura.com/archives/320-PHPMock-Independent-Mock-ObjectStub-Framework.html) but Mockery is at least two years newer.
Max
I'm fairly certain that this was written from scratch. It may employ ideas PHPMock, but I'm pretty certain that the similarities end there.
Noah Goodrich