diff --git a/unit-test/include/class/acc_ledger_history_genericTest.class.php b/unit-test/include/class/acc_ledger_history_genericTest.class.php new file mode 100644 index 000000000..fa84e9e61 --- /dev/null +++ b/unit-test/include/class/acc_ledger_history_genericTest.class.php @@ -0,0 +1,117 @@ + + +/** + * @file + * @brief concerne acc_ledger_history_generic.class + */ +class Acc_Ledger_History_GenericTest 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_generic($g_connection, [2], 92, 131, 'L'); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + + } + + function testGet_row() + { + $this->object->get_row(); + $this->assertSame(count($this->object->get_data()), 3); + } + + private function save_file($p_name, $content) + { + $hFile=fopen(__DIR__."/file/".$p_name, "w+"); + fwrite($hFile, $content); + fclose($hFile); + } + + //@covers Acc_Ledger_History_Generic::export_oneline_html + function testExport_Oneline_Html() + { + //- Listing + $name="acc_ledger_history_Generic_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); + + //- Extended + $name="acc_ledger_history_Generic_export_extended.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); + + //- Detail + $name="acc_ledger_history_Generic_export_detail.html"; + $this->object->set_m_mode("D"); + ob_start(); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + + //- Accounting + $name="acc_ledger_history_Generic_export_accounting.html"; + $this->object->set_m_mode("D"); + 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 a54d093d5..2ec6cad54 100644 --- a/unit-test/include/class/acc_ledger_history_purchaseTest.class.php +++ b/unit-test/include/class/acc_ledger_history_purchaseTest.class.php @@ -68,12 +68,49 @@ class Acc_Ledger_History_PurchaseTest extends TestCase //@covers Acc_Ledger_History_Financial::export_oneline_html function testExport_Oneline_Html() { + //- Listing + $name="acc_ledger_history_purchase_export_listing.html"; + $this->object->set_m_mode("L"); 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"); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + + //- Extended + $name="acc_ledger_history_purchase_export_extended.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); + + //- Detail + $name="acc_ledger_history_purchase_export_detail.html"; + $this->object->set_m_mode("D"); + ob_start(); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + + //- Accounting + $name="acc_ledger_history_purchase_export_accounting.html"; + $this->object->set_m_mode("D"); + 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_saleTest.class.php b/unit-test/include/class/acc_ledger_history_saleTest.class.php index 6197445a8..468731d84 100644 --- a/unit-test/include/class/acc_ledger_history_saleTest.class.php +++ b/unit-test/include/class/acc_ledger_history_saleTest.class.php @@ -57,4 +57,57 @@ class Acc_Ledger_History_SaleTest extends TestCase $this->object->get_row(); $this->assertSame(count($this->object->get_data()),4); } + private function save_file($p_name,$content) + { + $hFile=fopen(__DIR__."/file/".$p_name,"w+"); + fwrite($hFile, $content); + fclose($hFile); + } + //@covers Acc_Ledger_History_Sale::export_oneline_html + function testExport_Oneline_Html() + { + //- Listing + $name="acc_ledger_history_sale_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); + + //- Extended + $name="acc_ledger_history_sale_export_extended.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); + + //- Detail + $name="acc_ledger_history_sale_export_detail.html"; + $this->object->set_m_mode("D"); + ob_start(); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + + //- Accounting + $name="acc_ledger_history_sale_export_accounting.html"; + $this->object->set_m_mode("D"); + ob_start(); + phpunit_page_start(); + $this->object->export_html(); + $content=ob_get_contents(); + + $this->save_file($name, $content); + $this->assertFileExists(__DIR__."/file/".$name); + } }