shouldReceive('getId')->andReturn(1); $order->shouldReceive('getNumber')->andReturn('ABC_1234'); $order->shouldReceive('generateQRCode'); $order->shouldReceive('hasOwner')->andReturnFalse(); $order->shouldReceive('getOwnerEmail')->andReturn('test@test.com'); $order->shouldReceive('getOwnerFirstName')->andReturn('test'); $order->shouldReceive('getOwnerSurname')->andReturn('test'); $order->shouldReceive('getOwnerFullName')->andReturn('test test'); $order->shouldReceive('getRawAmount')->andReturn(1000); $order->shouldReceive('getFinalAmount')->andReturn(1000); $order->shouldReceive('getTaxesAmount')->andReturn(0); $order->shouldReceive('getDiscountAmount')->andReturn(0); $order->shouldReceive('getCurrency')->andReturn('USD'); $order->shouldReceive('getQRCode')->andReturn('QR_CODE'); $order->shouldReceive('getSummit')->andReturn(self::$summit); $order->shouldReceive('getTickets')->andReturn([]); $externalUserApi = \Mockery::mock(IExternalUserApi::class) ->shouldIgnoreMissing(); $externalUserApi->shouldReceive('getUserByEmail') ->with('test@test.com')->andReturn([]); $externalUserApi->shouldReceive('registerUser')->andReturn( [ 'set_password_link' => 'https://test.com' ] ); $this->app->instance(IExternalUserApi::class, $externalUserApi); $orderRepository = \Mockery::mock(ISummitOrderRepository::class)->shouldIgnoreMissing(); $orderRepository->shouldReceive('getById')->with(1)->andReturn($order); $this->app->instance(ISummitOrderRepository::class, $orderRepository); $job = new ProcessSummitOrderPaymentConfirmation($order->getId()); $job->handle(App::make(ISummitOrderService::class)); } catch (\Exception $ex){ $this->fail($ex->getMessage()); } $this->assertTrue(true); } public function testDispatchPaymentConfirmationJobWithExistentUser(){ try { $order = \Mockery::mock(SummitOrder::class); $order->shouldReceive('getId')->andReturn(1); $order->shouldReceive('getNumber')->andReturn('ABC_1234'); $order->shouldReceive('generateQRCode'); $order->shouldReceive('hasOwner')->andReturnFalse(); $order->shouldReceive('getOwnerEmail')->andReturn('test@test.com'); $order->shouldReceive('getOwnerFirstName')->andReturn('test'); $order->shouldReceive('getOwnerSurname')->andReturn('test'); $order->shouldReceive('getOwnerFullName')->andReturn('test test'); $order->shouldReceive('getRawAmount')->andReturn(1000); $order->shouldReceive('getFinalAmount')->andReturn(1000); $order->shouldReceive('getTaxesAmount')->andReturn(0); $order->shouldReceive('getDiscountAmount')->andReturn(0); $order->shouldReceive('getCurrency')->andReturn('USD'); $order->shouldReceive('getQRCode')->andReturn('QR_CODE'); $order->shouldReceive('getSummit')->andReturn(self::$summit); $order->shouldReceive('getTickets')->andReturn([]); $order->shouldReceive('setOwner'); $externalUserApi = \Mockery::mock(IExternalUserApi::class) ->shouldIgnoreMissing(); $externalUserApi->shouldReceive('getUserByEmail') ->with('test@test.com')->andReturn([ 'email' => 'test@test.com', 'id' => '1', 'first_name' => 'test', 'last_name' => 'test', ]); $externalUserApi->shouldReceive('registerUser')->andReturn( [ 'set_password_link' => 'https://test.com' ] ); $this->app->instance(IExternalUserApi::class, $externalUserApi); $orderRepository = \Mockery::mock(ISummitOrderRepository::class)->shouldIgnoreMissing(); $orderRepository->shouldReceive('getById')->with(1)->andReturn($order); $this->app->instance(ISummitOrderRepository::class, $orderRepository); $memberRepository = \Mockery::mock(IMemberRepository::class)->shouldIgnoreMissing(); $this->app->instance(IMemberRepository::class, $memberRepository); $job = new ProcessSummitOrderPaymentConfirmation($order->getId()); $job->handle(App::make(ISummitOrderService::class)); } catch (\Exception $ex){ $this->fail($ex->getMessage()); } $this->assertTrue(true); } public function testDispatchRefund(){ \App\Jobs\ProcessOrderRefundRequest::dispatch( 23, 10 ); } }