diff --git a/unit-test/global.php b/unit-test/global.php index 129616692..a01c85add 100644 --- a/unit-test/global.php +++ b/unit-test/global.php @@ -33,3 +33,27 @@ $_SESSION['g_user']='admin'; $_SESSION['g_pass']='phpcompta'; $_SESSION['g_pagesize']='50'; $g_user=new User($g_connection); + +if ( !function_exists("phpunit_page_start")) +{ +function phpunit_page_start() +{ + $noalyss_home=NOALYSS_HOME; + echo << + + PRINTJRN NOALYSS + + + + + + + + + + +
+EOF; +} +} \ No newline at end of file diff --git a/unit-test/include/class/acc_ledger_history_financialTest.class.php b/unit-test/include/class/acc_ledger_history_financialTest.class.php new file mode 100644 index 000000000..1d7d754ab --- /dev/null +++ b/unit-test/include/class/acc_ledger_history_financialTest.class.php @@ -0,0 +1,96 @@ + + +/** + * @file + * @brief concerne acc_ledger_history_financialTest.class + */ +class Acc_Ledger_History_FinancialTest extends TestCase +{ + + /** + * @var + */ + protected $object; + + /** + * 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'; + global $g_connection; + $this->object=new Acc_Ledger_History_Financial($g_connection, [1], 92, 131, 'E'); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + + } + + private function save_file($p_name, $content) + { + $hFile=fopen(__DIR__."/file/".$p_name,"w+"); + fwrite($hFile, $content); + fclose($hFile); + } + + function testGet__row() + { + $this->object->get_row(); + $this->assertEquals(1, count($this->object->get_data())); + } + + //@covers Acc_Ledger_History_Financial::export_html + //@covers Acc_Ledger_History_Financial::export_accounting_html + function testExport_Html() + { + //- Listing + $name="acc_ledger_history_export_listing.html"; + $this->object->set_m_mode("L"); + ob_start(); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + + //- Listing + $name="acc_ledger_history_export_accounting.html"; + $this->object->set_m_mode("E"); + ob_start(); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + + } +} diff --git a/unit-test/include/class/acc_ledger_history_purchaseTest.class.php b/unit-test/include/class/acc_ledger_history_purchaseTest.class.php index d9a88d56e..a54d093d5 100644 --- a/unit-test/include/class/acc_ledger_history_purchaseTest.class.php +++ b/unit-test/include/class/acc_ledger_history_purchaseTest.class.php @@ -52,10 +52,28 @@ class Acc_Ledger_History_PurchaseTest extends TestCase { } + private function save_file($p_name,$content) + { + $hFile=fopen(__DIR__."/file/".$p_name,"w+"); + fwrite($hFile, $content); + fclose($hFile); + } + //@covers Acc_Ledger_History_Financial::get_row , Acc_Ledger_History_Financial::get_data function testGet_Row() { $this->object->get_row(); $this->assertSame(count($this->object->get_data()),2); } + //@covers Acc_Ledger_History_Financial::export_oneline_html + function testExport_Oneline_Html() + { + ob_start(); + $this->object->export_accounting_html(); + $content=ob_get_flush(); + $this->save_file("acc_ledger_history_purchase_oneline.html",$content); + $this->assertFileExists(__DIR__."/file/"."acc_ledger_history_purchase_oneline.html"); + + } + }