Files

32 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace PhpQml\Bridge\Tests\Maker\Support;
use PhpQml\Bridge\Maker\Support\Naming;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
#[CoversClass(Naming::class)]
final class NamingTest extends TestCase
{
#[DataProvider('camelToCases')]
public function testCamelTo(string $input, string $separator, string $expected): void
{
self::assertSame($expected, Naming::camelTo($input, $separator));
}
/** @return iterable<string, array{string, string, string}> */
public static function camelToCases(): iterable
{
yield 'single word, underscore' => ['Todo', '_', 'todo'];
yield 'two words, underscore' => ['TodoList', '_', 'todo_list'];
yield 'two words, dash' => ['MarkAllDone', '-', 'mark-all-done'];
yield 'leading uppercase, no split' => ['Todo', '-', 'todo'];
yield 'all caps stay together (acronym preserved)' => ['HTTPClient', '-', 'h-t-t-p-client'];
yield 'empty input' => ['', '-', ''];
}
}