. */ declare(strict_types=1); namespace App\Tests\Doctrine\Functions; use App\Doctrine\Functions\ILike; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform; use PHPUnit\Framework\Attributes\DataProvider; final class ILikeTest extends AbstractDoctrineFunctionTestCase { public static function iLikePlatformProvider(): \Generator { yield 'mysql' => [new MySQLPlatform(), '(part_name LIKE :pattern)']; yield 'postgres' => [new PostgreSQLPlatform(), '(part_name ILIKE :pattern)']; yield 'sqlite' => [new SQLitePlatform(), "(part_name LIKE :pattern ESCAPE '\\')"]; } #[DataProvider('iLikePlatformProvider')] public function testILikeUsesExpectedOperator(AbstractPlatform $platform, string $expectedSql): void { $function = new ILike('ILIKE'); $function->value = $this->createNode('part_name'); $function->expr = $this->createNode(':pattern'); $sql = $function->getSql($this->createSqlWalker($platform)); $this->assertSame($expectedSql, $sql); } public function testILikeThrowsOnUnsupportedPlatform(): void { $function = new ILike('ILIKE'); $function->value = $this->createNode('part_name'); $function->expr = $this->createNode(':pattern'); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('does not support case insensitive like expressions'); $function->getSql($this->createSqlWalker(new SQLServerPlatform())); } }