/** * Returns an instance of this class. */ public static function getInstance() { if (is_null(ezcTestSettings::$instance)) { ezcTestSettings::$instance = new ezcTestSettings(); } return ezcTestSettings::$instance; }
protected function setUp() { try { $dbparams = ezcTestSettings::getInstance()->db->dsn; MyDB::setParams($dbparams); $this->db = MyDB::create(); } catch (Exception $e) { $this->markTestSkipped(); } }
public function testInvalidFromDb() { $type = ezcTestSettings::getInstance()->db->phptype; $dsn = ezcTestSettings::getInstance()->db->dsn; if ($dsn === null || $type === null || $type === 'sqlite') { $this->markTestSkipped("DSN or database type not set"); } // manipulate DSN $dsn = preg_replace("@/[^/]*\$@", "/db_not_exists", $dsn); // setup this test $destination = $this->createTempDir("PersObjDatSchem"); // real test $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f "{$type}" -s "{$dsn}" "{$destination}"`; $this->assertEquals(1, preg_match('(Error\\sreading\\sschema)s', $res), 'No success error found in generated output.'); $this->removeTempDir(); }
protected function handleDsn($value) { try { $ts = ezcTestSettings::getInstance(); $settings = ezcDbFactory::parseDSN($value); $ts->db->value = $value; try { $ts->setDatabaseSettings($settings); $db = ezcDbFactory::create($settings); ezcDbInstance::set($db); } catch (ezcDbException $e) { die($e->getMessage()); } } catch (Exception $e) { die("Database initialization error: {$e->getMessage()}\n"); } }