shouldReceive('get_related_orders') ->andReturn( [ 1 => 1, 3 => 3, 2 => 2, ] ); $wc_order = Mockery::mock(WC_Order::class); $wc_order->shouldReceive('get_status')->andReturn('processing'); $wc_order->shouldReceive('get_transaction_id')->andReturn('ABC123'); when('wc_get_order')->justReturn($wc_order); $this->assertSame( 'ABC123', (new SubscriptionHelper())->previous_transaction($subscription) ); } }