Restructuring unit/integration tests

This commit is contained in:
gamonoid
2017-09-05 08:07:33 +02:00
parent a0aacba4f5
commit d793d3575b
9 changed files with 56 additions and 73605 deletions

73563
phpunit

File diff suppressed because one or more lines are too long

View File

@@ -6,9 +6,18 @@
verbose="true"> verbose="true">
<testsuites> <testsuites>
<testsuite name="icehrm"> <testsuite name="Unit">
<directory suffix="Test.php">./test/</directory> <exclude>
<file>/test/TestTemplate.php</file>
</exclude>
<directory suffix=".php">./test/unit</directory>
</testsuite> </testsuite>
<testsuite name="Integration">
<exclude>
<file>/test/TestTemplate.php</file>
</exclude>
<directory suffix=".php">./test/integration</directory>
</testsuite>
</testsuites> </testsuites>
<logging> <logging>
@@ -20,13 +29,17 @@
<filter> <filter>
<whitelist addUncoveredFilesFromWhitelist="true"> <whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./build/app</directory> <directory suffix=".php">./src</directory>
<exclude> <exclude>
<directory suffix=".php">./composer</directory> <directory suffix=".php">./composer</directory>
<directory suffix=".php">./lib</directory> <directory suffix=".php">./lib</directory>
<directory suffix=".php">./lib/Mail</directory> <directory suffix=".php">./lib/Mail</directory>
<directory suffix=".php">./adodb512</directory> <directory suffix=".php">./lib/composer</directory>
<directory suffix=".php">./js</directory> <directory suffix=".php">./js</directory>
<directory suffix=".php">./admin</directory>
<directory suffix=".php">./modules</directory>
<directory suffix=".php">./robo</directory>
<directory suffix=".php">./migrations</directory>
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>

View File

@@ -22,10 +22,8 @@ class LogManager
self::$me->log = new Logger(APP_NAME); self::$me->log = new Logger(APP_NAME);
if (is_writable(ini_get('error_log'))) { if (is_writable(ini_get('error_log'))) {
self::$me->log->pushHandler(new StreamHandler(ini_get('error_log'), LOG_LEVEL)); self::$me->log->pushHandler(new StreamHandler(ini_get('error_log'), LOG_LEVEL));
} else if(is_writable(iCLIENT_BASE_PATH.'data/app.log')){ } else if(is_writable(CLIENT_BASE_PATH.'data/app.log')){
self::$me->log->pushHandler(new StreamHandler(CLIENT_BASE_PATH.'data/app.log', LOG_LEVEL)); self::$me->log->pushHandler(new StreamHandler(CLIENT_BASE_PATH.'data/app.log', LOG_LEVEL));
} else {
self::$me->log->pushHandler(new StreamHandler('/tmp/icehrm.log', LOG_LEVEL));
} }
} }
return self::$me; return self::$me;

View File

@@ -1,6 +1,4 @@
<?php <?php
include dirname(__FILE__).'/test.includes.php';
class TestTemplate extends PHPUnit_Framework_TestCase{ class TestTemplate extends PHPUnit_Framework_TestCase{
protected $usersArray = array(); protected $usersArray = array();

View File

@@ -3,6 +3,7 @@ if(file_exists('/usr/lib/php5/mysql.auth.php')){
include '/usr/lib/php5/mysql.auth.php'; include '/usr/lib/php5/mysql.auth.php';
} }
include(dirname(__FILE__).'/test.config.php'); include(dirname(__FILE__).'/test.config.php');
include(dirname(__FILE__).'/test.includes.php');
$dropDBCommand = 'echo "DROP DATABASE IF EXISTS ' . APP_DB . '"| mysql -u' . MYSQL_ROOT_USER . ' -p' . MYSQL_ROOT_PASS; $dropDBCommand = 'echo "DROP DATABASE IF EXISTS ' . APP_DB . '"| mysql -u' . MYSQL_ROOT_USER . ' -p' . MYSQL_ROOT_PASS;

View File

@@ -1,22 +0,0 @@
<?php
if(!class_exists("TestTemplate")) {
include dirname(__FILE__).'/../TestTemplate.php';
}
class LanguageManagerTest extends TestTemplate{
protected function setUp()
{
parent::setUp();
}
public function testTran(){
$this->assertEquals('cat', \Classes\LanguageManager::tran('cat'));
$this->assertEquals('solid', \Classes\LanguageManager::tran('solid'));
$this->assertEquals('one file', \Classes\LanguageManager::tran('one file'));
$this->assertEquals('2 files', \Classes\LanguageManager::tran('2 files'));
$this->assertEquals('User Logged In now', \Classes\LanguageManager::translateTnrText('User <t>Logged In</t> now'));
}
}

View File

@@ -1,18 +1,19 @@
<?php <?php
namespace Test\Integration;
if(!class_exists("TestTemplate")) { use Classes\Approval\ApprovalStatus;
include dirname(__FILE__).'/../TestTemplate.php'; use Employees\Common\Model\Employee;
} use Travel\Common\Model\EmployeeTravelRecord;
class ApprovalStatusTest extends TestTemplate{ class ApprovalStatusIntegration extends \TestTemplate{
var $travelRec = null; var $travelRec = null;
protected function setUp(){ protected function setUp(){
parent::setUp(); parent::setUp();
$emp = new \Employees\Common\Model\Employee(); $emp = new Employee();
$emp->Load("id = ?",array(1)); $emp->Load("id = ?",array(1));
$emp->supervisor = 2; $emp->supervisor = 2;
$emp->indirect_supervisors = json_encode(array(3,4)); $emp->indirect_supervisors = json_encode(array(3,4));
@@ -23,7 +24,7 @@ class ApprovalStatusTest extends TestTemplate{
$this->travelRec = new \Travel\Common\Model\EmployeeTravelRecord(); $this->travelRec = new EmployeeTravelRecord();
$this->travelRec->DB()->execute("delete from EmployeeTravelRecords"); $this->travelRec->DB()->execute("delete from EmployeeTravelRecords");
@@ -46,7 +47,7 @@ class ApprovalStatusTest extends TestTemplate{
public function testInitializeApprovalChain(){ public function testInitializeApprovalChain(){
$id = $this->travelRec->id; $id = $this->travelRec->id;
//$this->initializeObjects(); //$this->initializeObjects();
$as = \Classes\Approval\ApprovalStatus::getInstance(); $as = ApprovalStatus::getInstance();
$as->initializeApprovalChain('EmployeeTravelRecord',$id); $as->initializeApprovalChain('EmployeeTravelRecord',$id);
$status = $as->getAllStatuses('EmployeeTravelRecord',$id); $status = $as->getAllStatuses('EmployeeTravelRecord',$id);
$this->assertEquals(3, count($status)); $this->assertEquals(3, count($status));
@@ -56,7 +57,7 @@ class ApprovalStatusTest extends TestTemplate{
public function testUpdateApprovalStatus(){ public function testUpdateApprovalStatus(){
$id = $this->travelRec->id; $id = $this->travelRec->id;
//$this->initializeObjects(); //$this->initializeObjects();
$as = \Classes\Approval\ApprovalStatus::getInstance(); $as = ApprovalStatus::getInstance();
$as->initializeApprovalChain('EmployeeTravelRecord',$id); $as->initializeApprovalChain('EmployeeTravelRecord',$id);
$resp = $as->updateApprovalStatus('EmployeeTravelRecord',$id,2,1); $resp = $as->updateApprovalStatus('EmployeeTravelRecord',$id,2,1);

View File

@@ -7,9 +7,9 @@ if(!defined('TEST_BASE_PATH')){
//Mock Session class //Mock Session class
if (!class_exists('SessionUtils')) { if (!class_exists('SessionUtils')) {
class SessionUtils{ class SessionUtils{
public static $data; public static $data;
public static function getSessionObject($name){ public static function getSessionObject($name){
if(empty(self::$data)){ if(empty(self::$data)){
self::$data = array(); self::$data = array();
@@ -33,5 +33,8 @@ if (!class_exists('SessionUtils')) {
} }
if (!class_exists('TestTemplate')) {
include(dirname(__FILE__).'/TestTemplate.php');
include(APP_BASE_PATH."/includes.inc.php");
}
include(APP_BASE_PATH."/includes.inc.php");

View File

@@ -0,0 +1,22 @@
<?php
namespace Test\Unit;
use Classes\LanguageManager;
class LanguageManagerUnit extends \TestTemplate{
protected function setUp()
{
parent::setUp();
}
public function testTran(){
$this->assertEquals('cat', LanguageManager::tran('cat'));
$this->assertEquals('solid', LanguageManager::tran('solid'));
$this->assertEquals('one file', LanguageManager::tran('one file'));
$this->assertEquals('2 files', LanguageManager::tran('2 files'));
$this->assertEquals('User Logged In now', LanguageManager::translateTnrText('User <t>Logged In</t> now'));
fwrite(STDOUT, __METHOD__ . " End\n");
}
}