Can you show your SNPHubSpotService class? Do you know if it's using the HTTP facade? If not, faking the facade isn't going to do anything and you'll need to mock it another way.
Mar 5, 2024
3
Level 1
Why does Laravel HTTP fake not work...??!!??!
I have a project im testing and its connection to Hubspot. I have a simple service that has one method that needs to create a user in hubspot.
I create a pest unit test for it but http fake is not getting intercepting the request and i cant understand WHY?! :(
Http::fake([
'https://api.hubapi.com/crm/v3/objects/*' => Http::response(
array(
"properties" => array(
"email" => "[email protected]",
"date_of_birth" => "1984/10/19",
"firstname" => "Piet1",
"lastname" => "Pompies1",
"phone" => "0822234567",
"registration_p1" => "Yes",
"registration_p2" => "Yes",
"membership_linked" => "Yes",
"membership_number" => "123456789"
)
)
, 201),
]);
$hubSpotService = new SNPHubSpotService();
$result = $hubSpotService->createContact([
'email' => fake()->safeEmail(),
'date_of_birth' => '1986-09-04',
'firstname' => fake()->name(),
'lastname' => fake()->lastName(),
'phone' => '0825912364'
]);
expect($result)->toBeTrue();
});
PLEASE HELP...
Please or to participate in this conversation.