Restructuring unit/integration tests
This commit is contained in:
21
phpunit.xml
21
phpunit.xml
@@ -6,8 +6,17 @@
|
|||||||
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 name="Integration">
|
||||||
|
<exclude>
|
||||||
|
<file>/test/TestTemplate.php</file>
|
||||||
|
</exclude>
|
||||||
|
<directory suffix=".php">./test/integration</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
22
test/unit/LanguageManagerUnit.php
Normal file
22
test/unit/LanguageManagerUnit.php
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user