mardi 6 janvier 2015

Mock a public property on a static method?

I am using Confide which requires you do something like



Confide::user()->id


To get the user ID. And I am trying to mock this so it returns a garbage user id. I can mock Confide::user() fine by using Laravel's built in Facade mocking



Confide::shouldReceive('user')->once()->andReturn('blah');


If I run Confide::user() it returns blah.


But how can I add a property so if I run Confide::user()->id it returns a mock value?


Aucun commentaire:

Enregistrer un commentaire