37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Services\Sms\SmsMessageLength;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SmsMessageLengthTest extends TestCase
|
|
{
|
|
public function test_gsm_message_is_limited_to_160_units(): void
|
|
{
|
|
$length = new SmsMessageLength;
|
|
|
|
$this->assertTrue($length->fitsInOneSms(str_repeat('a', 160)));
|
|
$this->assertFalse($length->fitsInOneSms(str_repeat('a', 161)));
|
|
$this->assertSame(160, $length->units(str_repeat('^', 80)));
|
|
}
|
|
|
|
public function test_unicode_message_is_limited_to_70_units(): void
|
|
{
|
|
$length = new SmsMessageLength;
|
|
|
|
$this->assertTrue($length->fitsInOneSms(str_repeat('ê', 70)));
|
|
$this->assertFalse($length->fitsInOneSms(str_repeat('ê', 71)));
|
|
}
|
|
|
|
public function test_value_is_truncated_with_marker_inside_one_sms(): void
|
|
{
|
|
$length = new SmsMessageLength;
|
|
$value = $length->truncateBetween('Rappel : ', str_repeat('a', 200), "\n17/09/2026 14:00");
|
|
$message = 'Rappel : '.$value."\n17/09/2026 14:00";
|
|
|
|
$this->assertStringEndsWith('[...]', $value);
|
|
$this->assertTrue($length->fitsInOneSms($message));
|
|
}
|
|
}
|