Test : Acc_Ledger_History_Financial
Test : Acc_Ledger_History_Purchase Add function phpunit_page_start
This commit is contained in:
parent
5847c5a63c
commit
e9931f80af
3 changed files with 138 additions and 0 deletions
|
|
@ -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 <<<EOF
|
||||
<!doctype html>
|
||||
<HTML><HEAD><meta charset="utf-8"><META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>PRINTJRN NOALYSS</TITLE>
|
||||
<link rel="icon" type="image/ico" href="favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<LINK id="pagestyle" REL="stylesheet" type="text/css" href="{$noalyss_home}/style-classic7.css?version=7105" media="screen"/>
|
||||
<link rel="stylesheet" type="text/css" href="./style-print.css?version=7105" media="print"/>
|
||||
<script language="javascript" src="js/calendar.js"></script>
|
||||
<script type="text/javascript" src="js/lang/calendar-en.js"></script>
|
||||
<script language="javascript" src="js/calendar-setup.js"></script>
|
||||
<LINK REL="stylesheet" type="text/css" href="calendar-blue.css" media="screen">
|
||||
</HEAD>
|
||||
<body>
|
||||
<div class="content">
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2019) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue