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">
<testsuites>
<testsuite name="icehrm">
<directory suffix="Test.php">./test/</directory>
<testsuite name="Unit">
<exclude>
<file>/test/TestTemplate.php</file>
</exclude>
<directory suffix=".php">./test/unit</directory>
</testsuite>
<testsuite name="Integration">
<exclude>
<file>/test/TestTemplate.php</file>
</exclude>
<directory suffix=".php">./test/integration</directory>
</testsuite>
</testsuites>
<logging>
@@ -20,13 +29,17 @@
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./build/app</directory>
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./composer</directory>
<directory suffix=".php">./lib</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">./admin</directory>
<directory suffix=".php">./modules</directory>
<directory suffix=".php">./robo</directory>
<directory suffix=".php">./migrations</directory>
</exclude>
</whitelist>
</filter>

View File

@@ -22,10 +22,8 @@ class LogManager
self::$me->log = new Logger(APP_NAME);
if (is_writable(ini_get('error_log'))) {
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));
} else {
self::$me->log->pushHandler(new StreamHandler('/tmp/icehrm.log', LOG_LEVEL));
}
}
return self::$me;

View File

@@ -1,6 +1,4 @@
<?php
include dirname(__FILE__).'/test.includes.php';
class TestTemplate extends PHPUnit_Framework_TestCase{
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(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;

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

View File

@@ -7,9 +7,9 @@ if(!defined('TEST_BASE_PATH')){
//Mock Session class
if (!class_exists('SessionUtils')) {
class SessionUtils{
public static $data;
public static function getSessionObject($name){
if(empty(self::$data)){
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");
}
}