Files
luos/tests/unit/workflow/engine/classes/AppSolrTest.php
Herbert Saal Gutierrez 273dff4745 BUG 9180 Correct display priority in cases lists
Code Issue
----------
A number is display in the Priority column in the cases lists instead of the
priority in text.

Solution
--------
Correct display of priority column in cases lists.
The text that describes the priority is display instead of the priority number.
The number is converted to the corresponding text with the help of the function
G::LoadTranslation("ID_PRIORITY_N");
2012-06-18 17:58:14 -04:00

249 lines
7.2 KiB
PHP

<?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');
}
}