. */ declare(strict_types=1); namespace App\Tests\Doctrine\Functions; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\SqlWalker; use PHPUnit\Framework\TestCase; abstract class AbstractDoctrineFunctionTestCase extends TestCase { protected function createSqlWalker(AbstractPlatform $platform, string $serverVersion = '11.0.0-MariaDB'): SqlWalker { $connection = $this->createMock(Connection::class); $connection->method('getDatabasePlatform')->willReturn($platform); $connection->method('getServerVersion')->willReturn($serverVersion); $sqlWalker = $this->getMockBuilder(SqlWalker::class) ->disableOriginalConstructor() ->onlyMethods(['getConnection']) ->getMock(); $sqlWalker->method('getConnection')->willReturn($connection); return $sqlWalker; } protected function createNode(string $sql): Node { $node = $this->createMock(Node::class); $node->method('dispatch')->willReturn($sql); return $node; } protected function setObjectProperty(object $object, string $property, mixed $value): void { $reflection = new \ReflectionProperty($object, $property); $reflection->setValue($object, $value); } protected function setStaticProperty(string $class, string $property, mixed $value): void { $reflection = new \ReflectionProperty($class, $property); $reflection->setValue(null, $value); } }