24 require_once(dirname(__FILE__) .
'/../common-pkg.php');
25 require_once(dirname(__FILE__) .
'/../common-db.php');
33 public $DB_COMMAND =
"";
37 protected function setUp()
39 if (!is_callable(
'pg_connect')) {
40 $this->markTestSkipped(
"php-psql not found");
45 print
"Starting unit test for common-pkg.php\n";
47 $DB_COMMAND = dirname(dirname(dirname(dirname(__FILE__)))).
"/testing/db/createTestDB.php";
48 exec($DB_COMMAND, $dbout, $rc);
49 preg_match(
"/(\d+)/", $dbout[0], $matches);
50 $test_name = $matches[1];
52 $DB_NAME =
"fosstest".$test_name;
53 #$sysconfig = './sysconfigDirTest'; 62 print
"test function GetPkgMimetypes()\n";
65 #prepare database testdata 66 $mimeType =
"application/x-rpm";
68 $sql =
"DELETE FROM mimetype where mimetype_name in ('$mimeType');";
69 $result = pg_query($PG_CONN, $sql);
70 pg_free_result($result);
72 $sql =
"INSERT INTO mimetype(mimetype_pk, mimetype_name) VALUES(10000, '$mimeType');";
73 $result = pg_query($PG_CONN, $sql);
74 pg_free_result($result);
76 #begin test GetPkgMimetypes() 77 $sql =
"select * from mimetype where 78 mimetype_name='application/x-rpm'";
79 $result = pg_query($PG_CONN, $sql);
81 $row = pg_fetch_assoc($result);
82 $expected = $row[
'mimetype_pk'];
83 pg_free_result($result);
86 $this->assertContains($expected, $result);
89 $sql =
"DELETE FROM mimetype where mimetype_name in ('$mimeType');";
90 $result = pg_query($PG_CONN, $sql);
91 pg_free_result($result);
99 if (!is_callable(
'pg_connect')) {
107 exec(
"$DB_COMMAND -d $DB_NAME");
GetPkgMimetypes()
Get package mimetype.
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
test_GetPkgMimetypes()
test for GetPkgMimetypes()
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.