altocompta/unit-test/include/class/acc_ledger_purchaseTest.class.php
2019-11-02 17:34:12 +01:00

191 lines
4.9 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
/**
* Generated by PHPUnit_SkeletonGenerator on 2014-11-08 at 14:20:36.
* @backupGlobals enabled
*/
class Acc_Ledger_PurchaseTest extends TestCase
{
/**
* @var Acc_Ledger_Purchase
*/
protected $object;
/**
* @var array transmitted by _POST
*/
private $array;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
include 'global.php';
$this->object=new Acc_Ledger_Purchase($g_connection, 3);
$this->array=array
(
"gDossier"=>25,
"nb_item"=>1,
"p_jrn"=>3,
"p_jrn_predef"=>3,
"action"=>"use_opd",
"jrn_type"=>"ACH",
"filter"=>"",
"e_date"=>"24.02.2018",
"e_ech"=>"",
"e_client"=>"FOURNI",
"e_pj"=>"ACH6",
"e_pj_suggest"=>"ACH6",
"e_comm"=>"Loyer Appartement",
"e_march0"=>"LOYER",
"e_march0_price"=>658.25,
"e_quant0"=>1,
"htva_march0"=>658.25,
"e_march0_tva_id"=>4,
"e_march0_tva_amount"=>0,
"tva_march0"=>0,
"tvac_march0"=>658.25,
"p_action"=>"ach",
"sa"=>"p",
"e_mp"=>0,
"view_invoice"=>"Enregistrer",
);
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers Acc_Ledger_Purchase::verify
*/
public function testVerify()
{
$this->object->verify_operation($this->array);
$this->assertTrue(TRUE);
// Test date
try
{
$array=$this->array;
$array['e_date']="g";
$this->object->verify_operation($array);
}
catch (Exception $e)
{
$this->assertEquals(2, $e->getCode());
}
// Test Strict
try
{
$array=$this->array;
$array['e_date']="01.01.2018";
$this->object->verify_operation($array);
}
catch (Exception $e)
{
$this->assertEquals(13, $e->getCode());
}
}
/**
* @covers Acc_Ledger_Purchase::insert
* @todo Implement testInsert().
*/
public function testInsert()
{
global $g_connection;
$array=$this->array;
$array["mt"]="1572704002.1732";
$array["pa_id"]=array(2);
$array["op"]=array(0);
$array["amount_t0"]=658.25;
$array['hplan']=array(array(-1));
$array["val"]=array(array(658.25));
$this->clean_operation();
$this->assertEquals(0,
$g_connection->get_value ("select count(*) from jrn where jr_mt=$1",["1572704002.1732"]));
$this->object->insert($array);
$this->assertEquals(1,
$g_connection->get_value ("select count(*) from jrn where jr_mt=$1",["1572704002.1732"]));
$this->clean_operation();
}
/**
* @covers Acc_Ledger_Purchase::input
* @todo Implement testInput().
*/
public function testInput()
{
$res=$this->object->input();
}
/**
* @covers Acc_Ledger_Purchase::confirm
* @todo Implement testConfirm().
*/
public function testConfirm()
{
$array=$this->array;
$this->object->confirm($array);
}
private function clean_operation()
{
global $g_connection;
$g_connection->exec_sql("delete from jrn where jr_mt=$1", ["1572704002.1732"]);
$g_connection->exec_sql("delete from jrnx where j_grpt not in (select jr_grpt_id from jrn)");
}
/**
* @covers Acc_Ledger_Purchase::extra_info
* @todo Implement testExtra_info().
*/
public function testExtra_info()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Acc_Ledger_Purchase::get_detail_purchase
* @todo Implement testGet_detail_purchase().
*/
public function testGet_detail_purchase()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Acc_Ledger_Purchase::heading_detail_purchase
* @todo Implement testHeading_detail_purchase().
*/
public function testHeading_detail_purchase()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}