DoctrineDbalPostgreSqlStore example

case str_starts_with($connection, 'mysql:'):
            case str_starts_with($connection, 'oci:'):
            case str_starts_with($connection, 'pgsql:'):
            case str_starts_with($connection, 'sqlsrv:'):
            case str_starts_with($connection, 'sqlite:'):
                return new PdoStore($connection);

            case str_starts_with($connection, 'pgsql+advisory://'):
            case str_starts_with($connection, 'postgres+advisory://'):
            case str_starts_with($connection, 'postgresql+advisory://'):
                return new DoctrineDbalPostgreSqlStore($connection);

            case str_starts_with($connection, 'pgsql+advisory:'):
                return new PostgreSqlStore(preg_replace('/^([^:+]+)\+advisory/', '$1', $connection));

            case str_starts_with($connection, 'zookeeper://'):
                return new ZookeeperStore(ZookeeperStore::createConnection($connection));

            case 'in-memory' === $connection:
                return new InMemoryStore();
        }

        
if (!getenv('POSTGRES_HOST')) {
            $this->markTestSkipped('Missing POSTGRES_HOST env variable');
        }

        return self::getDbalConnection('pdo-pgsql://postgres:password@'.getenv('POSTGRES_HOST'));
    }

    public function getStore(): PersistingStoreInterface
    {
        $conn = $this->createPostgreSqlConnection();

        return new DoctrineDbalPostgreSqlStore($conn);
    }

    /** * @requires extension pdo_sqlite * * @dataProvider getInvalidDrivers */
    public function testInvalidDriver($connOrDsn)
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('The adapter "Symfony\Component\Lock\Store\DoctrineDbalPostgreSqlStore" does not support');

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