packages/requirements/tests/Unit/Ears/WordingTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Ears;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\DataProvider;
9use PHPUnit\Framework\Attributes\Small;
10use PHPUnit\Framework\TestCase;
11use Requirements\Ears\Wording;
12
13#[CoversClass(Wording::class)]
14#[Small]
15final class WordingTest extends TestCase
16{
17    #[DataProvider('providerHasContent')]
18    public function testHasContent(string $text, bool $expected): void
19    {
20        self::assertSame($expected, Wording::hasContent($text));
21    }
22
23    /**
24     * @return array<string, array{string, bool}>
25     */
26    public static function providerHasContent(): array
27    {
28        return [
29            'letters' => ['a token is read', true],
30            'digits' => ['42', true],
31            'letter among punctuation' => ['... x ...', true],
32            'non-latin letter' => ['é', true],
33            'non-latin digit' => ['٣', true],
34            'empty' => ['', false],
35            'space' => [" \t ", false],
36            'punctuation' => ['...,;!', false],
37        ];
38    }
39}
40