Tuesday 15 July 2014

php - Testing __call() with mockery? -


I have a very basic function in my class that justifies the comment, it just calls the baby model Does it work perfectly with my tests if they are not present on this class.

  / ** * Directly handles calling methods on the user model from the provider * e.g. Guardian :: User () - & gt; Searchofffell (1) without redistribution of methods * * @best $ method * @PRAM $ parameter * * @ return mix * / public function __call ($ method, $ parameter) {$ user = $ this- & gt; CreateModel (); Return call_user_func_array ([$ user, $ method], $ parameter); }   

However, in the case of which I tried the test I tried, write the unit test for this:

  public function testProviderAsksModelToFind () {$ FactoryUser = factory :: for attributes ('user', ['id' => 1]); $ P = m :: fake ('webfox \ guardian \ user \ guardian \ provider [making model]', [']]; $ User = m: fake ('webfox \ guardian \ user \ guardian user \ [search]'); $ P- & gt; ShouldReceive ('createModel') - & gt; Once () - & gt; AndReturn (user $); $ User- & gt; ShouldReceive ('feel') - & gt; (1) - & gt; Once () - & gt; AndReturn ($ factoryUser); $ This- & gt; Assign ($ factory user, $ p-> search (1)); }   

However this is spitting out pretty error:

1) EloquentUserProviderTest :: testProviderAsksModelToFind BadMethodCallException: Method Webfox \ Guardian \ User \ Guardian \ Provider: : This fake object is not present on

So, how can I fix it so that my test passes?

postprop = "itemprop =" text ">

The strange thing is that the method search provider is called on the fake class. The error claims that it should not be:

  $ this-> AssertSame ($ factoryUser, $ user- & gt; looks (1));   

?

No comments:

Post a Comment