Something went wrong. Try again.
Parse and validate AT Protocol Lexicons with DTO generation for Laravel
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879<?php
namespace SocialDept\AtpSchema\Tests\Unit\Validation\Rules;
use Orchestra\Testbench\TestCase;use SocialDept\AtpSchema\Validation\Rules\MaxGraphemes;
class MaxGraphemesTest extends TestCase{ public function test_it_validates_string_within_limit(): void { $rule = new MaxGraphemes(10);
$valid = 'Hello';
$failed = false; $rule->validate('text', $valid, function () use (&$failed) { $failed = true; });
$this->assertFalse($failed); }
public function test_it_rejects_string_exceeding_limit(): void { $rule = new MaxGraphemes(5);
$invalid = 'This is too long';
$failed = false; $rule->validate('text', $invalid, function () use (&$failed) { $failed = true; });
$this->assertTrue($failed); }
public function test_it_counts_graphemes_correctly(): void { $rule = new MaxGraphemes(5);
// 6 emoji graphemes $invalid = '😀😁😂😃😄😅';
$failed = false; $rule->validate('text', $invalid, function () use (&$failed) { $failed = true; });
$this->assertTrue($failed); }
public function test_it_allows_exact_limit(): void { $rule = new MaxGraphemes(5);
$valid = '😀😁😂😃😄';
$failed = false; $rule->validate('text', $valid, function () use (&$failed) { $failed = true; });
$this->assertFalse($failed); }
public function test_it_rejects_non_string(): void { $rule = new MaxGraphemes(10);
$failed = false; $rule->validate('text', 123, function () use (&$failed) { $failed = true; });
$this->assertTrue($failed); }}