Example #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");
     }
 }
Example #2
0
 /**
  * @test
  */
 public function it_returns_db_port()
 {
     $randomDbPort = "random-db-port";
     putenv("DB_PORT={$randomDbPort}");
     $this->assertSame($randomDbPort, App::getDbPort());
 }