/** * */ public function setUp() { $this->oConfig = Configuration::getInstance(); $this->oConfig->read(__DIR__ . self::MYSQL_TEST_CONFIG); $oFactory = new DriverFactory(); $this->object = $oFactory->getInstance('MySql'); }
/** * 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.'); } }
/** * 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); }