24 require_once(dirname(__FILE__) .
'/../common-cache.php');
25 require_once(dirname(__FILE__) .
'/../common-db.php');
33 public $upload_pk = 0;
34 public $uploadtree_pk = 0;
35 public $UserCacheStat = 0;
43 $sysconfig = dirname(__FILE__).
'/sysconfigDirTest';
44 if (!is_callable(
'pg_connect')) {
45 $this->markTestSkipped(
"php-psql not found");
57 global $uploadtree_pk;
61 $sql =
"INSERT INTO upload (upload_filename,upload_mode,upload_ts) VALUES ('cache_test',40,now());";
62 $result = pg_query($PG_CONN, $sql);
64 pg_free_result($result);
67 $sql =
"SELECT upload_pk from upload where upload_filename = 'cache_test';";
68 $result = pg_query($PG_CONN, $sql);
70 $row = pg_fetch_assoc($result);
71 $upload_pk= $row[
'upload_pk'];
72 pg_free_result($result);
75 $sql=
"INSERT INTO uploadtree (upload_fk) VALUES($upload_pk)";
76 $result = pg_query($PG_CONN, $sql);
78 pg_free_result($result);
81 $sql =
"SELECT uploadtree_pk from uploadtree where upload_fk = $upload_pk;";
82 $result = pg_query($PG_CONN, $sql);
84 $row = pg_fetch_assoc($result);
85 $uploadtree_pk= $row[
'uploadtree_pk'];
86 pg_free_result($result);
94 print
"Start unit test for common-cache.php\n";
95 print
"test function ReportCachePut()\n";
98 global $uploadtree_pk;
102 $CacheKey =
"?mod=nomoslicense&upload=$upload_pk&item=$uploadtree_pk&show=detail";
103 $CacheValue =
"no data";
106 $sql =
"SELECT report_cache_value from report_cache where report_cache_uploadfk = $upload_pk;";
107 $result = pg_query($PG_CONN, $sql);
109 $row = pg_fetch_assoc($result);
110 $value = $row[
'report_cache_value'];
111 pg_free_result($result);
112 $this->assertEquals($CacheValue, $value);
121 print
"test function ReportCachePut()\n";
124 global $uploadtree_pk;
128 $CacheKey =
"?mod=nomoslicense&item=$uploadtree_pk&show=detail";
129 $CacheValue =
"no data";
132 $sql =
"SELECT report_cache_value from report_cache where report_cache_uploadfk = $upload_pk;";
133 $result = pg_query($PG_CONN, $sql);
135 $row = pg_fetch_assoc($result);
136 $value = $row[
'report_cache_value'];
137 pg_free_result($result);
138 $this->assertEquals($CacheValue, $value);
147 print
"test function ReportCacheGet()\n";
150 global $uploadtree_pk;
151 global $UserCacheStat;
156 $CacheKey =
"?mod=nomoslicense&upload=$upload_pk&item=$uploadtree_pk&show=detail";
157 $CacheValue =
"no data";
162 $this->assertEquals($CacheValue, $value);
164 print
"unit test for common-cache.php end\n";
176 $sql =
"DELETE from report_cache where report_cache_uploadfk = $upload_pk;";
177 $result = pg_query($PG_CONN, $sql);
179 pg_free_result($result);
181 $sql=
"DELETE from uploadtree where upload_fk = $upload_pk;";
182 $result = pg_query($PG_CONN, $sql);
184 pg_free_result($result);
186 $sql =
"DELETE from upload where upload_pk = $upload_pk;";
187 $result = pg_query($PG_CONN, $sql);
189 pg_free_result($result);
199 if (is_callable(
'pg_close')) {
testReportCachePut_upload_id_null()
test for ReportCachePut upload id is not in $CacheKey
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
ReportCachePut($CacheKey, $CacheValue)
This function is used to write a record to the report cache. If the record already exists...
preparation4ReportCachePut()
preparation for testing ReportCachePut
testReportCachePut_upload_id_not_null()
test for ReportCachePut upload id is in $CacheKey
resetEnv4ReportCachePut()
reset enviroment after testing ReportCachePut
ReportCacheGet($CacheKey)
This function is used by Output() to see if the requested report is in the report cache...
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
testReportCacheGet()
test for ReportCacheGet