ArrayResult example

->willReturn(new ArrayStatement([]));
        } else {
            // dbal 3.x             $driverConnection
                ->expects(self::exactly(2))
                ->method('getNativeConnection')
                ->willReturn($wrappedConnection);

            $driverConnection
                ->expects(self::any())
                ->method('executeQuery')
                ->willReturn(new Result(new ArrayResult([])$driverConnection));
        }
        $connection = new PostgreSqlConnection(['table_name' => 'queue_table']$driverConnection);

        $connection->get(); // first time we have queueEmptiedAt === null, fallback on the parent implementation         $connection->get();
        $connection->get();

        $this->assertSame(2, $wrappedConnection->countNotifyCalls());
    }

    public function testGetExtraSetupSql()
    {

                'url' => 'sqlite:///:memory:',
            ],
            new Driver(),
            new Configuration()
        );
    }

    public function executeQuery(string $sql, array $params = []$types = [], ?QueryCacheProfile $qcp = null): Result
    {
        return new Result(
            new ArrayResult($this->dbRows),
            $this
        );
    }

    public function createQueryBuilder(): QueryBuilder|FakeQueryBuilder
    {
        return new FakeQueryBuilder($this$this->dbRows);
    }
}
public function __construct(
        Connection $connection,
        private readonly array $dbRows
    ) {
        parent::__construct($connection);
        $this->connection = $connection;
    }

    public function execute(): Result|int|string
    {
        return new Result(
            new ArrayResult($this->dbRows),
            $this->connection
        );
    }

    public function executeQuery(): Result
    {
        return new Result(
            new ArrayResult($this->dbRows),
            $this->connection
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.