Posts tagged doctrine

phpunit-small

PHPUnit – How to mock multiple calls to the same method

0

When you write unit tests with PHPUnit there is a big chance that you have to mock several objects. If you want to write a unit test for your controller action and you use Doctrine ORM in your project, you will have to mock the Doctrine EntityManager, specific repositories and specify return values of the repository method calls. In the example below a repository method calls are “getCustomers” and “getNewHouse”.

The use of $this->at() (not possible)

Mocking multiple calls to the same method can be a bit difficult with PHPUnit. Because if you have More >

apigility-hero-small

ZF Apigility + Doctrine + UniqueObject Validator

3

Building a REST API with Apigility that is built on top of Zend Framework 2 is awesome. I’m also a big fan of Doctrine. So I started with the zf-apigility-skeleton and added the zf-apigility-doctrine vendor.

I created an User API and a Doctrine REST service called “User” with the route “/users[/:userId]“. You can defined fields per REST service. Every field will become an instance of Zend\InputFilter\Input, and together they are specified in a Zend\InputFilter\InputFilter.

The username must be unique, so for the POST (adding a user) /users More >

Go to Top