#feature: some update

This commit is contained in:
2026-08-12 18:00:09 +08:00
parent ba916f5ce1
commit 103340536b
39 changed files with 2916 additions and 227 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace Tests\Unit;
use App\Services\DingTalkService;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class DingTalkServiceTest extends TestCase
{
public function test_it_sends_text_to_a_robot_token(): void
{
Http::fake([
'https://oapi.dingtalk.com/robot/send?access_token=report-token' => 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);
}
}