Exemplo n.º 1
0
 /**
  * Returns an instance of this class.
  */
 public static function getInstance()
 {
     if (is_null(ezcTestSettings::$instance)) {
         ezcTestSettings::$instance = new ezcTestSettings();
     }
     return ezcTestSettings::$instance;
 }
Exemplo n.º 2
0
 protected function setUp()
 {
     try {
         $dbparams = ezcTestSettings::getInstance()->db->dsn;
         MyDB::setParams($dbparams);
         $this->db = MyDB::create();
     } catch (Exception $e) {
         $this->markTestSkipped();
     }
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 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");
     }
 }