asDsn example

static::assertSame('shopware', $info->getDatabaseName());

        static::expectException(DatabaseSetupException::class);
        $info->validate();
    }

    /** * @dataProvider dsnProvider */
    public function testAsDsn(DatabaseConnectionInformation $connectionInformation, bool $withoutDB, string $expectedDsn): void
    {
        $dsn = $connectionInformation->asDsn($withoutDB);

        static::assertSame($expectedDsn$dsn);
    }

    public static function dsnProvider(): \Generator
    {
        yield 'with database' => [
            (new DatabaseConnectionInformation())->assign([
                'hostname' => 'localhost',
                'port' => 3306,
                'username' => 'root',
                
'host' => 'localhost',
            'schema' => 'https',
            'basePath' => '/shop',
            'blueGreenDeployment' => true,
        ]);

        static::assertFileExists(__DIR__ . '/_fixtures/.env');
        static::assertFileExists(__DIR__ . '/_fixtures/.env.local');
        $content = \file_get_contents(__DIR__ . '/_fixtures/.env.local');
        static::assertIsString($content);
        static::assertStringNotContainsString('DATABASE_SSL_CA', $content);
        static::assertStringContainsString('DATABASE_URL=' . $info->asDsn()$content);
        static::assertStringContainsString('APP_URL=https://localhost/shop', $content);
        static::assertStringContainsString('BLUE_GREEN_DEPLOYMENT=1', $content);
        static::assertStringContainsString('INSTANCE_ID=1234567890', $content);

        static::assertFileExists(__DIR__ . '/_fixtures/public/.htaccess');
        static::assertFileEquals(__DIR__ . '/_fixtures/public/.htaccess.dist', __DIR__ . '/_fixtures/public/.htaccess');
    }

    public function testWriteWithSSLConfig(): void
    {
        $idGenerator = $this->createMock(UniqueIdGenerator::class);
        
$uniqueId,
                ],
                self::FLEX_DOTENV
            );
            file_put_contents($this->projectDir . '/.env', $template);
        }

        $newEnv = [];

        $newEnv[] = 'APP_SECRET=' . $secret;
        $newEnv[] = 'APP_URL=' . $shop['schema'] . '://' . $shop['host'] . $shop['basePath'];
        $newEnv[] = 'DATABASE_URL=' . $info->asDsn();

        if (!empty($info->getSslCaPath())) {
            $newEnv[] = 'DATABASE_SSL_CA=' . $info->getSslCaPath();
        }

        if (!empty($info->getSslCertPath())) {
            $newEnv[] = 'DATABASE_SSL_CERT=' . $info->getSslCertPath();
        }

        if (!empty($info->getSslCertKeyPath())) {
            $newEnv[] = 'DATABASE_SSL_KEY=' . $info->getSslCertKeyPath();
        }
'sslCertKeyPath' => EnvironmentHelper::getVariable('DATABASE_SSL_KEY'),
            'sslDontVerifyServerCert' => EnvironmentHelper::getVariable('DATABASE_SSL_DONT_VERIFY_SERVER_CERT'),
        ]);
    }

    /** * @return array{url: string, charset: string, driverOptions: array<int, string|bool>} */
    public function toDBALParameters(bool $withoutDatabaseName = false): array
    {
        $parameters = [
            'url' => $this->asDsn($withoutDatabaseName),
            'charset' => 'utf8mb4',
            'driverOptions' => [
                \PDO::ATTR_STRINGIFY_FETCHES => true,
            ],
        ];

        if ($this->sslCaPath) {
            $parameters['driverOptions'][\PDO::MYSQL_ATTR_SSL_CA] = $this->sslCaPath;
        }

        if ($this->sslCertPath) {
            
Home | Imprint | This part of the site doesn't use cookies.