feat: update allowed frontend hosts and add clinic-pro.ir domain

This commit is contained in:
hamed
2026-07-21 16:51:42 +03:30
parent 512dbdaba0
commit 7e847b62c4
14 changed files with 207 additions and 25 deletions
+21
View File
@@ -46,4 +46,25 @@ class KavehNegarProviderTest extends TestCase
$this->assertSame('GET', $this->captured['method']);
$this->assertStringContainsString('/TESTKEY/sms/send.json', $this->captured['url']);
}
/** توکن بلند (نام فارسی) باید cap شود تا URL بزرگ نشود و کاوه‌نگار 431 ندهد. */
public function testLongTokenIsCapped(): void
{
$long = str_repeat('ک', 200); // 200 کاراکتر فارسی
$ok = $this->provider()->sendTemplate('09120671756', 'clinicpro-welcome', ['token' => $long]);
$this->assertTrue($ok);
parse_str(parse_url($this->captured['url'], PHP_URL_QUERY), $q);
$this->assertLessThanOrEqual(60, mb_strlen($q['token'], 'UTF-8'));
}
/** خطای 4xx کاوه‌نگار (مثل 431) باید false برگرداند و throw نکند. */
public function testHttpErrorReturnsFalseWithoutThrowing(): void
{
$client = new MockHttpClient(fn (): MockResponse => new MockResponse('too large', ['http_code' => 431]));
$provider = new KavehNegarProvider($client, new NullLogger(), 'TESTKEY', '10004346');
$this->assertFalse($provider->sendTemplate('09120671756', 'clinicpro-welcome', ['token' => 'x']));
$this->assertFalse($provider->send('09120671756', 'hello'));
}
}