toBeNull(); }); it('returns empty string when input is empty', function (): void { expect(IncoStringParser::protectiveDataFilter(''))->toBe(''); }); it('strips HTML tags and decodes HTML entities', function (): void { $input = '

Poulet & Dinde

'; expect(IncoStringParser::protectiveDataFilter($input))->toBe('Poulet & Dinde'); }); it('preserves newlines and removes non-printable control characters', function (): void { $input = "Ligne 1\x00\x08\r\nLigne 2\x1F"; expect(IncoStringParser::protectiveDataFilter($input))->toBe("Ligne 1\nLigne 2"); }); }); describe('toPhrase', function (): void { it('formats string as phrase with capitalized first letter and no trailing period', function (): void { expect(IncoStringParser::toPhrase('VOLAILLE DE QUALITE.'))->toBe('Volaille de qualite') ->and(IncoStringParser::toPhrase(' viande de porc '))->toBe('Viande de porc') ->and(IncoStringParser::toPhrase(''))->toBe(''); }); }); describe('beautifyName', function (): void { it('converts text to title case and trims punctuation', function (): void { expect(IncoStringParser::beautifyName('poulet rôti fermier.'))->toBe('Poulet Rôti Fermier') ->and(IncoStringParser::beautifyName(':NUGGETS DE POULET'))->toBe('Nuggets De Poulet') ->and(IncoStringParser::beautifyName(''))->toBe(''); }); }); describe('beautifyText', function (): void { it('returns null when input is null', function (): void { expect(IncoStringParser::beautifyText(null))->toBeNull(); }); it('properly formats sentences and preserves decimal floating point numbers', function (): void { $input = 'viande de poulet 51,5% et eau 20.5%. cuisson au four.'; $result = IncoStringParser::beautifyText($input); expect($result)->toContain('51.5%') ->and($result)->toContain('20.5%') ->and($result)->toContain('Viande de poulet') ->and($result)->toContain('Cuisson au four.'); }); }); describe('mbStrtok', function (): void { it('tokenizes multibyte strings with delimiters', function (): void { $str = 'Gluten;Lait,Œufs'; $delim = ';,'; $first = IncoStringParser::mbStrtok($delim, $str); $second = IncoStringParser::mbStrtok($delim); $third = IncoStringParser::mbStrtok($delim); $fourth = IncoStringParser::mbStrtok($delim); expect($first)->toBe('Gluten') ->and($second)->toBe('Lait') ->and($third)->toBe('Œufs') ->and($fourth)->toBeFalse(); }); }); describe('slugify', function (): void { it('transliterates utf8 to ascii lowercase', function (): void { expect(IncoStringParser::slugify('Émincés & Rôti'))->toBe('eminces & roti'); }); }); describe('words', function (): void { it('truncates text to specified word count', function (): void { $text = 'Un deux trois quatre cinq six sept'; expect(IncoStringParser::words($text, 3, '...'))->toBe('Un deux trois...') ->and(IncoStringParser::words($text, 10))->toBe($text); }); }); });