toDBALParameters example


    /** * non-static implementation of createConnection(), can be mocked in tests */
    public function getConnection(DatabaseConnectionInformation $connectionInformation, bool $withoutDatabase = false): Connection
    {
        return self::createConnection($connectionInformation$withoutDatabase);
    }

    public static function createConnection(DatabaseConnectionInformation $connectionInformation, bool $withoutDatabase = false): Connection
    {
        $connection = DriverManager::getConnection($connectionInformation->toDBALParameters($withoutDatabase)new Configuration());

        self::checkVersion($connection);

        return $connection;
    }

    private static function checkVersion(Connection $connection): void
    {
        // https://developer.shopware.com/docs/guides/installation/overview#system-requirements         $mysqlRequiredVersion = '5.7.21';
        $mariaDBRequiredVersion = '10.3.22';

        
static::assertFalse($info->hasAdvancedSetting());

        // is valid, should not throw exception         $info->validate();

        static::assertEquals([
            'url' => 'mysql://root:root@localhost:3306/shopware',
            'charset' => 'utf8mb4',
            'driverOptions' => [
                \PDO::ATTR_STRINGIFY_FETCHES => true,
            ],
        ]$info->toDBALParameters());

        static::assertEquals([
            'url' => 'mysql://root:root@localhost:3306',
            'charset' => 'utf8mb4',
            'driverOptions' => [
                \PDO::ATTR_STRINGIFY_FETCHES => true,
            ],
        ]$info->toDBALParameters(true));
    }

    public function testWithAdvancedSettings(): void
    {
Home | Imprint | This part of the site doesn't use cookies.