QueryBuilder example

$this->assertEquals('{"message":"Hi again"}', $doctrineEnvelopes[1]['body']);
        $this->assertEquals(['type' => DummyMessage::class]$doctrineEnvelopes[1]['headers']);
    }

    /** * @dataProvider providePlatformSql */
    public function testGeneratedSql(AbstractPlatform $platform, string $expectedSql)
    {
        $driverConnection = $this->createMock(DBALConnection::class);
        $driverConnection->method('getDatabasePlatform')->willReturn($platform);
        $driverConnection->method('createQueryBuilder')->willReturnCallback(fn () => new QueryBuilder($driverConnection));

        if (class_exists(Result::class)) {
            $result = $this->createMock(Result::class);
            $result->method('fetchAssociative')->willReturn(false);
        } else {
            $result = $this->createMock(ResultStatement::class);
            $result->method('fetch')->willReturn(false);
        }

        $driverConnection->expects($this->once())->method('beginTransaction');
        $driverConnection
            
$driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);
        $driverConnection->method('executeStatement')->willReturn(1);

        $driverConnection
            ->expects(self::any())
            ->method('getDatabasePlatform')
            ->willReturn(new PostgreSQLPlatform());

        $driverConnection
            ->expects(self::any())
            ->method('createQueryBuilder')
            ->willReturn(new QueryBuilder($driverConnection));

        $wrappedConnection = new class() {
            private int $notifyCalls = 0;

            public function pgsqlGetNotify()
            {
                ++$this->notifyCalls;

                return false;
            }

            
Home | Imprint | This part of the site doesn't use cookies.