makePartial(); $user->token_fcm = 'some-fcm-token'; $user->shouldReceive('notify')->once()->with(Mockery::type(FireBaseNotification::class)); $orderStatus = (object)['name' => 'В работе']; $order = Mockery::mock(Order::class); $order->shouldReceive('getAttribute')->with('common_name')->andReturn('ул. Тестовая 1'); $order->shouldReceive('getAttribute')->with('user')->andReturn($user); $order->shouldReceive('getAttribute')->with('orderStatus')->andReturn($orderStatus); $job = new NotifyManagerChangeStatusJob($order); $job->handle(); $this->addToAssertionCount(1); // Mockery expectation: notify called once } public function test_job_handle_skips_notification_when_no_token(): void { $user = Mockery::mock(User::class)->makePartial(); $user->token_fcm = null; $user->shouldNotReceive('notify'); $orderStatus = (object)['name' => 'В работе']; $order = Mockery::mock(Order::class); $order->shouldReceive('getAttribute')->with('common_name')->andReturn('ул. Тестовая 1'); $order->shouldReceive('getAttribute')->with('user')->andReturn($user); $order->shouldReceive('getAttribute')->with('orderStatus')->andReturn($orderStatus); $job = new NotifyManagerChangeStatusJob($order); $job->handle(); $this->assertTrue(true); } }