Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Davva's avatar
Level 10

Mockery : nested method?

I am writing some tests for a Stripe API implementation. A Stripe Refund is made like this via their API:

$ch = \Stripe\Charge::retrieve( $chargeId );
$re = $ch->refunds->create();

I am using Mockery, but I don't know how to mock the refunds->create method?

The following will not work (I get a "Trying to get property of non-object" error):

$charge = Mockery::mock( 'Stripe\Charge' );
$charge->shouldReceive( 'refunds->create' );
0 likes
0 replies

Please or to participate in this conversation.