How do I mock HTTP requests for PHPUnit?
-
06-11-2019 - |
سؤال
I'm writing a plugin that makes requests to the Facebook graph API. As I don't want my unit tests to actually make these requests, how would I overcome this? My method calls both wp_remote_get
and wp_remote_post
. Searching there does seem to be a way to mock functions using runkit
, here
I want to avoid having contributers requiring too many dependencies so would like to avoid the above method. Is there any other options? My class extends the WP_UnitTestCase
so I'm hoping maybe there's something from the wp unit-tests that I could use?
لا يوجد حل صحيح
لا تنتمي إلى wordpress.stackexchange