is there a guide on how to write tests for stripe (mocking it etc).. i have been googling but still a bit unsure?
I am using latest Laravel 6.0. creating a subscription when user registers. i am mocking the create() function of Stripe\Customer which is used to create customer. but regardless of mocking it is still being called?
public function test_i_can_register()
{
// arrange
$this->mock(\Stripe\Customer::class, function ($mock) {
$mock->shouldReceive('create')->andReturn(json_decode(example Request))
});
this is what i am hoping to mock
www/vendor/stripe/stripe-php/lib/ApiOperations/Create.php
public static function create($params = null, $options = null)
{
dump('come here');
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
when i run my tests i can see the dump(come here).. so i know its not working :/
NOTE example request is just one i made and have pasted in there (eventually will be placed elsewhere)
array:26 [
"id" => "cus_Fw9m3r1gzGagVj"
"object" => "customer"
"account_balance" => 0
"address" => null
"balance" => 0
"created" => 1570298062
"currency" => null
"default_source" => null
"delinquent" => false
"description" => null
"discount" => null
"email" => "sdummyemail"
"invoice_prefix" => "9FE4EC3E"
"invoice_settings" => array:3 [
"custom_fields" => null
"default_payment_method" => null
"footer" => null
]
"livemode" => false
"metadata" => []
"name" => null
"phone" => null
"preferred_locales" => []
"shipping" => null
"sources" => array:5 [
"object" => "list"
"data" => []
"has_more" => false
"total_count" => 0
"url" => "/v1/customers/cus_Fw9m3r1gzGagVj/sources"
]
"subscriptions" => array:5 [
"object" => "list"
"data" => []
"has_more" => false
"total_count" => 0
"url" => "/v1/customers/cus_Fw9m3r1gzGagVj/subscriptions"
]
"tax_exempt" => "none"
"tax_ids" => array:5 [
"object" => "list"
"data" => []
"has_more" => false
"total_count" => 0
"url" => "/v1/customers/cus_Fw9m3r1gzGagVj/tax_ids"
]
"tax_info" => null
"tax_info_verification" => null
]