/**
  * Tests getting the DB configuration.
  *
  * @covers empire\framework\app\configuration\ConfigurationManager::getDbConfiguration
  */
 public function testGetDbConfiguration()
 {
     $configuration = $this->instance->getDbConfiguration();
     $this->assertInstanceOf('empire\\framework\\configuration\\Configuration', $configuration);
     $this->assertSame('kamis', $configuration->defaultDb);
 }
示例#2
0
 /**
  * Returns the database object.
  *
  * This object is instantiated with the default database, <code>DB::switchDatabase()</code> can
  * be used to switch the database using the same connection.
  *
  * If modules need a different database connection, they need to create it manually using the
  * <code>DB</code> class.
  *
  * @return DB the database object
  */
 public function getDB()
 {
     if ($this->db === null) {
         $dbConfiguration = $this->configurationManager->getDbConfiguration();
         $connection = new DBConnection($dbConfiguration->driver, $dbConfiguration->host, $dbConfiguration->port, $dbConfiguration->defaultDb, $dbConfiguration->user, $dbConfiguration->pass, $dbConfiguration->options, $dbConfiguration->prefix);
         $this->db = new DB($connection);
     }
     return $this->db;
 }