Ejemplo n.º 1
0
 /**
  * 
  */
 public function setUp()
 {
     $this->oConfig = Configuration::getInstance();
     $this->oConfig->read(__DIR__ . self::MYSQL_TEST_CONFIG);
     $oFactory = new DriverFactory();
     $this->object = $oFactory->getInstance('MySql');
 }
Ejemplo n.º 2
0
 /**
  * Configures and then returns a data access object returned from a Driver.
  * 
  * @return \PDO
  * @throws DbalException
  */
 public function getDataObject()
 {
     $aConfig = $this->oConfig->get();
     if (isset($aConfig[Configuration::CONNECTION_KEY]) && isset($aConfig[Configuration::CONNECTION_KEY]['driver'])) {
         $oDriver = $this->oDriverFactory->getInstance($aConfig[Configuration::CONNECTION_KEY]['driver']);
         $oPDO = $oDriver->getDataAccessObject($this->oConfig);
         //Configure the error reporting level for PDO.
         $this->setErrorMode($oPDO);
         return $oPDO;
     } else {
         throw DbalException::invalidConfiguration('Cannot find driver in configurations.');
     }
 }
Ejemplo n.º 3
0
 /**
  * Tests instantiation for an invliad driver name.
  * 
  * @expectedException \MiniOrm\DbalException
  */
 public function testGetInvalidInstance()
 {
     $oFactory = new DriverFactory();
     $oDriver = $oFactory->getInstance('FOOBAR');
     $this->assertInstanceOf('\\MiniOrm\\Driver\\MySql', $oDriver);
 }