/** * Sets a mock Mailchimp API that will pass the webhook is configured * correctly test. * * This code is used in many methods. * * @return Prophecy. */ protected function prepMockForWebhookConfig() { // Make mock API that will return a webhook with the sources.API setting // set, which is wrong. $api_prophecy = $this->prophesize('CRM_Mailchimp_Api3'); CRM_Mailchimp_Utils::setMailchimpApi($api_prophecy->reveal()); $url = CRM_Mailchimp_Utils::getWebhookUrl(); $api_prophecy->get("/lists/dummylistid/webhooks", Argument::any())->shouldBeCalled()->willReturn(json_decode('{"http_code":200,"data":{"webhooks":[{"url":"' . $url . '","sources":{"api":false}}]}}')); return $api_prophecy; }