Merge pull request #84 from herbertsg/BUG-9180
Bug 9180 Correct display priority in cases lists
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<!-- <filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
@@ -26,5 +26,9 @@
|
||||
<directory>./rbac</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</filter> -->
|
||||
|
||||
<php>
|
||||
<var name="SYS_SYS" value="herbert" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
@@ -12,6 +12,8 @@ if (!defined('__DIR__')) {
|
||||
define('PATH_TRUNK', realpath(__DIR__ . '/../') . PATH_SEP);
|
||||
define('PATH_HOME', PATH_TRUNK . 'workflow' . PATH_SEP);
|
||||
|
||||
define('SYS_SYS', $GLOBALS['SYS_SYS']);
|
||||
|
||||
require PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php';
|
||||
|
||||
set_include_path(
|
||||
@@ -21,3 +23,19 @@ set_include_path(
|
||||
PATH_RBAC_CORE . PATH_SEPARATOR .
|
||||
get_include_path()
|
||||
);
|
||||
|
||||
// perpare propel env.
|
||||
require_once "propel/Propel.php";
|
||||
require_once "creole/Creole.php";
|
||||
|
||||
Propel::init( PATH_CORE . "config/databases.php" );
|
||||
|
||||
//initialize required classes
|
||||
G::LoadClass ('dbtable');
|
||||
G::LoadClass ('system');
|
||||
|
||||
//read memcached configuration
|
||||
$config = System::getSystemConfiguration ('', '', SYS_SYS);
|
||||
define ('MEMCACHED_ENABLED', $config ['memcached']);
|
||||
define ('MEMCACHED_SERVER', $config ['memcached_server']);
|
||||
define ('TIME_ZONE', $config ['time_zone']);
|
||||
@@ -780,7 +780,7 @@ class GTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMySQLSintaxis()
|
||||
{
|
||||
define('DB_ADAPTER', 'mysql');
|
||||
//define('DB_ADAPTER', 'mysql');
|
||||
$this->assertTrue(G::MySQLSintaxis());
|
||||
}
|
||||
|
||||
|
||||
248
tests/unit/workflow/engine/classes/AppSolrTest.php
Normal file
248
tests/unit/workflow/engine/classes/AppSolrTest.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
// require_once PATH_HOME . PATH_SEP . "engine" . PATH_SEP . "classes" .
|
||||
// PATH_SEP . "class.AppSolr.php";
|
||||
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2012-05-30 at 12:36:24.
|
||||
*/
|
||||
class AppSolrTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var AppSolr
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before each test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
// get Solr initialization variables
|
||||
if (($solrConf = System::solrEnv (SYS_SYS)) !== false) {
|
||||
G::LoadClass ('AppSolr');
|
||||
$this->object = new AppSolr ($solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::isSolrEnabled
|
||||
*/
|
||||
public function testIsSolrEnabled()
|
||||
{
|
||||
// display messages with --debug option
|
||||
// print "XXXXXXXXXXXXXXXXXXXXX";
|
||||
$result = $this->object->isSolrEnabled ();
|
||||
$this->assertEquals ($result, true, "Assert error testIsSolrEnabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::reindexAllApplications
|
||||
* executed first to copy all the application records to the search server
|
||||
* @depends testIsSolrEnabled
|
||||
*/
|
||||
public function testReindexAllApplications()
|
||||
{
|
||||
$this->object->reindexAllApplications ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::getCountApplicationsPMOS2
|
||||
*
|
||||
* @depends testReindexAllApplications
|
||||
*/
|
||||
public function testGetCountApplicationsPMOS2()
|
||||
{
|
||||
$result = $this->object->getCountApplicationsPMOS2 ();
|
||||
$this->assertGreaterThan (0, $result, "Assert error testGetCountApplicationsPMOS2");
|
||||
print "Applications count: " . $result . "\n";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers AppSolr::getPagedApplicationUids
|
||||
*
|
||||
* @depends testGetCountApplicationsPMOS2
|
||||
*/
|
||||
public function testGetPagedApplicationUids($totalNumApplications)
|
||||
{
|
||||
$pagesize = 2;
|
||||
|
||||
$aAppUids = $this->object->getPagedApplicationUids(0, $pagesize);
|
||||
|
||||
if($totalNumApplications >= $pagesize){
|
||||
$this->assertCount(2, $aAppUids, 'Error returned paginated list of AppUids');
|
||||
}
|
||||
else{
|
||||
$this->assertGreaterThan(0, $aAppUids, 'No AppUids found');
|
||||
}
|
||||
|
||||
return $aAppUids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::getAppGridData
|
||||
*
|
||||
* @depends testReindexAllApplications
|
||||
*/
|
||||
public function testGetAppGridData()
|
||||
{
|
||||
//$userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $user = null,
|
||||
//$status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = 'APP_CACHE_VIEW.APP_NUMBER', $doCount = false
|
||||
$userUid = '00000000000000000000000000000001'; //admin user
|
||||
$start = 0;
|
||||
$limit = 20;
|
||||
$action = 'todo';
|
||||
$sort = 'APP_NUMBER';
|
||||
$dir = 'ASC';
|
||||
$result = $this->object->getAppGridData ($userUid, $start, $limit, $action, null, null, null, null,
|
||||
null, null, null, null, null, $dir, $sort, false);
|
||||
print_r($result);
|
||||
if(!$result ['success']){
|
||||
$this->assertEmpty($result ['message'], 'The message is only display in not success');
|
||||
}
|
||||
if(!$result ['result']){
|
||||
$this->assertCount(0, $result ['data'], 'Returned data when not success reported');
|
||||
}
|
||||
|
||||
//verify the number of returned rows
|
||||
print 'count results: ' . count($result ['data']);
|
||||
//$this->assertGreaterThan($result ['totalCount'], count($result ['data']), 'The returned records are less than the total');
|
||||
|
||||
|
||||
|
||||
//test all the views
|
||||
$userUid = '00000000000000000000000000000001'; //admin user
|
||||
$start = 0;
|
||||
$limit = 20;
|
||||
$action = 'participated';
|
||||
$sort = 'APP_NUMBER';
|
||||
$dir = 'ASC';
|
||||
$result = $this->object->getAppGridData ($userUid, $start, $limit, $action, null, null, null, null,
|
||||
null, null, null, null, null, $dir, $sort, false);
|
||||
|
||||
|
||||
$userUid = '00000000000000000000000000000001'; //admin user
|
||||
$start = 0;
|
||||
$limit = 20;
|
||||
$action = 'draft';
|
||||
$sort = 'APP_NUMBER';
|
||||
$dir = 'ASC';
|
||||
$result = $this->object->getAppGridData ($userUid, $start, $limit, $action, null, null, null, null,
|
||||
null, null, null, null, null, $dir, $sort, false);
|
||||
|
||||
$userUid = '00000000000000000000000000000001'; //admin user
|
||||
$start = 0;
|
||||
$limit = 20;
|
||||
$action = 'unassigned';
|
||||
$sort = 'APP_NUMBER';
|
||||
$dir = 'ASC';
|
||||
$result = $this->object->getAppGridData ($userUid, $start, $limit, $action, null, null, null, null,
|
||||
null, null, null, null, null, $dir, $sort, false);
|
||||
|
||||
//test search functionality
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::getCasesCount
|
||||
*
|
||||
*/
|
||||
public function testGetCasesCount()
|
||||
{
|
||||
$userUid = '00000000000000000000000000000001';
|
||||
$result = $this->object->getCasesCount($userUid);
|
||||
print_r($result);
|
||||
$this->assertNotEmpty($result, 'Empty array of counters');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::updateApplicationSearchIndex
|
||||
*
|
||||
* @depends testGetPagedApplicationUids
|
||||
*/
|
||||
public function testUpdateApplicationSearchIndex($aAppUids)
|
||||
{
|
||||
|
||||
$this->object->updateApplicationSearchIndex($aAppUids);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::deleteApplicationSearchIndex
|
||||
*
|
||||
* @depends testGetPagedApplicationUids
|
||||
*/
|
||||
public function testDeleteApplicationSearchIndex($aAppUids)
|
||||
{
|
||||
$appUID = $aAppUids[0]['APP_UID'];
|
||||
|
||||
$count = $this->object->getCountApplicationsSearchIndex();
|
||||
$this->object->deleteApplicationSearchIndex($appUID);
|
||||
$count2 = $this->object->getCountApplicationsSearchIndex();
|
||||
|
||||
$this->assertEquals($count, $count2 + 1, 'Error deleting application in search index');
|
||||
|
||||
//leave index as in the beginning
|
||||
$this->object->reindexAllApplications();
|
||||
|
||||
$count3 = $this->object->getCountApplicationsSearchIndex();
|
||||
|
||||
$this->assertEquals($count, $count3, 'Error restoring deleted application in search index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers AppSolr::applicationChangedUpdateSolrQueue
|
||||
*
|
||||
* @depends testGetPagedApplicationUids
|
||||
*/
|
||||
public function testApplicationChangedUpdateSolrQueue($aAppUids)
|
||||
{
|
||||
$appUID = $aAppUids[0]['APP_UID'];
|
||||
|
||||
//mark application for deletion
|
||||
$this->object->applicationChangedUpdateSolrQueue($appUID, 2); //to delete
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers AppSolr::synchronizePendingApplications
|
||||
*
|
||||
* @depends testApplicationChangedUpdateSolrQueue
|
||||
*/
|
||||
public function testSynchronizePendingApplications()
|
||||
{
|
||||
//count number of indexed applications
|
||||
$count = $this->object->getCountApplicationsSearchIndex();
|
||||
|
||||
print "Total applications:" . $count;
|
||||
//delete application marked in previous test
|
||||
$this->object->synchronizePendingApplications();
|
||||
|
||||
$count2 = $this->object->getCountApplicationsSearchIndex();
|
||||
print "Total applications deleted record:" . $count2;
|
||||
|
||||
$this->assertEquals($count, $count2 + 1, 'Error synchronizing applications in search index');
|
||||
|
||||
//leave index as in the beginning
|
||||
$this->object->reindexAllApplications();
|
||||
|
||||
$count3 = $this->object->getCountApplicationsSearchIndex();
|
||||
|
||||
$this->assertEquals($count, $count3, 'Error restoring deleted application in search index');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -193,6 +193,7 @@ class AppSolr
|
||||
|
||||
$swErrorInSearchText = false;
|
||||
$solrQueryResult = null;
|
||||
$aPriorities = array('1'=>'VL', '2'=>'L', '3'=>'N', '4'=>'H', '5'=>'VH');
|
||||
|
||||
$result = array ();
|
||||
$result ['totalCount'] = 0;
|
||||
@@ -492,6 +493,7 @@ class AppSolr
|
||||
$aRow ['PREVIOUS_USR_UID'] = $row ['PREVIOUS_USR_UID'];
|
||||
$aRow ['TAS_UID'] = $row ['TAS_UID'];
|
||||
$aRow ['USR_UID'] = $userUid;
|
||||
$aRow ['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}");
|
||||
|
||||
$rows [] = $aRow;
|
||||
}
|
||||
@@ -957,9 +959,10 @@ class AppSolr
|
||||
return;
|
||||
|
||||
// check if index server is available
|
||||
if (! $this->isSolrEnabled) {
|
||||
if (! $this->_solrIsEnabled) {
|
||||
// store update in table and return
|
||||
$this->applicationChangedUpdateSolrQueue ($appUID ['APP_UID'], 2); // delete
|
||||
return;
|
||||
}
|
||||
|
||||
$idQuery = "APP_UID:" . $appUID;
|
||||
@@ -2002,7 +2005,12 @@ class AppSolr
|
||||
|
||||
foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
|
||||
// call the syncronization function
|
||||
$this->updateApplicationSearchIndex ($oAppSolrQueueEntity->appUid);
|
||||
if($oAppSolrQueueEntity->appUpdated == 1){
|
||||
$this->updateApplicationSearchIndex ($oAppSolrQueueEntity->appUid);
|
||||
}
|
||||
if($oAppSolrQueueEntity->appUpdated == 2){
|
||||
$this->deleteApplicationSearchIndex ($oAppSolrQueueEntity->appUid);
|
||||
}
|
||||
$this->applicationChangedUpdateSolrQueue ($oAppSolrQueueEntity->appUid, 0);
|
||||
}
|
||||
}
|
||||
@@ -2010,7 +2018,7 @@ class AppSolr
|
||||
/**
|
||||
* Get the total number of application records in database
|
||||
*
|
||||
* @return application counter
|
||||
* @return integer application counter
|
||||
*/
|
||||
public function getCountApplicationsPMOS2()
|
||||
{
|
||||
@@ -2023,6 +2031,20 @@ class AppSolr
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of application records in search index
|
||||
*
|
||||
* @return integer application counter
|
||||
*/
|
||||
public function getCountApplicationsSearchIndex()
|
||||
{
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
// execute query
|
||||
$count = $searchIndex->getNumberDocuments ($this->_solrInstance);
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a paginated list of application uids from database.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user