Skip to content

Trying to set invalid time_zone property for Postgresql #4

@arunahk

Description

@arunahk

Creating a connection to postgres database fails due to wrong parameter setup.
*** https://github.com/natterbox/Codeception-MultiDb/blame/master/src/Codeception/Extension/MultiDb.php

    /**
     * @see MultiDb::amConnectedToDb
     *
     * @param string $connector
     *
     * @throws ModuleException
     * @return \Codeception\Lib\Driver\Db
     */
    private function getDriver($connector)
    {
        if (!(isset($this->drivers[$connector]) && is_object($this->drivers[$connector]))) {
            if (!isset($this->config['connectors'][$connector])) {
                throw new ModuleException(
                    __CLASS__,
                    "The specified connector, {$connector}, does not exist in the configuration"
                );
            }
            $config = $this->config['connectors'][$connector];

            try {
                $this->drivers[$connector] = Driver::create($config['dsn'], $config['user'], $config['password']);
                $this->executeSqlAgainstDriver(
                    $this->drivers[$connector]->getDbh(),
                    "SET time_zone = '{$this->timezone}'" 
                );
            } catch (\PDOException $e) {
                throw new ModuleException(
                    __CLASS__,
                    $e->getMessage() . ' while creating PDO connection ['.get_class($e).']'
                );
            } catch (\Exception $e) {
                throw new ModuleException(
                    __CLASS__,
                    $e->getMessage() . ' while creating PDO connection ['.get_class($e).']'
                );
            }
        }

        return $this->drivers[$connector];
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions