payment = new class { public string $method = 'paypal_smart_button'; public array $additional = ['gateway_order_id' => 'GW-LOCK-1']; }; } }; $orderRepository = Mockery::mock(OrderRepository::class); $orderRepository->shouldReceive('find')->once()->with(99)->andReturn($order); $orderRepository->shouldReceive('cancel')->never(); $smartButton = Mockery::mock(SmartButton::class); $smartButton->shouldReceive('getOrder')->once()->with('GW-LOCK-1')->andReturn( (object) [ 'result' => (object) [ 'status' => 'VOIDED', 'purchase_units' => [(object) ['payments' => (object) ['captures' => []]]], ], ] ); $this->app->instance(SmartButton::class, $smartButton); DB::shouldReceive('transaction')->once()->andReturn(false); (new ReconcilePendingPaymentJob(99))->handle($orderRepository); Event::assertDispatched('bagistoapi.payment.reconcile.voided'); Event::assertNotDispatched('bagistoapi.payment.reconcile.cancelled'); } }