129 lines
3.6 KiB
PHP
129 lines
3.6 KiB
PHP
<?php
|
|
use PHPUnit\Framework\TestCase;
|
|
/**
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-02-13 at 00:41:50.
|
|
* @backupGlobals enabled
|
|
*/
|
|
class Acc_OperationTest extends TestCase
|
|
{
|
|
/**
|
|
* @var Acc_OperationTest
|
|
*/
|
|
protected $object;
|
|
|
|
/**
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
* This method is called before a test is executed.
|
|
*/
|
|
protected function setUp():void
|
|
{
|
|
include 'global.php';
|
|
global $g_connection,$g_user;
|
|
$this->object = new Acc_Operation($g_connection);
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Tears down the fixture, for example, closes a network connection.
|
|
* This method is called after a test is executed.
|
|
*/
|
|
protected function tearDown():void
|
|
{
|
|
}
|
|
|
|
/**
|
|
*@covers Acc_Operation::seek_group
|
|
*/
|
|
public function testSeek_group()
|
|
{
|
|
$this->object->jr_id=6;
|
|
$r=$this->object->seek_group();
|
|
$this->assertEquals(8,$r);
|
|
}
|
|
/**
|
|
* @covers Acc_Operation::set_id
|
|
*
|
|
*/
|
|
public function testSet_id()
|
|
{
|
|
$this->object->set_id(1000);
|
|
$this->assertEquals(1000,$this->object->jr_id);
|
|
try {
|
|
$this->object->set_id('AB');
|
|
} catch (Exception $e) {
|
|
$this->assertEquals($e->getMessage(),'Acc_Operation::set_id , id invalide ');
|
|
}
|
|
}
|
|
/**
|
|
* @covers Acc_Operation::set_paid
|
|
*/
|
|
function testSet_Paid()
|
|
{
|
|
$row=$this->object->db->get_array('select * from jrn where jr_rapt <> $1 limit 1',array('paid'));
|
|
if ( ! $row ) {
|
|
echo "Aucune ligne trouvée";
|
|
$this->assertTrue(TRUE);
|
|
} else {
|
|
$this->object->jr_id=$row[0]['jr_id'];
|
|
$this->object->set_paid();
|
|
$status=$this->object->db->get_value ('select jr_rapt from jrn where jr_id=$1',array($row[0]['jr_id']));
|
|
$this->assertEquals($status,'paid');
|
|
}
|
|
|
|
}
|
|
/**
|
|
* @covers Acc_Operation::get_amount
|
|
*/
|
|
function testGet_Amount()
|
|
{
|
|
$row=$this->object->db->get_array('select * from jrn limit 1');
|
|
if ( ! $row ) {
|
|
echo "Aucune ligne trouvée";
|
|
$this->assertTrue(FALSE);
|
|
} else {
|
|
$this->object->jr_id=$row[0]['jr_id'];
|
|
$amount=$this->object->get_amount();
|
|
$this->assertEquals($amount,$row[0]['jr_montant']);
|
|
}
|
|
|
|
}
|
|
/**
|
|
* provide data for testAmount_Currency
|
|
* @return type
|
|
*/
|
|
public function data_amount_currency()
|
|
{
|
|
return array(
|
|
/* sale */
|
|
array(659,146.95),
|
|
array(657,146.95),
|
|
array(649,0),
|
|
/* purchase*/
|
|
array(680,680.33),
|
|
array(683,834.91),
|
|
array(526,0),
|
|
/* financial */
|
|
array(658,146.95),
|
|
array(684,200),
|
|
array(685,300),
|
|
/* misc operation */
|
|
array(686,25.25),
|
|
|
|
);
|
|
}
|
|
/**
|
|
* @testdox acc_operation::get_amount_currency - sale-purchase-fin-misc
|
|
* @covers Acc_Operation::get_amount_currency
|
|
* @dataProvider data_amount_currency
|
|
*/
|
|
function testGet_AmountCurrency($p_jrn_id,$p_amount_currency)
|
|
{
|
|
global $g_connection;
|
|
$acc_operation=new Acc_Detail($g_connection,$p_jrn_id);
|
|
$acc_operation->get();
|
|
$acc_operation->get_quant();
|
|
$actual_amount=round($acc_operation->get_currency_amount(),2);
|
|
$this->assertEquals($p_amount_currency,$actual_amount,"currency values doesn't match for $p_jrn_id");
|
|
}
|
|
}
|