public function __construct() { try { $this->dbConnection = new PDO("mysql:host=" . App::getDbHost() . ";" . "dbname=" . App::getDbName() . ";" . "port=" . App::getDbPort(), App::getDbUsername(), App::getDbPassword()); $this->dbConnection->setAttribute(PDO::ATTR_ERRMODE, App::getPDOErrorMode()); // CHANGE THE ERROR MODE, THROW AN EXCEPTION WHEN AN ERROR IS FOUND $this->dbConnection->exec("SET NAMES 'utf8'"); } catch (PDOException $e) { throw new Exception("Could not connect to the database.\n" . $e->getMessage() . "\n\n"); } }
/** * @test */ public function it_returns_db_password() { $randomDbPassword = "******"; putenv("DB_PASSWORD={$randomDbPassword}"); $this->assertSame($randomDbPassword, App::getDbPassword()); }