15 require_once(dirname(__FILE__, 2) .
'/common-cache.php');
16 require_once(dirname(__FILE__, 2) .
'/common-db.php');
29 public $upload_pk = 0;
30 public $uploadtree_pk = 0;
31 public $UserCacheStat = 0;
36 protected function setUp() : void
38 $this->testDb =
new TestPgDb(
"fosslibtest");
39 $tables = array(
'upload',
'uploadtree',
'report_cache');
40 $this->testDb->createPlainTables($tables);
41 $sequences = array(
'upload_upload_pk_seq',
'uploadtree_uploadtree_pk_seq',
'report_cache_report_cache_pk_seq');
42 $this->testDb->createSequences($sequences);
43 $this->testDb->createConstraints([
'upload_pkey_idx',
'ufile_rel_pkey',
'report_cache_pkey',
'report_cache_report_cache_key_key']);
44 $this->testDb->alterTables($tables);
47 global $uploadtree_pk;
48 global $UserCacheStat;
50 $this->
dbManager = $this->testDb->getDbManager();
59 global $uploadtree_pk;
63 $sql =
"INSERT INTO upload (upload_filename,upload_mode,upload_ts) VALUES ('cache_test',40,now());";
64 $result = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"insert.upload");
67 $sql =
"SELECT upload_pk from upload where upload_filename = 'cache_test';";
68 $row = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"upload.select");
69 $upload_pk= $row[
'upload_pk'];
72 $sql=
"INSERT INTO uploadtree (upload_fk) VALUES($upload_pk)";
73 $result = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"insert.uploadtree");
76 $sql =
"SELECT uploadtree_pk from uploadtree where upload_fk = $upload_pk;";
77 $row = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"uploadtree.select");
78 $uploadtree_pk= $row[
'uploadtree_pk'];
87 global $uploadtree_pk;
91 $CacheKey =
"?mod=nomoslicense&upload=$upload_pk&item=$uploadtree_pk&show=detail";
92 $CacheValue =
"no data";
95 $sql =
"SELECT report_cache_value from report_cache where report_cache_uploadfk = $upload_pk;";
96 $row = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"select.report_cache");
97 $value = $row[
'report_cache_value'];
98 $this->assertEquals($CacheValue, $value);
108 global $uploadtree_pk;
112 $CacheKey =
"?mod=nomoslicense&item=$uploadtree_pk&show=detail";
113 $CacheValue =
"no data";
116 $sql =
"SELECT report_cache_value from report_cache where report_cache_uploadfk = $upload_pk;";
117 $row = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"select.report_cache");
118 $value = $row[
'report_cache_value'];
119 $this->assertEquals($CacheValue, $value);
129 global $uploadtree_pk;
130 global $UserCacheStat;
135 $CacheKey =
"?mod=nomoslicense&upload=$upload_pk&item=$uploadtree_pk&show=detail";
136 $CacheValue =
"no data";
141 $this->assertEquals($CacheValue, $value);
153 $sql =
"DELETE from report_cache where report_cache_uploadfk = $upload_pk;";
154 $result = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"delete.report_cache");
156 $sql=
"DELETE from uploadtree where upload_fk = $upload_pk;";
157 $result = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"delete.uploadtree");
159 $sql =
"DELETE from upload where upload_pk = $upload_pk;";
160 $result = $this->
dbManager->getSingleRow($sql, [], __METHOD__ .
"delete.upload");
168 if (!is_callable(
'pg_connect')) {
171 $this->testDb->fullDestruct();
172 $this->testDb =
null;
resetEnv4ReportCachePut()
reset enviroment after testing ReportCachePut
preparation4ReportCachePut()
preparation for testing ReportCachePut
testReportCachePut_upload_id_not_null()
test for ReportCachePut upload id is in $CacheKey
testReportCacheGet()
test for ReportCacheGet
testReportCachePut_upload_id_null()
test for ReportCachePut upload id is not in $CacheKey
ReportCacheGet($CacheKey)
This function is used by Output() to see if the requested report is in the report cache.
ReportCachePut($CacheKey, $CacheValue)
This function is used to write a record to the report cache. If the record already exists,...
fo_dbManager * dbManager
fo_dbManager object