lundi 9 mars 2015

mocking findOneBy"field" in doctrine2 with phpunit

If I mock the repository method find I got the expected results, but if I method with either findBy, findOneBy, findOneById I've got alway null.


example:



$mock->expects($this->once())
->method('getId')
->will($this->returnValue(1));
$mockRepository->expects($this->any())
->method('findBy') //if here I use 'find' works for all other cases always null
->will($this->returnValue($mock));


Is there a reson why this happen? is it possible to mock the "magics" method of doctrine2 like findById or findOneById? if it yes how is wrong in my approach?


Aucun commentaire:

Enregistrer un commentaire