_stefanzweifel’s avatar_stefanzweifel’s Twitter Archive—№ 372

  1. ❓ Folks, what's the "right way"™ in phpunit to assert that the payload to an API looks like what you expect?
    1. …in reply to @_stefanzweifel
      . @adamwathan had the best solution: Fakes. @adamwathan/1146800745808846848?s=20
    2. …in reply to @_stefanzweifel
      Currently using "$this->mock()->shouldReceive()->with()->andReturn();" but this feels dirty, as I don't actually write assertions against the payload. (And the Mockery Exceptions are not really helpful when a test fails)
      1. …in reply to @_stefanzweifel
        Thinking of setting the API client as a singleton, "store" the payload as a public property and then use the property for my assertions in my tests. 🤔 I think I'm missing something here. This can't be the right way…
        1. …in reply to @_stefanzweifel
          Guzzle's MockHandlers are cool, but only work for responses. (docs.guzzlephp.org/en/stable/testing.html#mock-handler) Maybe I should just write a class which prepares and formats the data.