Ejemplo n.º 1
0
 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");
     }
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function it_returns_db_host()
 {
     $randomDbHost = "random-db-host";
     putenv("DB_HOST={$randomDbHost}");
     $this->assertSame($randomDbHost, App::getDbHost());
 }