Http::response([ 'errcode' => 0, ]), ]); $sent = (new DingTalkService)->sendTextToToken('report-token', '日报内容'); $this->assertTrue($sent); Http::assertSent(fn ($request) => $request->url() === 'https://oapi.dingtalk.com/robot/send?access_token=report-token' && $request->data() === [ 'msgtype' => 'text', 'text' => ['content' => '日报内容'], 'at' => ['atMobiles' => [], 'isAtAll' => false], ]); } public function test_it_reports_a_dingtalk_business_error(): void { Http::fake([ 'https://oapi.dingtalk.com/robot/send?access_token=invalid-token' => Http::response([ 'errcode' => 310000, 'errmsg' => 'invalid token', ]), ]); $sent = (new DingTalkService)->sendTextToToken('invalid-token', '日报内容'); $this->assertFalse($sent); } }