QUAL Add get_substitutionarray_each_var_object in phpunit

This commit is contained in:
Laurent Destailleur (aka Eldy) 2025-02-06 12:04:41 +01:00
parent 52a4cd5975
commit 0772222900
5 changed files with 46 additions and 2 deletions

View File

@ -4073,7 +4073,7 @@ class Commande extends CommonOrder
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
global $conf, $langs;
global $langs;
$langs->load("orders");
$outputlangs->load("products");

View File

@ -5801,7 +5801,7 @@ abstract class CommonObject
*/
protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams = null)
{
global $conf, $langs, $user, $hookmanager, $action;
global $conf, $langs, $hookmanager, $action;
$srctemplatepath = '';

View File

@ -38,6 +38,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*
* This files is called by the "$obj = new $classname($this->db);" found into
* the commobject.class.php->commonGenerateDocument() called by $object->generateDocument()
*/
class doc_generic_order_odt extends ModelePDFCommandes
{

View File

@ -37,6 +37,9 @@ global $conf,$user,$langs,$db;
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
// Delete the log file to avoid problem of writing permission on it
@unlink(DOL_DATA_ROOT.'/dolibarr.log');
if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";

View File

@ -28,6 +28,7 @@ global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
//require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/commande/class/commande.class.php';
require_once dirname(__FILE__).'/../../htdocs/includes/odtphp/odf.php';
require_once dirname(__FILE__).'/CommonClassTest.class.php';
@ -50,6 +51,43 @@ $langs->load("main");
*/
class ODFTest extends CommonClassTest
{
/**
* test ODF convertVarToOdf
*
* @return int
*/
public function testGetSubstitutionarrayEachVarObject()
{
global $conf,$user,$langs,$db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
$localobject = new Commande($db);
$localobject->fetch(1);
$localobject->lines[0]->date_start = dol_now();
$localobject->lines[0]->date_end = dol_now() + 84600;
$result = $localobject->generateDocument('generic_order_odt', $langs);
print __METHOD__." result=".$result."\n";
$this->assertEquals(1, $result);
$filefound = DOL_DOCUMENT_ROOT.'/core/modules/commande/doc/doc_generic_order_odt.modules.php';
require_once $filefound;
$objdoc = new doc_generic_order_odt($db);
$result = $objdoc->get_substitutionarray_each_var_object($localobject, $langs);
$this->assertEquals(1, $result['object_id']);
}
/**
* test ODF convertVarToOdf
*