forked from Wavyzz/dolibarr
WIP PSR2
This commit is contained in:
@@ -175,23 +175,68 @@
|
||||
|
||||
|
||||
|
||||
<!-- Rules from PEAR Standard -->
|
||||
<!-- Rules from PEAR Standard -->
|
||||
|
||||
<rule ref="PEAR.Classes.ClassDeclaration" />
|
||||
<rule ref="PEAR.Classes.ClassDeclaration" />
|
||||
|
||||
<!-- Check for duplicate class names -->
|
||||
<!-- <rule ref="Generic.Classes.DuplicateClassName" /> -->
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment" />
|
||||
<rule ref="PEAR.Commenting.ClassComment.MissingTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.MissingTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@authorTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@categoryTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@licenseTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@linkTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@packageTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.Missing" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@authorTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@categoryTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@licenseTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@linkTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@packageTag" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.Missing" />
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@authorTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@categoryTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@licenseTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
@@ -201,94 +246,21 @@
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@packageTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<!-- TODO Remove this and fix reported errors -->
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.Missing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@authorTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@categoryTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@licenseTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@linkTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@packageTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<!-- TODO Remove this and fix reported errors -->
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.Missing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@authorTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@categoryTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@licenseTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@linkTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing@packageTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<!-- TODO Remove this and fix reported errors -->
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Commenting.FunctionComment.Missing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.Missing" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired" />
|
||||
|
||||
<rule ref="PEAR.Commenting.FunctionComment.Missing" />
|
||||
|
||||
<!--
|
||||
<rule ref="PEAR.Commenting.FileComment" />
|
||||
<rule ref="PEAR.Commenting.FileComment.WrongStyle">
|
||||
|
||||
@@ -40,8 +40,18 @@ class autoTranslator
|
||||
const DIR_SEPARATOR = '/';
|
||||
|
||||
|
||||
function __construct($_destlang,$_refLang,$_langDir,$_limittofile,$_apikey)
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $_destlang Destination lang
|
||||
* @param string $_refLang Ref lang
|
||||
* @param string $_langDir Dir lang
|
||||
* @param string $_limittofile Limit to file
|
||||
* @param string $_apikey Api key
|
||||
* @return void
|
||||
*/
|
||||
function __construct($_destlang,$_refLang,$_langDir,$_limittofile,$_apikey)
|
||||
{
|
||||
|
||||
// Set enviorment variables
|
||||
$this->_destlang = $_destlang;
|
||||
|
||||
@@ -34,189 +34,195 @@ if (!$user->admin) accessforbidden();
|
||||
llxHeader();
|
||||
|
||||
|
||||
if (!function_exists('eaccelerator_info'))
|
||||
{
|
||||
print 'eAccelerator is not installed.';
|
||||
llxFooter();
|
||||
exit;
|
||||
if (!function_exists('eaccelerator_info')) {
|
||||
print 'eAccelerator is not installed.';
|
||||
llxFooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$info = eaccelerator_info();
|
||||
if (isset($_POST['caching'])) {
|
||||
if ($info['cache']) {
|
||||
eaccelerator_caching(false);
|
||||
} else {
|
||||
eaccelerator_caching(true);
|
||||
}
|
||||
if ($info['cache']) {
|
||||
eaccelerator_caching(false);
|
||||
} else {
|
||||
eaccelerator_caching(true);
|
||||
}
|
||||
} else if (isset($_POST['optimizer']) && function_exists('eaccelerator_optimizer')) {
|
||||
if ($info['optimizer']) {
|
||||
eaccelerator_optimizer(false);
|
||||
} else {
|
||||
eaccelerator_optimizer(true);
|
||||
}
|
||||
if ($info['optimizer']) {
|
||||
eaccelerator_optimizer(false);
|
||||
} else {
|
||||
eaccelerator_optimizer(true);
|
||||
}
|
||||
} else if (isset($_POST['clear'])) {
|
||||
eaccelerator_clear();
|
||||
eaccelerator_clear();
|
||||
} else if (isset($_POST['clean'])) {
|
||||
eaccelerator_clean();
|
||||
eaccelerator_clean();
|
||||
} else if (isset($_POST['purge'])) {
|
||||
eaccelerator_purge();
|
||||
eaccelerator_purge();
|
||||
}
|
||||
$info = eaccelerator_info();
|
||||
if (!is_array($info)) {
|
||||
dol_print_error('','An error occured getting eAccelerator information, this is caused if eAccelerator isn\'t initalised properly');
|
||||
exit;
|
||||
dol_print_error('','An error occured getting eAccelerator information, this is caused if eAccelerator isn\'t initalised properly');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Compare revisions
|
||||
*
|
||||
* @param array $x Parts of version 1
|
||||
* @param array $y Parts of version 2
|
||||
* @return int -1 if 1<2, 0 if 1=2, 1 if 1>2
|
||||
*/
|
||||
function compare($x, $y)
|
||||
{
|
||||
global $sortby;
|
||||
global $sortby;
|
||||
|
||||
if ( $x[$sortby] == $y[$sortby] )
|
||||
return 0;
|
||||
else if ( $x[$sortby] < $y[$sortby] )
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
if ( $x[$sortby] == $y[$sortby] ) {
|
||||
return 0;
|
||||
} else if ($x[$sortby] < $y[$sortby]) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare revisions
|
||||
*
|
||||
* @param array $x Parts of version 1
|
||||
* @param array $y Parts of version 2
|
||||
* @return int 1 if 1<2, 0 if 1=2, -1 if 1>2
|
||||
* @param array $x Parts of version 1
|
||||
* @param array $y Parts of version 2
|
||||
* @return int 1 if 1<2, 0 if 1=2, -1 if 1>2
|
||||
*/
|
||||
function revcompare($x, $y)
|
||||
{
|
||||
global $sortby, $langs;
|
||||
global $sortby, $langs;
|
||||
|
||||
if ( $x[$sortby] == $y[$sortby] )
|
||||
return 0;
|
||||
else if ( $x[$sortby] < $y[$sortby] )
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
if ($x[$sortby] == $y[$sortby]) {
|
||||
return 0;
|
||||
} else if ($x[$sortby] < $y[$sortby]) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output table
|
||||
*
|
||||
* @param array $list Array of records
|
||||
* @return void
|
||||
* @param array $list Array of records
|
||||
* @return void
|
||||
*/
|
||||
function create_script_table($list)
|
||||
{
|
||||
global $sortby,$bc,$langs;
|
||||
$var=true;
|
||||
global $sortby,$bc,$langs;
|
||||
$var=true;
|
||||
|
||||
if (isset($_GET['order']) && ($_GET['order'] == "asc" || $_GET['order'] =="desc")) {
|
||||
$order = $_GET['order'];
|
||||
} else {
|
||||
$order = "asc";
|
||||
}
|
||||
if (isset($_GET['order']) && ($_GET['order'] == "asc" || $_GET['order'] =="desc")) {
|
||||
$order = $_GET['order'];
|
||||
} else {
|
||||
$order = "asc";
|
||||
}
|
||||
|
||||
if (isset($_GET['sort'])) {
|
||||
switch ($_GET['sort']) {
|
||||
case "mtime":
|
||||
case "size":
|
||||
case "reloads":
|
||||
case "hits":
|
||||
$sortby = $_GET['sort'];
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
break;
|
||||
default:
|
||||
$sortby = "file";
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
}
|
||||
}
|
||||
if (isset($_GET['sort'])) {
|
||||
switch ($_GET['sort']) {
|
||||
case "mtime":
|
||||
case "size":
|
||||
case "reloads":
|
||||
case "hits":
|
||||
$sortby = $_GET['sort'];
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
break;
|
||||
default:
|
||||
$sortby = "file";
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<table class="noborder">
|
||||
<tr>
|
||||
<th><a
|
||||
href="<?php print $_SERVER['PHP_SELF']?>?sort=file&order=<?php print ($order == "asc" ? "desc" : "asc")?>"><?php print $langs->trans("Filename"); ?></a> <?php if($sortby == "file") print ($order == "asc" ? "↓" : "↑") ?></th>
|
||||
<th><a
|
||||
href="<?php print $_SERVER['PHP_SELF']?>?sort=mtime&order=<?php print ($order == "asc" ? "desc" : "asc")?>"><?php print $langs->trans("Date"); ?></a> <?php if($sortby == "mtime") print ($order == "asc" ? "↓" : "↑") ?></th>
|
||||
<th><a
|
||||
href="<?php print $_SERVER['PHP_SELF']?>?sort=size&order=<?php print ($order == "asc" ? "desc" : "asc")?>"><?php print $langs->trans("Size"); ?></a> <?php if($sortby == "size") print ($order == "asc" ? "↓" : "↑") ?></th>
|
||||
<th><a
|
||||
href="<?php print $_SERVER['PHP_SELF']?>?sort=reloads&order=<?php print ($order == "asc" ? "desc" : "asc")?>"><?php print $langs->trans("Reloads"); ?></a> <?php if($sortby == "reloads") print ($order == "asc" ? "↓" : "↑") ?></th>
|
||||
<th><a
|
||||
href="<?php print $_SERVER['PHP_SELF']?>?sort=hits&order=<?php print ($order == "asc" ? "desc" : "asc")?>"><?php print $langs->trans("Hits"); ?></a> <?php if($sortby == "hits") print ($order == "asc" ? "↓" : "↑") ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
switch ($sortby) {
|
||||
case "mtime":
|
||||
case "size":
|
||||
case "reloads":
|
||||
case "hits":
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
break;
|
||||
case "file":
|
||||
default:
|
||||
$sortby = "file";
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
print '<table class="noborder">';
|
||||
print '<tr>';
|
||||
print '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=file&order='.($order == "asc" ? "desc" : "asc").'">'.$langs->trans("Filename").'</a> ';
|
||||
if($sortby == "file")
|
||||
print ($order == "asc" ? "↓" : "↑").'</th>';
|
||||
print '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=mtime&order='.($order == "asc" ? "desc" : "asc").'">'.$langs->trans("Date").'</a> ';
|
||||
if($sortby == "mtime")
|
||||
print ($order == "asc" ? "↓" : "↑").'</th>';
|
||||
print '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=size&order='.($order == "asc" ? "desc" : "asc").'">'.$langs->trans("Size").'</a> ';
|
||||
if($sortby == "size")
|
||||
print ($order == "asc" ? "↓" : "↑").'</th>';
|
||||
print '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=reloads&order='.($order == "asc" ? "desc" : "asc").'">'.$langs->trans("Reloads").'</a> ';
|
||||
if($sortby == "reloads")
|
||||
print ($order == "asc" ? "↓" : "↑").'</th>';
|
||||
print '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=hits&order='.($order == "asc" ? "desc" : "asc").'">'.$langs->trans("Hits").'</a> ';
|
||||
if($sortby == "hits")
|
||||
print ($order == "asc" ? "↓" : "↑").'</th>';
|
||||
print '</tr>';
|
||||
switch ($sortby) {
|
||||
case "mtime":
|
||||
case "size":
|
||||
case "reloads":
|
||||
case "hits":
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
break;
|
||||
case "file":
|
||||
default:
|
||||
$sortby = "file";
|
||||
($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach($list as $script) {
|
||||
$var = ! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.dol_trunc($script['file'],80,'left').'</td>';
|
||||
print '<td align="center" class="nowrap">'.dol_print_date($script['mtime'],'dayhour').'</td>';
|
||||
print '<td align="right" class="nowrap">'.number_format($script['size'] / 1024, 2).'KB</td>';
|
||||
print '<td align="right" class="nowrap">'.$script['reloads'].' ('.$script['usecount'].')</td>';
|
||||
print '<td align="right" class="nowrap">'.$script['hits'].'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
foreach($list as $script) { ?>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td><?php print dol_trunc($script['file'],80,'left'); ?></td>
|
||||
<td align="center" class="nowrap"><?php print dol_print_date($script['mtime'],'dayhour'); ?></td>
|
||||
<td align="right" class="nowrap"><?php print number_format($script['size'] / 1024, 2); ?>
|
||||
KB</td>
|
||||
<td align="right" class="nowrap"><?php print $script['reloads']; ?> (<?php print $script['usecount']; ?>)</td>
|
||||
<td align="right" class="nowrap"><?php print $script['hits']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output table
|
||||
*
|
||||
* @param array $list Array of records
|
||||
* @return void
|
||||
* @param array $list Array of records
|
||||
* @return void
|
||||
*/
|
||||
function create_key_table($list)
|
||||
{
|
||||
global $bc,$langs;
|
||||
$var=true;
|
||||
?>
|
||||
<table class="noborder">
|
||||
<tr class="liste_titre">
|
||||
<th>Name</th>
|
||||
<th>Created</th>
|
||||
<th><?php print $langs->trans("Size"); ?></th>
|
||||
<th>ttl</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($list as $key) {
|
||||
?>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td><?php print dol_trunc($key['name'],80,'left'); ?></td>
|
||||
<td align="center" class="nowrap"><?php dol_print_date($key['created'],'dayhour'); ?></td>
|
||||
<td align="right" class="nowrap"><?php print number_format($key['size']/1024, 3); ?>
|
||||
KB</td>
|
||||
<td align="right" class="nowrap"><?php
|
||||
if ($key['ttl'] == -1) {
|
||||
print 'expired';
|
||||
} elseif ($key['ttl'] == 0) {
|
||||
print 'none';
|
||||
} else {
|
||||
print dol_print_date($key['ttl'],'dayhour');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
global $bc,$langs;
|
||||
$var=true;
|
||||
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>Name</th>';
|
||||
print '<th>Created</th>';
|
||||
print '<th>'.$langs->trans("Size").'</th>';
|
||||
print '<th>ttl</th>';
|
||||
print '</tr>';
|
||||
|
||||
foreach($list as $key) {
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.dol_trunc($key['name'],80,'left').'</td>';
|
||||
print '<td align="center" class="nowrap">'.dol_print_date($key['created'],'dayhour').'</td>';
|
||||
print '<td align="right" class="nowrap">'.number_format($key['size']/1024, 3).'KB</td>';
|
||||
print '<td align="right" class="nowrap">';
|
||||
if ($key['ttl'] == -1) {
|
||||
print 'expired';
|
||||
} elseif ($key['ttl'] == 0) {
|
||||
print 'none';
|
||||
} else {
|
||||
print dol_print_date($key['ttl'],'dayhour');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
|
||||
@@ -225,123 +231,117 @@ print_fiche_titre('Dolibarr eAccelerator '.$info['version'].' control panel','',
|
||||
|
||||
$var=true;
|
||||
|
||||
?>
|
||||
<br>
|
||||
print '<br>';
|
||||
|
||||
|
||||
<table class="noborder">
|
||||
<tr class="liste_titre">
|
||||
<td colspan="2">Information</td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Caching enabled</td>
|
||||
<td align="right"><?php print $info['cache'] ? 'yes':'no' ?></td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Optimizer enabled</td>
|
||||
<td align="right"><?php print $info['optimizer'] ? 'yes':'no' ?></td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Memory usage</td>
|
||||
<td align="right"><?php print number_format(100 * $info['memoryAllocated'] / $info['memorySize'], 2); ?>%
|
||||
(<?php print number_format($info['memoryAllocated'] / (1024*1024), 2); ?>
|
||||
MB / <?php print number_format($info['memorySize'] / (1024*1024), 2); ?>
|
||||
MB)</td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Free memory in reserved cache</td>
|
||||
<td align="right"><?php print number_format($info['memoryAvailable'] / (1024*1024), 2); ?>MB</td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Cached scripts</td>
|
||||
<td align="right"><?php print $info['cachedScripts']; ?></td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Removed scripts</td>
|
||||
<td align="right"><?php print $info['removedScripts']; ?></td>
|
||||
</tr>
|
||||
<tr <?php $var = ! $var; print $bc[$var]; ?>>
|
||||
<td>Cached keys</td>
|
||||
<td align="right"><?php print (isset($info['cachedKeys'])?$info['cachedKeys']:''); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">Information</td>';
|
||||
print '</tr>';
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Caching enabled</td>';
|
||||
print '<td align="right">'.($info['cache']?'yes':'no').'</td>';
|
||||
print '</tr>';
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Optimizer enabled</td>';
|
||||
print '<td align="right">'.$info['optimizer']?'yes':'no'.'</td>';
|
||||
print '</tr>';
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Memory usage</td>';
|
||||
print '<td align="right">'.number_format(100 * $info['memoryAllocated']/$info['memorySize'], 2).'%('.number_format($info['memoryAllocated'] / (1024*1024), 2).'MB / '.number_format($info['memorySize']/(1024*1024), 2).'MB)</td>';
|
||||
print '</tr>';
|
||||
$var = ! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Free memory in reserved cache</td>';
|
||||
print '<td align="right">'.number_format($info['memoryAvailable']/(1024*1024), 2).'MB</td>';
|
||||
print '</tr>';
|
||||
$var = ! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Cached scripts</td>';
|
||||
print '<td align="right">'.$info['cachedScripts'].'</td>';
|
||||
print '</tr>';
|
||||
$var = ! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Removed scripts</td>';
|
||||
print '<td align="right">'.$info['removedScripts'].'</td>';
|
||||
print '</tr>';
|
||||
$var = ! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>Cached keys</td>';
|
||||
print '<td align="right">'.(isset($info['cachedKeys'])?$info['cachedKeys']:'').'</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
$var=true;
|
||||
|
||||
$resCached = @eaccelerator_cached_scripts(); // If success return an array
|
||||
$resCached = @eaccelerator_cached_scripts(); // If success return an array
|
||||
$resRemoved = @eaccelerator_removed_scripts();
|
||||
|
||||
if (is_array($resCached) || is_array($resRemoved))
|
||||
{
|
||||
print "<br>";
|
||||
print '<form name="ea_control" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="2">Actions</td></tr>';
|
||||
if (is_array($resCached) || is_array($resRemoved)) {
|
||||
print "<br>";
|
||||
print '<form name="ea_control" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="2">Actions</td></tr>';
|
||||
|
||||
if (is_array($resCached))
|
||||
{
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Caching</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="caching" value="'. ($info['cache']?'disable':'enable') .'" /></td>';
|
||||
print "</tr>";
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Optimizer</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="optimizer" value="'. ($info['optimizer']?'disable':'enable') .'" /></td>';
|
||||
print "</tr>";
|
||||
}
|
||||
if (is_array($resCached)) {
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Caching</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="caching" value="'. ($info['cache']?'disable':'enable') .'" /></td>';
|
||||
print "</tr>";
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Optimizer</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="optimizer" value="'. ($info['optimizer']?'disable':'enable') .'" /></td>';
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
if (is_array($resRemoved))
|
||||
{
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Clear cache</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="clear" value="clear" title="remove all unused scripts and data from shared memory and disk cache" /></td>';
|
||||
print "</tr>";
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Clean cache</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="clean" value="clean" title=" remove all expired scripts and data from shared memory and disk cache" /></td>';
|
||||
print "</tr>";
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Purge cache</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="purge" value="purge" title="remove all \'removed\' scripts from shared memory" /></td>';
|
||||
print "</tr></table></form>";
|
||||
}
|
||||
if (is_array($resRemoved)) {
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Clear cache</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="clear" value="clear" title="remove all unused scripts and data from shared memory and disk cache" /></td>';
|
||||
print "</tr>";
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Clean cache</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="clean" value="clean" title=" remove all expired scripts and data from shared memory and disk cache" /></td>';
|
||||
print "</tr>";
|
||||
$var = ! $var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>Purge cache</td>";
|
||||
print '<td align="right"><input type="submit" class="butAction" name="purge" value="purge" title="remove all \'removed\' scripts from shared memory" /></td>';
|
||||
print "</tr></table></form>";
|
||||
}
|
||||
|
||||
if (is_array($resCached))
|
||||
{
|
||||
print "<br><br>";
|
||||
print "<b>Cached scripts</b><br>";
|
||||
create_script_table($resCached);
|
||||
}
|
||||
if (is_array($resCached)) {
|
||||
print "<br><br>";
|
||||
print "<b>Cached scripts</b><br>";
|
||||
create_script_table($resCached);
|
||||
}
|
||||
|
||||
if (is_array($resRemoved))
|
||||
{
|
||||
print "<br><br>";
|
||||
print "<b>Removed scripts</b><br>";
|
||||
create_script_table($resRemoved);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<br><br>";
|
||||
print "Check in your <b>php.ini</b> that <b>eaccelerator.allowed_admin_path</b> parameter is : ";
|
||||
print "<br><br>";
|
||||
print "<b>".$_SERVER["SCRIPT_FILENAME"]."</b>";
|
||||
print "<br><br>";
|
||||
if (is_array($resRemoved)) {
|
||||
print "<br><br>";
|
||||
print "<b>Removed scripts</b><br>";
|
||||
create_script_table($resRemoved);
|
||||
}
|
||||
} else {
|
||||
print "<br><br>";
|
||||
print "Check in your <b>php.ini</b> that <b>eaccelerator.allowed_admin_path</b> parameter is : ";
|
||||
print "<br><br>";
|
||||
print "<b>".$_SERVER["SCRIPT_FILENAME"]."</b>";
|
||||
print "<br><br>";
|
||||
}
|
||||
|
||||
if (function_exists('eaccelerator_get'))
|
||||
{
|
||||
print '<br><br>';
|
||||
print '<b>Cached keys</b><br>';
|
||||
$res=eaccelerator_list_keys();
|
||||
create_key_table($res);
|
||||
if (function_exists('eaccelerator_get')) {
|
||||
print '<br><br>';
|
||||
print '<b>Cached keys</b><br>';
|
||||
$res=eaccelerator_list_keys();
|
||||
create_key_table($res);
|
||||
}
|
||||
|
||||
print "<br><br>";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/localtax/index.php
|
||||
* \file htdocs/compta/localtax/index.php
|
||||
* \ingroup tax
|
||||
* \brief Index page of IRPF reports
|
||||
* \brief Index page of IRPF reports
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
||||
@@ -30,8 +30,7 @@ $langs->load("other");
|
||||
$localTaxType=GETPOST('localTaxType', 'int');
|
||||
|
||||
$year=$_GET["year"];
|
||||
if ($year == 0 )
|
||||
{
|
||||
if ($year == 0 ) {
|
||||
$year_current = strftime("%Y",time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
@@ -41,21 +40,30 @@ if ($year == 0 )
|
||||
|
||||
// Security check
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
if ($user->societe_id)
|
||||
$socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"];
|
||||
if (isset($_GET["modetax"]))
|
||||
$modetax=$_GET["modetax"];
|
||||
|
||||
/**
|
||||
* print function
|
||||
*
|
||||
* @param DoliDB $db Database
|
||||
* @param string $sql sql
|
||||
* @param string $date date
|
||||
* @return void
|
||||
*/
|
||||
function pt ($db, $sql, $date)
|
||||
{
|
||||
global $conf, $bc,$langs;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
@@ -66,8 +74,7 @@ function pt ($db, $sql, $date)
|
||||
print '<td> </td>'."\n";
|
||||
print "</tr>\n";
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
@@ -83,8 +90,7 @@ function pt ($db, $sql, $date)
|
||||
|
||||
print "</table>";
|
||||
$db->free($result);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
@@ -96,17 +102,14 @@ function pt ($db, $sql, $date)
|
||||
|
||||
llxHeader();
|
||||
|
||||
if($localTaxType==1)
|
||||
{
|
||||
if($localTaxType==1) {
|
||||
$LT='LT1';
|
||||
$LTSummary='LT1Summary';
|
||||
$LTPaid='LT1Paid';
|
||||
$LTCustomer='LT1Customer';
|
||||
$LTSupplier='LT1Supplier';
|
||||
$CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$LT='LT2';
|
||||
$LTSummary='LT2Summary';
|
||||
$LTPaid='LT2Paid';
|
||||
@@ -138,18 +141,15 @@ print '<tr><td width="50%" valign="top">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td width=\"30%\">".$langs->trans("Year")." $y</td>";
|
||||
if($CalcLT==0)
|
||||
{
|
||||
print "<td align=\"right\">".$langs->transcountry($LTCustomer,$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->transcountry($LTSupplier,$mysoc->country_code)."</td>";
|
||||
if($CalcLT==0) {
|
||||
print "<td align=\"right\">".$langs->transcountry($LTCustomer,$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->transcountry($LTSupplier,$mysoc->country_code)."</td>";
|
||||
}
|
||||
if($CalcLT==1)
|
||||
{
|
||||
print "<td align=\"right\">".$langs->transcountry($LTSupplier,$mysoc->country_code)."</td><td></td>";
|
||||
if($CalcLT==1) {
|
||||
print "<td align=\"right\">".$langs->transcountry($LTSupplier,$mysoc->country_code)."</td><td></td>";
|
||||
}
|
||||
if($CalcLT==2)
|
||||
{
|
||||
print "<td align=\"right\">".$langs->transcountry($LTCustomer,$mysoc->country_code)."</td><td></td>";
|
||||
if($CalcLT==2) {
|
||||
print "<td align=\"right\">".$langs->transcountry($LTCustomer,$mysoc->country_code)."</td><td></td>";
|
||||
}
|
||||
|
||||
print "<td align=\"right\">".$langs->trans("TotalToPay")."</td>";
|
||||
@@ -161,8 +161,7 @@ $y = $year_current ;
|
||||
$var=True;
|
||||
$total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
|
||||
$i=0;
|
||||
for ($m = 1 ; $m < 13 ; $m++ )
|
||||
{
|
||||
for ($m = 1 ; $m < 13 ; $m++ ) {
|
||||
$coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m);
|
||||
$coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m);
|
||||
|
||||
@@ -175,72 +174,56 @@ for ($m = 1 ; $m < 13 ; $m++ )
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (! is_array($coll_listbuy) && $coll_listbuy == -1)
|
||||
{
|
||||
if (! is_array($coll_listbuy) && $coll_listbuy == -1) {
|
||||
$langs->load("errors");
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
break;
|
||||
}
|
||||
if (! is_array($coll_listbuy) && $coll_listbuy == -2)
|
||||
{
|
||||
if (! is_array($coll_listbuy) && $coll_listbuy == -2) {
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
break;
|
||||
}
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td class="nowrap">'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'</td>';
|
||||
if($CalcLT==0)
|
||||
{
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val)
|
||||
{
|
||||
if($CalcLT==0) {
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val) {
|
||||
$x_coll+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalcoll = $subtotalcoll + $x_coll;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_coll)."</td>";
|
||||
|
||||
$x_paye = 0;
|
||||
foreach($coll_listbuy as $vatrate=>$val)
|
||||
{
|
||||
foreach($coll_listbuy as $vatrate=>$val) {
|
||||
$x_paye+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalpaye = $subtotalpaye + $x_paye;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_paye)."</td>";
|
||||
}
|
||||
elseif($CalcLT==1)
|
||||
{
|
||||
} elseif($CalcLT==1) {
|
||||
$x_paye = 0;
|
||||
foreach($coll_listbuy as $vatrate=>$val)
|
||||
{
|
||||
foreach($coll_listbuy as $vatrate=>$val) {
|
||||
$x_paye+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalpaye = $subtotalpaye + $x_paye;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_paye)."</td><td></td>";
|
||||
}
|
||||
elseif($CalcLT==2)
|
||||
{
|
||||
} elseif($CalcLT==2) {
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val)
|
||||
{
|
||||
foreach($coll_listsell as $vatrate=>$val) {
|
||||
$x_coll+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalcoll = $subtotalcoll + $x_coll;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_coll)."</td><td></td>";
|
||||
|
||||
}
|
||||
|
||||
if($CalcLT==0)
|
||||
{
|
||||
$diff= $x_coll - $x_paye;
|
||||
}
|
||||
elseif($CalcLT==1)
|
||||
{
|
||||
$diff= $x_paye;
|
||||
}
|
||||
elseif($CalcLT==2)
|
||||
{
|
||||
$diff= $x_coll;
|
||||
|
||||
if($CalcLT==0) {
|
||||
$diff= $x_coll - $x_paye;
|
||||
} elseif($CalcLT==1) {
|
||||
$diff= $x_paye;
|
||||
} elseif($CalcLT==2) {
|
||||
$diff= $x_coll;
|
||||
}
|
||||
|
||||
$total = $total + $diff;
|
||||
@@ -251,23 +234,17 @@ for ($m = 1 ; $m < 13 ; $m++ )
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
if ($i > 2)
|
||||
{
|
||||
if ($i > 2) {
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="right">'.$langs->trans("SubTotal").':</td>';
|
||||
if($CalcLT==0)
|
||||
{
|
||||
if($CalcLT==0) {
|
||||
print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
}
|
||||
elseif($CalcLT==1)
|
||||
{
|
||||
} elseif($CalcLT==1) {
|
||||
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td><td></td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
}
|
||||
elseif($CalcLT==2)
|
||||
{
|
||||
} elseif($CalcLT==2) {
|
||||
print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td><td></td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
}
|
||||
@@ -298,7 +275,7 @@ $sql.= " GROUP BY dm ASC";
|
||||
|
||||
pt($db, $sql,$langs->trans("Year")." $y");
|
||||
|
||||
print "</td></tr></table>";
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/boxes/box_activite.php
|
||||
* \ingroup projet
|
||||
* \brief Module to show Projet activity of the current Year
|
||||
* \file htdocs/core/boxes/box_activite.php
|
||||
* \ingroup projet
|
||||
* \brief Module to show Projet activity of the current Year
|
||||
*/
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
|
||||
|
||||
@@ -37,23 +37,27 @@ class box_project extends ModeleBoxes
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
*/
|
||||
function box_project()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
$langs->load("projects");
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $param More parameters
|
||||
*/
|
||||
function __construct($db,$param='')
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
$langs->load("projects");
|
||||
|
||||
$this->boxlabel="Projects";
|
||||
}
|
||||
$this->db = $db;
|
||||
$this->boxlabel="Projects";
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data for box to show them later
|
||||
*
|
||||
* @param int $max Maximum number of records to load
|
||||
* @return void
|
||||
* @param int $max Maximum number of records to load
|
||||
* @return void
|
||||
*/
|
||||
function loadBox($max=5)
|
||||
{
|
||||
@@ -69,8 +73,7 @@ class box_project extends ModeleBoxes
|
||||
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
|
||||
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire)
|
||||
{
|
||||
if ($user->rights->projet->lire) {
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
@@ -79,35 +82,37 @@ class box_project extends ModeleBoxes
|
||||
$sql.= " ORDER BY p.datec DESC";
|
||||
$sql.= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
|
||||
'logo' => 'object_project',
|
||||
'url' => DOL_URL_ROOT."/projet/card.php?id=".$objp->rowid);
|
||||
$this->info_box_contents[$i][0] = array(
|
||||
'td' => 'align="left" width="16"',
|
||||
'logo' => 'object_project',
|
||||
'url' => DOL_URL_ROOT."/projet/card.php?id=".$objp->rowid
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
|
||||
'text' => $objp->ref,
|
||||
'url' => DOL_URL_ROOT."/product/card.php?id=".$objp->rowid);
|
||||
$this->info_box_contents[$i][1] = array(
|
||||
'td' => 'align="left"',
|
||||
'text' => $objp->ref,
|
||||
'url' => DOL_URL_ROOT."/product/card.php?id=".$objp->rowid
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][2] = array('td' => 'align="left"',
|
||||
'text' => $objp->title
|
||||
);
|
||||
$this->info_box_contents[$i][2] = array(
|
||||
'td' => 'align="left"',
|
||||
'text' => $objp->title
|
||||
);
|
||||
|
||||
$sql ="SELECT count(*) as nb, sum(progress) as totprogress";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid";
|
||||
$sql.=" WHERE p.entity = ".$conf->entity;
|
||||
|
||||
$resultTask = $db->query($sql);
|
||||
if ($resultTask)
|
||||
{
|
||||
if ($resultTask) {
|
||||
$objTask = $db->fetch_object($resultTask);
|
||||
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format($objTask->nb, 0, ',', ' ')." ".$langs->trans("Tasks"));
|
||||
if ($objTask->nb > 0 )
|
||||
@@ -115,9 +120,7 @@ class box_project extends ModeleBoxes
|
||||
else
|
||||
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A ");
|
||||
$totalnbTask += $objTask->nb;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format(0, 0, ',', ' '));
|
||||
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A ");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012-2014 Charles-François BENKE <charles.fr@benke.fr>
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
@@ -15,10 +16,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/boxes/box_task.php
|
||||
* \ingroup Projet
|
||||
* \brief Module to Task activity of the current year
|
||||
* \version $Id: box_task.php,v 1.1 2012/09/11 Charles-François BENKE
|
||||
* \file htdocs/core/boxes/box_task.php
|
||||
* \ingroup Projet
|
||||
* \brief Module to Task activity of the current year
|
||||
* \version $Id: box_task.php,v 1.1 2012/09/11 Charles-François BENKE
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
|
||||
@@ -29,32 +30,36 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||
*/
|
||||
class box_task extends ModeleBoxes
|
||||
{
|
||||
var $boxcode="projet";
|
||||
var $boximg="object_projecttask";
|
||||
var $boxlabel;
|
||||
//var $depends = array("projet");
|
||||
var $db;
|
||||
var $param;
|
||||
var $boxcode="projet";
|
||||
var $boximg="object_projecttask";
|
||||
var $boxlabel;
|
||||
//var $depends = array("projet");
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function box_task()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
$langs->load("projects");
|
||||
$this->boxlabel="Tasks";
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $param More parameters
|
||||
*/
|
||||
function __construct($db,$param='')
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
$langs->load("projects");
|
||||
$this->boxlabel="Tasks";
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data for box to show them later
|
||||
*
|
||||
* @param int $max Maximum number of records to load
|
||||
* @return void
|
||||
* @param int $max Maximum number of records to load
|
||||
* @return void
|
||||
*/
|
||||
function loadBox($max=5)
|
||||
{
|
||||
@@ -73,8 +78,7 @@ class box_task extends ModeleBoxes
|
||||
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
|
||||
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire)
|
||||
{
|
||||
if ($user->rights->projet->lire) {
|
||||
|
||||
$sql = "SELECT pt.fk_statut, count(pt.rowid) as nb, sum(ptt.task_duration) as durationtot, sum(pt.planned_workload) as plannedtot";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt";
|
||||
@@ -86,23 +90,23 @@ class box_task extends ModeleBoxes
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_projecttask');
|
||||
while ($i < $num) {
|
||||
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_projecttask');
|
||||
|
||||
$objp = $db->fetch_object($result);
|
||||
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
|
||||
'text' =>$langs->trans("Task")." ".$taskstatic->LibStatut($objp->fk_statut,0)
|
||||
);
|
||||
$objp = $db->fetch_object($result);
|
||||
$this->info_box_contents[$i][1] = array(
|
||||
'td' => 'align="left"',
|
||||
'text' =>$langs->trans("Task")." ".$taskstatic->LibStatut($objp->fk_statut,0)
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
|
||||
'text' => $objp->nb." ".$langs->trans("Tasks"),
|
||||
'url' => DOL_URL_ROOT."/projet/tasks/index.php?leftmenu=projects&viewstatut=".$objp->fk_statut
|
||||
);
|
||||
$this->info_box_contents[$i][2] = array(
|
||||
'td' => 'align="right"',
|
||||
'text' => $objp->nb." ".$langs->trans("Tasks"),
|
||||
'url' => DOL_URL_ROOT."/projet/tasks/index.php?leftmenu=projects&viewstatut=".$objp->fk_statut
|
||||
);
|
||||
$totalnb += $objp->nb;
|
||||
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => ConvertSecondToTime($objp->plannedtot,'all',25200,5));
|
||||
$totalplannedtot += $objp->plannedtot;
|
||||
|
||||
@@ -118,6 +118,13 @@ function GetFoldersAndFiles( $resourceType, $currentFolder )
|
||||
echo '</Files>' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create folder
|
||||
*
|
||||
* @param string $resourceType Resource type
|
||||
* @param string $currentFolder Current folder
|
||||
* @return void
|
||||
*/
|
||||
function CreateFolder( $resourceType, $currentFolder )
|
||||
{
|
||||
if (!isset($_GET)) {
|
||||
|
||||
@@ -123,8 +123,8 @@ function ServerMapFolder($resourceType, $folderPath, $sCommand)
|
||||
*/
|
||||
function GetParentFolder($folderPath)
|
||||
{
|
||||
$sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
|
||||
return preg_replace($sPattern, '', $folderPath);
|
||||
$sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
|
||||
return preg_replace($sPattern, '', $folderPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,46 +196,57 @@ function CreateServerFolder($folderPath, $lastFolder = null)
|
||||
return '' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Root Path
|
||||
*
|
||||
* @return string real path
|
||||
*/
|
||||
function GetRootPath()
|
||||
{
|
||||
if (!isset($_SERVER)) {
|
||||
global $_SERVER;
|
||||
}
|
||||
$sRealPath = realpath('./');
|
||||
// #2124 ensure that no slash is at the end
|
||||
$sRealPath = rtrim($sRealPath,"\\/");
|
||||
if (!isset($_SERVER)) {
|
||||
global $_SERVER;
|
||||
}
|
||||
$sRealPath = realpath('./');
|
||||
// #2124 ensure that no slash is at the end
|
||||
$sRealPath = rtrim($sRealPath,"\\/");
|
||||
|
||||
$sSelfPath = $_SERVER['PHP_SELF'] ;
|
||||
$sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
|
||||
$sSelfPath = $_SERVER['PHP_SELF'] ;
|
||||
$sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
|
||||
|
||||
$sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
|
||||
$sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
|
||||
|
||||
$position = strpos($sRealPath, $sSelfPath);
|
||||
$position = strpos($sRealPath, $sSelfPath);
|
||||
|
||||
// This can check only that this script isn't run from a virtual dir
|
||||
// But it avoids the problems that arise if it isn't checked
|
||||
if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
|
||||
SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
|
||||
// This can check only that this script isn't run from a virtual dir
|
||||
// But it avoids the problems that arise if it isn't checked
|
||||
if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
|
||||
SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
|
||||
|
||||
return substr($sRealPath, 0, $position);
|
||||
return substr($sRealPath, 0, $position);
|
||||
}
|
||||
|
||||
// Emulate the asp Server.mapPath function.
|
||||
// given an url path return the physical directory that it corresponds to
|
||||
function Server_MapPath( $path )
|
||||
{
|
||||
// This function is available only for Apache
|
||||
if (function_exists('apache_lookup_uri'))
|
||||
{
|
||||
$info = apache_lookup_uri($path);
|
||||
return $info->filename . $info->path_info ;
|
||||
}
|
||||
// This function is available only for Apache
|
||||
if (function_exists('apache_lookup_uri')) {
|
||||
$info = apache_lookup_uri($path);
|
||||
return $info->filename . $info->path_info ;
|
||||
}
|
||||
|
||||
// This isn't correct but for the moment there's no other solution
|
||||
// If this script is under a virtual directory or symlink it will detect the problem and stop
|
||||
return GetRootPath() . $path ;
|
||||
// This isn't correct but for the moment there's no other solution
|
||||
// If this script is under a virtual directory or symlink it will detect the problem and stop
|
||||
return GetRootPath() . $path ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Allowed Extension
|
||||
*
|
||||
* @param string $sExtension File extension
|
||||
* @param string $resourceType ressource type
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function IsAllowedExt($sExtension, $resourceType)
|
||||
{
|
||||
global $Config ;
|
||||
@@ -252,6 +263,12 @@ function IsAllowedExt($sExtension, $resourceType)
|
||||
return true ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Allowed Type
|
||||
*
|
||||
* @param string $resourceType ressource type
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function IsAllowedType($resourceType)
|
||||
{
|
||||
global $Config ;
|
||||
@@ -264,8 +281,8 @@ function IsAllowedType($resourceType)
|
||||
/**
|
||||
* IsAllowedCommand
|
||||
*
|
||||
* @param string $sCommand Command
|
||||
* @return boolean True or false
|
||||
* @param string $sCommand Command
|
||||
* @return boolean True or false
|
||||
*/
|
||||
function IsAllowedCommand($sCommand)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandlerInterface.php';
|
||||
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/syslog/logHandlerInterface.php
|
||||
* \ingroup syslog
|
||||
* \brief LogHandlerInterface
|
||||
*/
|
||||
|
||||
/**
|
||||
* LogHandlerInterface
|
||||
|
||||
@@ -341,8 +341,12 @@ llxFooter();
|
||||
$db->close();
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Print html activity for product type
|
||||
*
|
||||
* @param int $product_type Type of product
|
||||
* @return void
|
||||
*/
|
||||
function activitytrim($product_type)
|
||||
{
|
||||
global $conf,$langs,$db;
|
||||
|
||||
@@ -495,7 +495,14 @@ class MouvementStock extends CommonObject
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get origin
|
||||
*
|
||||
* @param variant $fk_origin id of origin
|
||||
* @param int $origintype origin type
|
||||
* @return string name url
|
||||
*/
|
||||
function get_origin($fk_origin, $origintype) {
|
||||
switch ($origintype) {
|
||||
case 'commande':
|
||||
|
||||
@@ -798,16 +798,20 @@ class Resource extends CommonObject
|
||||
return $resources;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return an int number of resources linked to the element
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function fetchElementResources($element,$element_id)
|
||||
{
|
||||
$resources = $this->getElementResources($element,$element_id);
|
||||
$i=0;
|
||||
foreach($resources as $nb => $resource)
|
||||
{
|
||||
$this->lines[$i] = fetchObjectByElement($resource['resource_id'],$resource['resource_type']);
|
||||
$i++;
|
||||
}
|
||||
return $i;
|
||||
$resources = $this->getElementResources($element,$element_id);
|
||||
$i=0;
|
||||
foreach($resources as $nb => $resource) {
|
||||
$this->lines[$i] = fetchObjectByElement($resource['resource_id'],$resource['resource_type']);
|
||||
$i++;
|
||||
}
|
||||
return $i;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/AdherentTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -31,11 +31,10 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/adherents/class/adherent.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/adherents/class/adherent_type.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -49,72 +48,77 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return AdherentTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return AdherentTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n"; die(); }
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
|
||||
print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n";
|
||||
die();
|
||||
}
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,71 +128,71 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAdherentTypeCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new AdherentType($this->savdb);
|
||||
$localobject->statut=1;
|
||||
$localobject->libelle='Adherent type test';
|
||||
$localobject->cotisation=1;
|
||||
$localobject->vote=1;
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new AdherentType($this->savdb);
|
||||
$localobject->statut=1;
|
||||
$localobject->libelle='Adherent type test';
|
||||
$localobject->cotisation=1;
|
||||
$localobject->vote=1;
|
||||
$result=$localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject->id;
|
||||
return $localobject->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* testAdherentCreate
|
||||
*
|
||||
* @param int $fk_adherent_type Id type of member
|
||||
* @return int
|
||||
* @param int $fk_adherent_type Id type of member
|
||||
* @return int
|
||||
*
|
||||
* @depends testAdherentTypeCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentCreate($fk_adherent_type)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Adherent($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->typeid=$fk_adherent_type;
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new Adherent($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->typeid=$fk_adherent_type;
|
||||
$result=$localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testAdherentFetch
|
||||
*
|
||||
* @param int $id Id of object to fetch
|
||||
* @return object Fetched object
|
||||
* @param int $id Id of object to fetch
|
||||
* @return object Fetched object
|
||||
*
|
||||
* @depends testAdherentCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Adherent($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$localobject=new Adherent($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
@@ -222,78 +226,78 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testAdherentUpdate
|
||||
*
|
||||
* @param Adherent $localobject Member instance
|
||||
* @return Adherent
|
||||
* @param Adherent $localobject Member instance
|
||||
* @return Adherent
|
||||
*
|
||||
* @depends testAdherentFetchLogin
|
||||
* @depends testAdherentFetchLogin
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentUpdate(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$timestamp = dol_now();
|
||||
|
||||
$localobject->civility_id = 0;
|
||||
$localobject->login='newlogin';
|
||||
$localobject->societe='New company';
|
||||
$localobject->note='New note after update';
|
||||
//$localobject->note_public='New note public after update';
|
||||
$localobject->lastname='New name';
|
||||
$localobject->firstname='New firstname';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->statut=0;
|
||||
$localobject->login='newlogin';
|
||||
$localobject->societe='New company';
|
||||
$localobject->note='New note after update';
|
||||
//$localobject->note_public='New note public after update';
|
||||
$localobject->lastname='New name';
|
||||
$localobject->firstname='New firstname';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->statut=0;
|
||||
$localobject->morphy=0;
|
||||
$localobject->phone='New tel pro';
|
||||
$localobject->phone_perso='New tel perso';
|
||||
$localobject->phone_mobile='New tel mobile';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->phone='New tel pro';
|
||||
$localobject->phone_perso='New tel perso';
|
||||
$localobject->phone_mobile='New tel mobile';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->birth=$timestamp;
|
||||
$result=$localobject->update($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->update_note($localobject->note);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
//$result=$localobject->update_note_public($localobject->note_public);
|
||||
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
//$this->assertLessThan($result, 0);
|
||||
$result=$localobject->update($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->update_note($localobject->note);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
//$result=$localobject->update_note_public($localobject->note_public);
|
||||
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
//$this->assertLessThan($result, 0);
|
||||
|
||||
$newobject=new Adherent($this->savdb);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$newobject=new Adherent($this->savdb);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$this->assertEquals($localobject->civility_id, $newobject->civility_id);
|
||||
$this->assertEquals($localobject->login, $newobject->login);
|
||||
$this->assertEquals($localobject->societe, $newobject->societe);
|
||||
$this->assertEquals($localobject->note, $newobject->note);
|
||||
//$this->assertEquals($localobject->note_public, $newobject->note_public);
|
||||
$this->assertEquals($localobject->lastname, $newobject->lastname);
|
||||
$this->assertEquals($localobject->firstname, $newobject->firstname);
|
||||
$this->assertEquals($localobject->address, $newobject->address);
|
||||
$this->assertEquals($localobject->zip, $newobject->zip);
|
||||
$this->assertEquals($localobject->town, $newobject->town);
|
||||
$this->assertEquals($localobject->country_id, $newobject->country_id);
|
||||
$this->assertEquals('BE', $newobject->country_code);
|
||||
$this->assertEquals($localobject->login, $newobject->login);
|
||||
$this->assertEquals($localobject->societe, $newobject->societe);
|
||||
$this->assertEquals($localobject->note, $newobject->note);
|
||||
//$this->assertEquals($localobject->note_public, $newobject->note_public);
|
||||
$this->assertEquals($localobject->lastname, $newobject->lastname);
|
||||
$this->assertEquals($localobject->firstname, $newobject->firstname);
|
||||
$this->assertEquals($localobject->address, $newobject->address);
|
||||
$this->assertEquals($localobject->zip, $newobject->zip);
|
||||
$this->assertEquals($localobject->town, $newobject->town);
|
||||
$this->assertEquals($localobject->country_id, $newobject->country_id);
|
||||
$this->assertEquals('BE', $newobject->country_code);
|
||||
$this->assertEquals('Belgium', $newobject->country);
|
||||
$this->assertEquals($localobject->statut, $newobject->statut);
|
||||
$this->assertEquals($localobject->phone, $newobject->phone);
|
||||
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
|
||||
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
|
||||
$this->assertEquals($localobject->email, $newobject->email);
|
||||
$this->assertEquals($localobject->statut, $newobject->statut);
|
||||
$this->assertEquals($localobject->phone, $newobject->phone);
|
||||
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
|
||||
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
|
||||
$this->assertEquals($localobject->email, $newobject->email);
|
||||
$this->assertEquals($localobject->birth, $timestamp);
|
||||
$this->assertEquals($localobject->morphy, $newobject->morphy);
|
||||
|
||||
//We return newobject because of new values
|
||||
return $newobject;
|
||||
return $newobject;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,24 +434,24 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAdherentValidate(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testAdherentOther
|
||||
*
|
||||
* @param Adherent $localobject Member instance
|
||||
* @return int Id of object
|
||||
* @param Adherent $localobject Member instance
|
||||
* @return int Id of object
|
||||
*
|
||||
* @depends testAdherentValidate
|
||||
* The depends says test is run only if previous is ok
|
||||
@@ -520,17 +524,17 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAdherentDelete($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->delete($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->delete($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,18 +549,18 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAdherentTypeDelete($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobjectat=new AdherentType($this->savdb);
|
||||
$result=$localobjectat->fetch($localobject->typeid);
|
||||
$result=$localobjectat->delete();
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$localobjectat=new AdherentType($this->savdb);
|
||||
$result=$localobjectat->fetch($localobject->typeid);
|
||||
$result=$localobjectat->delete();
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject->id;
|
||||
return $localobject->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/AdminLibTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -29,11 +29,10 @@ global $conf,$user,$langs,$db;
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/admin.lib.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -43,74 +42,76 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class AdminLibTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return AdminLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return AdminLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,25 +121,25 @@ class AdminLibTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testVersionCompare()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=versioncompare(array(3,1,-4),array(3,1,1));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3,$result);
|
||||
$result=versioncompare(array(3,1,0),array(3,1,1));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3,$result);
|
||||
$result=versioncompare(array(3,1,0),array(3,2,0));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-2,$result);
|
||||
$result=versioncompare(array(3,1,0),array(3,1,0));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(0,$result);
|
||||
$result=versioncompare(array(3,1,-4),array(3,1,1));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3,$result);
|
||||
$result=versioncompare(array(3,1,0),array(3,1,1));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3,$result);
|
||||
$result=versioncompare(array(3,1,0),array(3,2,0));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-2,$result);
|
||||
$result=versioncompare(array(3,1,0),array(3,1,0));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(0,$result);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,32 +19,29 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/AllTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief This file is a test suite to run all unit tests
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
print "PHP Version: ".phpversion()."\n";
|
||||
print "Memory: ". ini_get('memory_limit')."\n";
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
//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';
|
||||
|
||||
if ($langs->defaultlang != 'en_US')
|
||||
{
|
||||
if ($langs->defaultlang != 'en_US') {
|
||||
print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n";
|
||||
exit;
|
||||
}
|
||||
if (! empty($conf->google->enabled))
|
||||
{
|
||||
print "Warning: Google module should not be enabled.\n";
|
||||
if (! empty($conf->google->enabled)) {
|
||||
print "Warning: Google module should not be enabled.\n";
|
||||
}
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -59,37 +56,37 @@ class AllTests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function suite()
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
|
||||
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
|
||||
|
||||
//require_once dirname(__FILE__).'/CoreTest.php';
|
||||
//$suite->addTestSuite('CoreTest');
|
||||
require_once dirname(__FILE__).'/AdminLibTest.php';
|
||||
$suite->addTestSuite('AdminLibTest');
|
||||
require_once dirname(__FILE__).'/DateLibTest.php';
|
||||
$suite->addTestSuite('DateLibTest');
|
||||
//require_once dirname(__FILE__).'/DateLibTzFranceTest.php';
|
||||
//$suite->addTestSuite('DateLibTzFranceTest');
|
||||
require_once dirname(__FILE__).'/MarginsLibTest.php';
|
||||
$suite->addTestSuite('MarginsLibTest');
|
||||
require_once dirname(__FILE__).'/FilesLibTest.php';
|
||||
$suite->addTestSuite('FilesLibTest');
|
||||
require_once dirname(__FILE__).'/JsonLibTest.php';
|
||||
$suite->addTestSuite('JsonLibTest');
|
||||
require_once dirname(__FILE__).'/ImagesLibTest.php';
|
||||
$suite->addTestSuite('ImagesLibTest');
|
||||
require_once dirname(__FILE__).'/FunctionsLibTest.php';
|
||||
$suite->addTestSuite('FunctionsLibTest');
|
||||
require_once dirname(__FILE__).'/Functions2LibTest.php';
|
||||
$suite->addTestSuite('Functions2LibTest');
|
||||
require_once dirname(__FILE__).'/XCalLibTest.php';
|
||||
$suite->addTestSuite('XCalLibTest');
|
||||
require_once dirname(__FILE__).'/AdminLibTest.php';
|
||||
$suite->addTestSuite('AdminLibTest');
|
||||
require_once dirname(__FILE__).'/DateLibTest.php';
|
||||
$suite->addTestSuite('DateLibTest');
|
||||
//require_once dirname(__FILE__).'/DateLibTzFranceTest.php';
|
||||
//$suite->addTestSuite('DateLibTzFranceTest');
|
||||
require_once dirname(__FILE__).'/MarginsLibTest.php';
|
||||
$suite->addTestSuite('MarginsLibTest');
|
||||
require_once dirname(__FILE__).'/FilesLibTest.php';
|
||||
$suite->addTestSuite('FilesLibTest');
|
||||
require_once dirname(__FILE__).'/JsonLibTest.php';
|
||||
$suite->addTestSuite('JsonLibTest');
|
||||
require_once dirname(__FILE__).'/ImagesLibTest.php';
|
||||
$suite->addTestSuite('ImagesLibTest');
|
||||
require_once dirname(__FILE__).'/FunctionsLibTest.php';
|
||||
$suite->addTestSuite('FunctionsLibTest');
|
||||
require_once dirname(__FILE__).'/Functions2LibTest.php';
|
||||
$suite->addTestSuite('Functions2LibTest');
|
||||
require_once dirname(__FILE__).'/XCalLibTest.php';
|
||||
$suite->addTestSuite('XCalLibTest');
|
||||
|
||||
require_once dirname(__FILE__).'/LangTest.php';
|
||||
$suite->addTestSuite('LangTest');
|
||||
require_once dirname(__FILE__).'/SqlTest.php';
|
||||
$suite->addTestSuite('SqlTest');
|
||||
require_once dirname(__FILE__).'/LangTest.php';
|
||||
$suite->addTestSuite('LangTest');
|
||||
require_once dirname(__FILE__).'/SqlTest.php';
|
||||
$suite->addTestSuite('SqlTest');
|
||||
|
||||
require_once dirname(__FILE__).'/SecurityTest.php';
|
||||
$suite->addTestSuite('SecurityTest');
|
||||
@@ -98,8 +95,8 @@ class AllTests
|
||||
$suite->addTestSuite('NumberingModulesTest');
|
||||
require_once dirname(__FILE__).'/PgsqlTest.php';
|
||||
$suite->addTestSuite('PgsqlTest');
|
||||
require_once dirname(__FILE__).'/PdfDocTest.php';
|
||||
$suite->addTestSuite('PdfDocTest');
|
||||
require_once dirname(__FILE__).'/PdfDocTest.php';
|
||||
$suite->addTestSuite('PdfDocTest');
|
||||
require_once dirname(__FILE__).'/BuildDocTest.php';
|
||||
$suite->addTestSuite('BuildDocTest');
|
||||
require_once dirname(__FILE__).'/CMailFileTest.php';
|
||||
@@ -147,13 +144,13 @@ class AllTests
|
||||
require_once dirname(__FILE__).'/FactureFournisseurTest.php';
|
||||
$suite->addTestSuite('FactureFournisseurTest');
|
||||
|
||||
require_once dirname(__FILE__).'/UserTest.php';
|
||||
require_once dirname(__FILE__).'/UserTest.php';
|
||||
$suite->addTestSuite('UserTest');
|
||||
require_once dirname(__FILE__).'/UserGroupTest.php';
|
||||
require_once dirname(__FILE__).'/UserGroupTest.php';
|
||||
$suite->addTestSuite('UserGroupTest');
|
||||
require_once dirname(__FILE__).'/BankAccountTest.php';
|
||||
$suite->addTestSuite('BankAccountTest');
|
||||
require_once dirname(__FILE__).'/CompanyBankAccountTest.php';
|
||||
require_once dirname(__FILE__).'/CompanyBankAccountTest.php';
|
||||
$suite->addTestSuite('CompanyBankAccountTest');
|
||||
require_once dirname(__FILE__).'/ChargeSocialesTest.php';
|
||||
$suite->addTestSuite('ChargeSocialesTest');
|
||||
@@ -195,7 +192,7 @@ class AllTests
|
||||
|
||||
// GUI
|
||||
require_once dirname(__FILE__).'/FormAdminTest.php';
|
||||
$suite->addTestSuite('FormAdminTest');
|
||||
$suite->addTestSuite('FormAdminTest');
|
||||
|
||||
|
||||
return $suite;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/ContratTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -29,11 +29,10 @@ global $conf,$user,$langs,$db;
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/compta/bank/class/account.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -49,127 +48,129 @@ $langs->load("main");
|
||||
*/
|
||||
class BankAccountTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return BankAccountTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return BankAccountTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testBankAccountCreate
|
||||
*
|
||||
* @return int
|
||||
* @return int
|
||||
*/
|
||||
public function testBankAccountCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Account($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->date_solde=dol_now();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new Account($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->date_solde=dol_now();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testBankAccountFetch
|
||||
*
|
||||
* @param int $id Id of contract
|
||||
* @return int
|
||||
* @param int $id Id of contract
|
||||
* @return int
|
||||
*
|
||||
* @depends testBankAccountCreate
|
||||
* @depends testBankAccountCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testBankAccountFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Account($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Account($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testBankAccountOther
|
||||
*
|
||||
* @param Object $localobject Object contract
|
||||
* @return int
|
||||
* @param Object $localobject Object contract
|
||||
* @return int
|
||||
*
|
||||
* @depends testBankAccountFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
@@ -197,27 +198,27 @@ class BankAccountTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testBankAccountDelete
|
||||
*
|
||||
* @param int $id Id of contract
|
||||
* @return int
|
||||
* @param int $id Id of contract
|
||||
* @return int
|
||||
*
|
||||
* @depends testBankAccountOther
|
||||
* @depends testBankAccountOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testBankAccountDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Account($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
$localobject=new Account($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/BuildDocTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -56,11 +56,10 @@ require_once dirname(__FILE__).'/../../htdocs/core/modules/project/modules_proje
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/fichinter/modules_fichinter.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/modules_expedition.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -74,35 +73,35 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return BuildDocTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return BuildDocTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
if (! $conf->facture->enabled) { print __METHOD__." invoice module not enabled\n"; die(); }
|
||||
if (! $conf->commande->enabled) { print __METHOD__." order module not enabled\n"; die(); }
|
||||
@@ -112,41 +111,43 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
if (! $conf->ficheinter->enabled) { print __METHOD__." intervention module not enabled\n"; die(); }
|
||||
if (! $conf->deplacement->enabled) { print __METHOD__." trip module not enabled\n"; die(); }
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,76 +157,76 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testFactureBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$conf->facture->dir_output.='/temp';
|
||||
$conf->facture->dir_output.='/temp';
|
||||
|
||||
$localobjectcom=new Commande($this->savdb);
|
||||
$localobjectcom->initAsSpecimen();
|
||||
$localobjectcom=new Commande($this->savdb);
|
||||
$localobjectcom->initAsSpecimen();
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject->createFromOrder($localobjectcom);
|
||||
$localobject->date_lim_reglement = dol_now() + 3600 * 24 *30;
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject->createFromOrder($localobjectcom);
|
||||
$localobject->date_lim_reglement = dol_now() + 3600 * 24 *30;
|
||||
|
||||
// Crabe (english)
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (english)
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (japanese)
|
||||
$newlangs1=new Translate("",$conf);
|
||||
$newlangs1->setDefaultLang('ja_JP');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs1);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (japanese)
|
||||
$newlangs1=new Translate("",$conf);
|
||||
$newlangs1->setDefaultLang('ja_JP');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs1);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (saudiarabia)
|
||||
$newlangs2a=new Translate("",$conf);
|
||||
$newlangs2a->setDefaultLang('sa_SA');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs2a);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (saudiarabia)
|
||||
$newlangs2a=new Translate("",$conf);
|
||||
$newlangs2a->setDefaultLang('sa_SA');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs2a);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (english_saudiarabia)
|
||||
$newlangs2b=new Translate("",$conf);
|
||||
$newlangs2b->setDefaultLang('en_SA');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs2b);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (english_saudiarabia)
|
||||
$newlangs2b=new Translate("",$conf);
|
||||
$newlangs2b->setDefaultLang('en_SA');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs2b);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (greek)
|
||||
$newlangs3=new Translate("",$conf);
|
||||
$newlangs3->setDefaultLang('el_GR');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs3);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (greek)
|
||||
$newlangs3=new Translate("",$conf);
|
||||
$newlangs3->setDefaultLang('el_GR');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs3);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (chinese)
|
||||
$newlangs4=new Translate("",$conf);
|
||||
$newlangs4->setDefaultLang('zh_CN');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs4);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (chinese)
|
||||
$newlangs4=new Translate("",$conf);
|
||||
$newlangs4->setDefaultLang('zh_CN');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs4);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (russian)
|
||||
$newlangs5=new Translate("",$conf);
|
||||
$newlangs5->setDefaultLang('ru_RU');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs5);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
// Crabe (russian)
|
||||
$newlangs5=new Translate("",$conf);
|
||||
$newlangs5->setDefaultLang('ru_RU');
|
||||
$localobject->modelpdf='crabe';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs5);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +248,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Canelle
|
||||
$localobject->modelpdf='canelle';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -274,7 +275,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Einstein
|
||||
$localobject->modelpdf='einstein';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -285,9 +286,9 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurBuild
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function testCommandeFournisseurBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -329,7 +330,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Azur
|
||||
$localobject->modelpdf='azur';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -355,7 +356,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Baleine
|
||||
$localobject->modelpdf='baleine';
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/CMailFileTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -29,11 +29,10 @@ global $conf,$user,$langs,$db;
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/class/CMailFile.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -47,70 +46,72 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class CMailFileTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CMailFile
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CMailFile
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,19 +121,19 @@ class CMailFileTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCMailFileText()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new CMailFile('Test','test@test.com','from@from.com','Message txt',array(),array(),array(),'','',1,0);
|
||||
$localobject=new CMailFile('Test','test@test.com','from@from.com','Message txt',array(),array(),array(),'','',1,0);
|
||||
|
||||
$result=$localobject->sendfile();
|
||||
$result=$localobject->sendfile();
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertFalse($result); // False because mail send disabled
|
||||
$this->assertFalse($result); // False because mail send disabled
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/CategorieTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -30,11 +30,10 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/categories/class/categorie.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -48,70 +47,72 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class CategorieTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CategorieTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CategorieTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,145 +122,145 @@ class CategorieTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCategorieCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
// We create a category
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
// We create a category
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Check it does not exist (return 0)
|
||||
$resultCheck=$localobject->already_exists();
|
||||
print __METHOD__." resultCheck=".$resultCheck."\n";
|
||||
$this->assertEquals(0, $resultCheck);
|
||||
// Check it does not exist (return 0)
|
||||
$resultCheck=$localobject->already_exists();
|
||||
print __METHOD__." resultCheck=".$resultCheck."\n";
|
||||
$this->assertEquals(0, $resultCheck);
|
||||
|
||||
// Create
|
||||
$resultFirstCreate=$localobject->create($user);
|
||||
print __METHOD__." resultFirstCreate=".$resultFirstCreate."\n";
|
||||
$this->assertGreaterThan(0, $resultFirstCreate);
|
||||
// Create
|
||||
$resultFirstCreate=$localobject->create($user);
|
||||
print __METHOD__." resultFirstCreate=".$resultFirstCreate."\n";
|
||||
$this->assertGreaterThan(0, $resultFirstCreate);
|
||||
|
||||
// We try to create another one with same ref
|
||||
$localobject2=new Categorie($this->savdb);
|
||||
$localobject2->initAsSpecimen();
|
||||
// We try to create another one with same ref
|
||||
$localobject2=new Categorie($this->savdb);
|
||||
$localobject2->initAsSpecimen();
|
||||
|
||||
// Check it does exist (return 1)
|
||||
$resultCheck=$localobject2->already_exists();
|
||||
print __METHOD__." resultCheck=".$resultCheck."\n";
|
||||
$this->assertGreaterThan(0, $resultCheck);
|
||||
// Check it does exist (return 1)
|
||||
$resultCheck=$localobject2->already_exists();
|
||||
print __METHOD__." resultCheck=".$resultCheck."\n";
|
||||
$this->assertGreaterThan(0, $resultCheck);
|
||||
|
||||
$resultSecondCreate=$localobject2->create($user);
|
||||
print __METHOD__." result=".$resultSecondCreate."\n";
|
||||
$this->assertEquals(-4, $resultSecondCreate);
|
||||
$resultSecondCreate=$localobject2->create($user);
|
||||
print __METHOD__." result=".$resultSecondCreate."\n";
|
||||
$this->assertEquals(-4, $resultSecondCreate);
|
||||
|
||||
return $resultFirstCreate;
|
||||
return $resultFirstCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCategorieProduct
|
||||
*
|
||||
* @param int $id Id of category
|
||||
* @return int
|
||||
* @param int $id Id of category
|
||||
* @return int
|
||||
*
|
||||
* @depends testCategorieCreate
|
||||
* @depends testCategorieCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCategorieProduct($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobjecttmp=new Categorie($this->savdb);
|
||||
$localobjecttmp->initAsSpecimen();
|
||||
$localobjecttmp->label='Specimen Category for product';
|
||||
$localobjecttmp->type=0; // product category
|
||||
$catid=$localobjecttmp->create($user);
|
||||
$localobjecttmp=new Categorie($this->savdb);
|
||||
$localobjecttmp->initAsSpecimen();
|
||||
$localobjecttmp->label='Specimen Category for product';
|
||||
$localobjecttmp->type=0; // product category
|
||||
$catid=$localobjecttmp->create($user);
|
||||
|
||||
print __METHOD__." catid=".$catid."\n";
|
||||
$this->assertGreaterThan(0, $catid);
|
||||
|
||||
// Try to create product linked to category
|
||||
$localobject2=new Product($this->savdb);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->ref.='-CATEG';
|
||||
$localobject2->tva_npr=1;
|
||||
$result=$localobject2->create($user);
|
||||
$cat = new Categorie($this->savdb);
|
||||
$cat->id = $catid;
|
||||
$result=$cat->add_type($localobject2,"product");
|
||||
$localobject2=new Product($this->savdb);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->ref.='-CATEG';
|
||||
$localobject2->tva_npr=1;
|
||||
$result=$localobject2->create($user);
|
||||
$cat = new Categorie($this->savdb);
|
||||
$cat->id = $catid;
|
||||
$result=$cat->add_type($localobject2,"product");
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Get list of categories for product
|
||||
$localcateg=new Categorie($this->savdb);
|
||||
$listofcateg=$localcateg->containing($localobject2->id, 'product', 'label');
|
||||
$this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should');
|
||||
// Get list of categories for product
|
||||
$localcateg=new Categorie($this->savdb);
|
||||
$listofcateg=$localcateg->containing($localobject2->id, 'product', 'label');
|
||||
$this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should');
|
||||
|
||||
return $id;
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCategorieFetch
|
||||
*
|
||||
* @param int $id Id of category
|
||||
* @return int
|
||||
* @param int $id Id of category
|
||||
* @return int
|
||||
*
|
||||
* @depends testCategorieProduct
|
||||
* @depends testCategorieProduct
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCategorieFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCategorieUpdate
|
||||
*
|
||||
* @param Category $localobject Category
|
||||
* @return int
|
||||
* @param Category $localobject Category
|
||||
* @return int
|
||||
|
||||
* @depends testCategorieFetch
|
||||
* @depends testCategorieFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCategorieUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCategorieOther
|
||||
*
|
||||
* @param Category $localobject Category
|
||||
* @return int
|
||||
* @param Category $localobject Category
|
||||
* @return int
|
||||
*
|
||||
* @depends testCategorieUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
@@ -289,50 +290,50 @@ class CategorieTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testCategorieDelete
|
||||
*
|
||||
* @param int $id Id of category
|
||||
* @return int
|
||||
* @param int $id Id of category
|
||||
* @return int
|
||||
*
|
||||
* @depends testCategorieOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCategorieDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCategorieStatic
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*
|
||||
* @depends testCategorieDelete
|
||||
*/
|
||||
public function testCategorieStatic()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$localobject=new Categorie($this->savdb);
|
||||
$retarray=$localobject->get_full_arbo(3);
|
||||
|
||||
print __METHOD__." retarray size=".count($retarray)."\n";
|
||||
$this->assertTrue(is_array($retarray));
|
||||
return $retarray;
|
||||
print __METHOD__." retarray size=".count($retarray)."\n";
|
||||
$this->assertTrue(is_array($retarray));
|
||||
return $retarray;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/CommandeFournisseurTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -30,11 +30,10 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.commande.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.product.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -49,71 +48,73 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CommandeFournisseurTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CommandeFournisseurTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,169 +124,169 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCommandeFournisseurCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// Set supplier and product to use
|
||||
$socid=1;
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($socid);
|
||||
$product=new ProductFournisseur($db);
|
||||
$product->fetch(0,'PIDRESS');
|
||||
if ($product->id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); }
|
||||
// Set supplier and product to use
|
||||
$socid=1;
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($socid);
|
||||
$product=new ProductFournisseur($db);
|
||||
$product->fetch(0,'PIDRESS');
|
||||
if ($product->id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); }
|
||||
|
||||
$quantity=10;
|
||||
$ref_fourn='SUPPLIER_REF_PHPUNIT';
|
||||
$tva_tx=19.6;
|
||||
$quantity=10;
|
||||
$ref_fourn='SUPPLIER_REF_PHPUNIT';
|
||||
$tva_tx=19.6;
|
||||
|
||||
// Create supplier price
|
||||
$result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
|
||||
$this->assertGreaterThanOrEqual(1, $result);
|
||||
$result=$product->update_buyprice($quantity, 10, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
// Create supplier price
|
||||
$result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
|
||||
$this->assertGreaterThanOrEqual(1, $result);
|
||||
$result=$product->update_buyprice($quantity, 10, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
|
||||
// Create supplier order with a too low quantity
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line too low";
|
||||
$line->qty=1; // So lower than $quantity
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject->lines[]=$line;
|
||||
// Create supplier order with a too low quantity
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line too low";
|
||||
$line->qty=1; // So lower than $quantity
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject->lines[]=$line;
|
||||
|
||||
$result=$localobject->create($user);
|
||||
$result=$localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-1, $result); // must be -1 because quantity is lower than minimum of supplier price
|
||||
$this->assertEquals(-1, $result); // must be -1 because quantity is lower than minimum of supplier price
|
||||
|
||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''";
|
||||
$db->query($sql);
|
||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''";
|
||||
$db->query($sql);
|
||||
|
||||
// Create supplier order
|
||||
$localobject2=new CommandeFournisseur($db);
|
||||
$localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1
|
||||
$localobject2->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line ok";
|
||||
$line->qty=10; // So enough quantity
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject2->lines[]=$line;
|
||||
// Create supplier order
|
||||
$localobject2=new CommandeFournisseur($db);
|
||||
$localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1
|
||||
$localobject2->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line ok";
|
||||
$line->qty=10; // So enough quantity
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject2->lines[]=$line;
|
||||
|
||||
$result=$localobject2->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
$result=$localobject2->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurFetch
|
||||
*
|
||||
* @param int $id Id of supplier order
|
||||
* @return void
|
||||
* @param int $id Id of supplier order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFournisseurCreate
|
||||
* @depends testCommandeFournisseurCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFournisseurFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new CommandeFournisseur($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new CommandeFournisseur($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurValid
|
||||
*
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFournisseurFetch
|
||||
* @depends testCommandeFournisseurFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFournisseurValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->valid($user);
|
||||
$result=$localobject->valid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurApprove
|
||||
*
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFournisseurValid
|
||||
* @depends testCommandeFournisseurValid
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFournisseurApprove($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->approve($user);
|
||||
$result=$localobject->approve($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurCancel
|
||||
*
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFournisseurValid
|
||||
* @depends testCommandeFournisseurValid
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFournisseurCancel($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->cancel($user);
|
||||
$result=$localobject->cancel($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurOther
|
||||
*
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
* @param Object $localobject Supplier order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFournisseurCancel
|
||||
* The depends says test is run only if previous is ok
|
||||
@@ -314,27 +315,27 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testCommandeFournisseurDelete
|
||||
*
|
||||
* @param int $id Id of order
|
||||
* @return void
|
||||
* @param int $id Id of order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFournisseurOther
|
||||
* @depends testCommandeFournisseurOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFournisseurDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new CommandeFournisseur($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject=new CommandeFournisseur($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/CommandeTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -29,11 +29,10 @@ global $conf,$user,$langs,$db;
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/commande/class/commande.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -47,173 +46,176 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class CommandeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CommandeTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CommandeTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeCreate
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testCommandeCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeFetch
|
||||
*
|
||||
* @param int $id Id order
|
||||
* @return Commande
|
||||
* @param int $id Id order
|
||||
* @return Commande
|
||||
*
|
||||
* @depends testCommandeCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Commande($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeValid
|
||||
*
|
||||
* @param Object $localobject Order
|
||||
* @return void
|
||||
* @param Object $localobject Order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->valid($user);
|
||||
$result=$localobject->valid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeCancel
|
||||
*
|
||||
* @param Object $localobject Order
|
||||
* @return void
|
||||
* @param Object $localobject Order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeValid
|
||||
* @depends testCommandeValid
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeCancel($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->cancel();
|
||||
$result=$localobject->cancel();
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCommandeOther
|
||||
*
|
||||
* @param Object $localobject Order
|
||||
* @return void
|
||||
* @param Object $localobject Order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeCancel
|
||||
* The depends says test is run only if previous is ok
|
||||
@@ -241,27 +243,27 @@ class CommandeTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testCommandeDelete
|
||||
*
|
||||
* @param int $id Id of order
|
||||
* @return void
|
||||
* @param int $id Id of order
|
||||
* @return void
|
||||
*
|
||||
* @depends testCommandeOther
|
||||
* @depends testCommandeOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject=new Commande($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/CommonObjectTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -30,11 +30,10 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/commande/class/commande.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/projet/class/project.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -48,138 +47,140 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class CommonObjectTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CommonObjectTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CommonObjectTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testFetchUser
|
||||
* testFetchUser
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testFetchUser()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->fetch(1);
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->fetch(1);
|
||||
|
||||
$result=$localobject->fetch_user(1);
|
||||
$result=$localobject->fetch_user(1);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($localobject->user->id, 0);
|
||||
return $result;
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($localobject->user->id, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testFetchProjet
|
||||
* testFetchProjet
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testFetchProjet()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->fetch(1);
|
||||
$result=$localobject->fetch_projet();
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->fetch(1);
|
||||
$result=$localobject->fetch_projet();
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result,0);
|
||||
return $result;
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result,0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testFetchThirdParty
|
||||
* testFetchThirdParty
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testFetchThirdParty()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->fetch(1);
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject->fetch(1);
|
||||
|
||||
$result=$localobject->fetch_thirdparty();
|
||||
$result=$localobject->fetch_thirdparty();
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result,0);
|
||||
return $result;
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result,0);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -89,6 +89,8 @@ class ContactTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class ContratTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/CoreTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -49,70 +49,72 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
|
||||
*/
|
||||
class CoreTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CoreTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
//print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return CoreTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
//print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
//$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -123,177 +125,170 @@ class CoreTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDetectURLROOT()
|
||||
{
|
||||
global $dolibarr_main_prod;
|
||||
global $dolibarr_main_prod;
|
||||
|
||||
global $dolibarr_main_url_root;
|
||||
global $dolibarr_main_data_root;
|
||||
global $dolibarr_main_document_root;
|
||||
global $dolibarr_main_data_root_alt;
|
||||
global $dolibarr_main_document_root_alt;
|
||||
global $dolibarr_main_db_host;
|
||||
global $dolibarr_main_db_port;
|
||||
global $dolibarr_main_db_type;
|
||||
global $dolibarr_main_db_prefix;
|
||||
global $dolibarr_main_url_root;
|
||||
global $dolibarr_main_data_root;
|
||||
global $dolibarr_main_document_root;
|
||||
global $dolibarr_main_data_root_alt;
|
||||
global $dolibarr_main_document_root_alt;
|
||||
global $dolibarr_main_db_host;
|
||||
global $dolibarr_main_db_port;
|
||||
global $dolibarr_main_db_type;
|
||||
global $dolibarr_main_db_prefix;
|
||||
|
||||
$testtodo=3;
|
||||
$testtodo=3;
|
||||
|
||||
// Case 1:
|
||||
// Test for subdir dolibarrnew (that point to htdocs) in root directory /var/www
|
||||
// URL: http://localhost/dolibarrnew/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Create link from htdocs to /var/www/dolibarrnew
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/dolibarrnew';
|
||||
if ($testtodo == 1)
|
||||
{
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/dolibarrnew/admin/system/phpinfo.php';
|
||||
$expectedresult='/dolibarrnew';
|
||||
}
|
||||
// Case 1:
|
||||
// Test for subdir dolibarrnew (that point to htdocs) in root directory /var/www
|
||||
// URL: http://localhost/dolibarrnew/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Create link from htdocs to /var/www/dolibarrnew
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/dolibarrnew';
|
||||
if ($testtodo == 1) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/dolibarrnew/admin/system/phpinfo.php';
|
||||
$expectedresult='/dolibarrnew';
|
||||
}
|
||||
|
||||
// Case 2:
|
||||
// Test for subdir aaa (that point to dolibarr) in root directory /var/www
|
||||
// URL: http://localhost/aaa/htdocs/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Create link from dolibarr to /var/www/aaa
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/aaa/htdocs';
|
||||
if ($testtodo == 2)
|
||||
{
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/aaa/htdocs/admin/system/phpinfo.php';
|
||||
$expectedresult='/aaa/htdocs';
|
||||
}
|
||||
// Case 2:
|
||||
// Test for subdir aaa (that point to dolibarr) in root directory /var/www
|
||||
// URL: http://localhost/aaa/htdocs/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Create link from dolibarr to /var/www/aaa
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/aaa/htdocs';
|
||||
if ($testtodo == 2) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/aaa/htdocs/admin/system/phpinfo.php';
|
||||
$expectedresult='/aaa/htdocs';
|
||||
}
|
||||
|
||||
// Case 3:
|
||||
// Test for virtual host localhostdolibarrnew that point to htdocs directory with
|
||||
// a direct document root
|
||||
// URL: http://localhostdolibarrnew/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Create virtual host localhostdolibarrnew that point to /home/ldestailleur/git/dolibarr/htdocs
|
||||
// - Put into conf.php $dolibarr_main_document_root='/home/ldestailleur/git/dolibarr/htdocs';
|
||||
if ($testtodo == 3)
|
||||
{
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/home/ldestailleur/git/dolibarr/htdocs';
|
||||
$_SERVER["SCRIPT_NAME"]='/admin/system/phpinfo.php';
|
||||
$expectedresult='';
|
||||
}
|
||||
// Case 3:
|
||||
// Test for virtual host localhostdolibarrnew that point to htdocs directory with
|
||||
// a direct document root
|
||||
// URL: http://localhostdolibarrnew/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Create virtual host localhostdolibarrnew that point to /home/ldestailleur/git/dolibarr/htdocs
|
||||
// - Put into conf.php $dolibarr_main_document_root='/home/ldestailleur/git/dolibarr/htdocs';
|
||||
if ($testtodo == 3) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/home/ldestailleur/git/dolibarr/htdocs';
|
||||
$_SERVER["SCRIPT_NAME"]='/admin/system/phpinfo.php';
|
||||
$expectedresult='';
|
||||
}
|
||||
|
||||
// Case 4:
|
||||
// Test for virtual host localhostdolibarrnew that point to htdocs directory with
|
||||
// a symbolic link
|
||||
// URL: http://localhostdolibarrnew/admin/system/phpinfo.php
|
||||
if ($testtodo == 4)
|
||||
{
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www/dolibarr'; // This is a link that point to /home/ldestail/workspace/dolibarr/htdocs
|
||||
$_SERVER["SCRIPT_NAME"]='/admin/system/phpinfo.php';
|
||||
$expectedresult='';
|
||||
}
|
||||
// Case 4:
|
||||
// Test for virtual host localhostdolibarrnew that point to htdocs directory with
|
||||
// a symbolic link
|
||||
// URL: http://localhostdolibarrnew/admin/system/phpinfo.php
|
||||
if ($testtodo == 4) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www/dolibarr'; // This is a link that point to /home/ldestail/workspace/dolibarr/htdocs
|
||||
$_SERVER["SCRIPT_NAME"]='/admin/system/phpinfo.php';
|
||||
$expectedresult='';
|
||||
}
|
||||
|
||||
// Case 5:
|
||||
// Test for alias /dolibarralias, Test when using nginx, Test when using lighttpd
|
||||
// URL: http://localhost/dolibarralias/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Copy content of dolibarr project into /var/www/dolibarr
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/dolibarr/htdocs';
|
||||
// - Put into conf.php $dolibarr_main_url_root='http://localhost/dolibarralias'; (because autodetect will fails in this case)
|
||||
if ($testtodo == 5)
|
||||
{
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/dolibarralias/admin/system/phpinfo.php';
|
||||
$expectedresult='/dolibarralias';
|
||||
}
|
||||
// Case 5:
|
||||
// Test for alias /dolibarralias, Test when using nginx, Test when using lighttpd
|
||||
// URL: http://localhost/dolibarralias/admin/system/phpinfo.php
|
||||
// To prepare this test:
|
||||
// - Copy content of dolibarr project into /var/www/dolibarr
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/dolibarr/htdocs';
|
||||
// - Put into conf.php $dolibarr_main_url_root='http://localhost/dolibarralias'; (because autodetect will fails in this case)
|
||||
if ($testtodo == 5) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/dolibarralias/admin/system/phpinfo.php';
|
||||
$expectedresult='/dolibarralias';
|
||||
}
|
||||
|
||||
// Force to rerun filefunc.inc.php
|
||||
include dirname(__FILE__).'/../../htdocs/filefunc.inc.php';
|
||||
// Force to rerun filefunc.inc.php
|
||||
include dirname(__FILE__).'/../../htdocs/filefunc.inc.php';
|
||||
|
||||
print __METHOD__." DOL_MAIN_URL_ROOT=".DOL_MAIN_URL_ROOT."\n";
|
||||
print __METHOD__." DOL_URL_ROOT=".DOL_URL_ROOT."\n";
|
||||
$this->assertEquals(DOL_URL_ROOT,$expectedresult);
|
||||
print __METHOD__." DOL_MAIN_URL_ROOT=".DOL_MAIN_URL_ROOT."\n";
|
||||
print __METHOD__." DOL_URL_ROOT=".DOL_URL_ROOT."\n";
|
||||
$this->assertEquals(DOL_URL_ROOT,$expectedresult);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testSqlAndScriptInject
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testSqlAndScriptInject()
|
||||
{
|
||||
global $dolibarr_main_prod;
|
||||
global $dolibarr_main_prod;
|
||||
|
||||
global $dolibarr_main_url_root;
|
||||
global $dolibarr_main_data_root;
|
||||
global $dolibarr_main_document_root;
|
||||
global $dolibarr_main_data_root_alt;
|
||||
global $dolibarr_main_document_root_alt;
|
||||
global $dolibarr_main_db_host;
|
||||
global $dolibarr_main_db_port;
|
||||
global $dolibarr_main_db_type;
|
||||
global $dolibarr_main_db_prefix;
|
||||
global $dolibarr_main_url_root;
|
||||
global $dolibarr_main_data_root;
|
||||
global $dolibarr_main_document_root;
|
||||
global $dolibarr_main_data_root_alt;
|
||||
global $dolibarr_main_document_root_alt;
|
||||
global $dolibarr_main_db_host;
|
||||
global $dolibarr_main_db_port;
|
||||
global $dolibarr_main_db_type;
|
||||
global $dolibarr_main_db_prefix;
|
||||
|
||||
|
||||
// This is code copied from main.inc.php
|
||||
// This is code copied from main.inc.php
|
||||
|
||||
/**
|
||||
* Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF).
|
||||
*
|
||||
* @param string $val Value
|
||||
* @param string $type 1=GET, 0=POST, 2=PHP_SELF
|
||||
* @return int >0 if there is an injection
|
||||
*/
|
||||
function test_sql_and_script_inject($val, $type)
|
||||
{
|
||||
$sql_inj = 0;
|
||||
// For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests)
|
||||
if ($type != 2)
|
||||
{
|
||||
$sql_inj += preg_match('/delete[\s]+from/i', $val);
|
||||
$sql_inj += preg_match('/create[\s]+table/i', $val);
|
||||
$sql_inj += preg_match('/update.+set.+=/i', $val);
|
||||
$sql_inj += preg_match('/insert[\s]+into/i', $val);
|
||||
$sql_inj += preg_match('/select.+from/i', $val);
|
||||
$sql_inj += preg_match('/union.+select/i', $val);
|
||||
$sql_inj += preg_match('/(\.\.%2f)+/i', $val);
|
||||
}
|
||||
// For XSS Injection done by adding javascript with script
|
||||
// This is all cases a browser consider text is javascript:
|
||||
// When it found '<script', 'javascript:', '<style', 'onload\s=' on body tag, '="&' on a tag size with old browsers
|
||||
// All examples on page: http://ha.ckers.org/xss.html#XSScalc
|
||||
$sql_inj += preg_match('/<script/i', $val);
|
||||
if (! defined('NOSTYLECHECK')) $sql_inj += preg_match('/<style/i', $val);
|
||||
$sql_inj += preg_match('/base[\s]+href/i', $val);
|
||||
if ($type == 1)
|
||||
{
|
||||
$sql_inj += preg_match('/javascript:/i', $val);
|
||||
$sql_inj += preg_match('/vbscript:/i', $val);
|
||||
}
|
||||
// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
|
||||
if ($type == 1) $sql_inj += preg_match('/"/i', $val); // We refused " in GET parameters value
|
||||
if ($type == 2) $sql_inj += preg_match('/[\s;"]/', $val); // PHP_SELF is an url and must match url syntax
|
||||
return $sql_inj;
|
||||
}
|
||||
/**
|
||||
* Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF).
|
||||
*
|
||||
* @param string $val Value
|
||||
* @param string $type 1=GET, 0=POST, 2=PHP_SELF
|
||||
* @return int >0 if there is an injection
|
||||
*/
|
||||
function test_sql_and_script_inject($val, $type)
|
||||
{
|
||||
$sql_inj = 0;
|
||||
// For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests)
|
||||
if ($type != 2) {
|
||||
$sql_inj += preg_match('/delete[\s]+from/i', $val);
|
||||
$sql_inj += preg_match('/create[\s]+table/i', $val);
|
||||
$sql_inj += preg_match('/update.+set.+=/i', $val);
|
||||
$sql_inj += preg_match('/insert[\s]+into/i', $val);
|
||||
$sql_inj += preg_match('/select.+from/i', $val);
|
||||
$sql_inj += preg_match('/union.+select/i', $val);
|
||||
$sql_inj += preg_match('/(\.\.%2f)+/i', $val);
|
||||
}
|
||||
// For XSS Injection done by adding javascript with script
|
||||
// This is all cases a browser consider text is javascript:
|
||||
// When it found '<script', 'javascript:', '<style', 'onload\s=' on body tag, '="&' on a tag size with old browsers
|
||||
// All examples on page: http://ha.ckers.org/xss.html#XSScalc
|
||||
$sql_inj += preg_match('/<script/i', $val);
|
||||
if (! defined('NOSTYLECHECK')) $sql_inj += preg_match('/<style/i', $val);
|
||||
$sql_inj += preg_match('/base[\s]+href/i', $val);
|
||||
if ($type == 1) {
|
||||
$sql_inj += preg_match('/javascript:/i', $val);
|
||||
$sql_inj += preg_match('/vbscript:/i', $val);
|
||||
}
|
||||
// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
|
||||
if ($type == 1) $sql_inj += preg_match('/"/i', $val); // We refused " in GET parameters value
|
||||
if ($type == 2) $sql_inj += preg_match('/[\s;"]/', $val); // PHP_SELF is an url and must match url syntax
|
||||
return $sql_inj;
|
||||
}
|
||||
|
||||
//type=2 key=0 value=/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices
|
||||
$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices';
|
||||
$result=test_sql_and_script_inject($_SERVER["PHP_SELF"],2);
|
||||
$expectedresult=1;
|
||||
//type=2 key=0 value=/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices
|
||||
$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices';
|
||||
$result=test_sql_and_script_inject($_SERVER["PHP_SELF"],2);
|
||||
$expectedresult=1;
|
||||
|
||||
$this->assertEquals($result,$expectedresult);
|
||||
$this->assertEquals($result,$expectedresult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -85,6 +85,8 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class DiscountTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -83,6 +83,8 @@ class EntrepotTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -84,6 +84,8 @@ class ExportTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -81,6 +81,8 @@ class FactureRecTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/FactureTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -29,11 +29,10 @@ global $conf,$user,$langs,$db;
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -47,74 +46,76 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class FactureTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return FactureTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return FactureTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
if (! empty($conf->ecotaxdeee->enabled)) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(); }
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,107 +125,107 @@ class FactureTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testFactureCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testFactureFetch
|
||||
*
|
||||
* @param int $id Id invoice
|
||||
* @return int
|
||||
* @param int $id Id invoice
|
||||
* @return int
|
||||
*
|
||||
* @depends testFactureCreate
|
||||
* @depends testFactureCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testFactureFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Facture($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testFactureFetch
|
||||
*
|
||||
* @param Object $localobject Invoice
|
||||
* @return int
|
||||
* @param Object $localobject Invoice
|
||||
* @return int
|
||||
*
|
||||
* @depends testFactureFetch
|
||||
* @depends testFactureFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testFactureUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$this->changeProperties($localobject);
|
||||
$result=$localobject->update($user);
|
||||
$result=$localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testFactureValid
|
||||
*
|
||||
* @param Object $localobject Invoice
|
||||
* @return void
|
||||
* @param Object $localobject Invoice
|
||||
* @return void
|
||||
*
|
||||
* @depends testFactureUpdate
|
||||
* @depends testFactureUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testFactureValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$result=$localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
// Test everything are still same than specimen
|
||||
$newlocalobject=new Facture($this->savdb);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
// Test everything are still same than specimen
|
||||
$newlocalobject=new Facture($this->savdb);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc')), array()); // Actual, Expected
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testFactureOther
|
||||
*
|
||||
* @param Object $localobject Invoice
|
||||
* @return int
|
||||
* @param Object $localobject Invoice
|
||||
* @return int
|
||||
*
|
||||
* @depends testFactureValid
|
||||
* The depends says test is run only if previous is ok
|
||||
@@ -256,34 +257,34 @@ class FactureTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testFactureDelete
|
||||
*
|
||||
* @param int $id Id of invoice
|
||||
* @return int
|
||||
* @param int $id Id of invoice
|
||||
* @return int
|
||||
*
|
||||
* @depends testFactureOther
|
||||
* @depends testFactureOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testFactureDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
$localobject=new Facture($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an object to test updates
|
||||
*
|
||||
* @param mixed $localobject Object Facture
|
||||
* @return void
|
||||
* @param mixed $localobject Object Facture
|
||||
* @return void
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
@@ -294,11 +295,11 @@ class FactureTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* Compare all public properties values of 2 objects
|
||||
*
|
||||
* @param Object $oA Object operand 1
|
||||
* @param Object $oB Object operand 2
|
||||
* @param boolean $ignoretype False will not report diff if type of value differs
|
||||
* @param array $fieldstoignorearray Array of fields to ignore in diff
|
||||
* @return array Array with differences
|
||||
* @param Object $oA Object operand 1
|
||||
* @param Object $oB Object operand 2
|
||||
* @param boolean $ignoretype False will not report diff if type of value differs
|
||||
* @param array $fieldstoignorearray Array of fields to ignore in diff
|
||||
* @return array Array with differences
|
||||
*/
|
||||
public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
|
||||
{
|
||||
|
||||
@@ -80,6 +80,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class FichinterTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -81,6 +81,8 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class FormAdminTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -83,6 +83,8 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -83,6 +83,8 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -83,6 +83,8 @@ class HolidayTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -81,6 +81,8 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -82,6 +82,8 @@ class ImportTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -82,6 +82,8 @@ class JsonLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -92,6 +92,8 @@ class LangTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -79,6 +79,8 @@ class ModulesTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -79,6 +79,8 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -84,6 +84,8 @@ class PaypalTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -83,6 +83,8 @@ class PdfDocTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -83,6 +83,8 @@ class PgsqlTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -81,6 +81,8 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/ProductTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -31,9 +31,9 @@ require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -43,169 +43,170 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class ProductTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return ProductTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return ProductTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
if (empty($conf->produit->enabled)) { print __METHOD__." Module Product must be enabled.\n"; die(); }
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
if (empty($conf->produit->enabled)) { print __METHOD__." Module Product must be enabled.\n"; die(); }
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
// teardownafterclass
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testProductCreate
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testProductCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Product($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new Product($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testProductFetch
|
||||
*
|
||||
* @param int $id Id product
|
||||
* @return Product
|
||||
* @param int $id Id product
|
||||
* @return Product
|
||||
*
|
||||
* @depends testProductCreate
|
||||
* @depends testProductCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testProductFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Product($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Product($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testProductUpdate
|
||||
*
|
||||
* @param Product $localobject Product
|
||||
* @return void
|
||||
* @param Product $localobject Product
|
||||
* @return void
|
||||
*
|
||||
* @depends testProductFetch
|
||||
* @depends testProductFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testProductUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($localobject->id,$user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($localobject->id,$user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testProductOther
|
||||
*
|
||||
* @param Product $localobject Product
|
||||
* @return void
|
||||
* @param Product $localobject Product
|
||||
* @return void
|
||||
*
|
||||
* @depends testProductUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testProductOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
return $localobject->id;
|
||||
@@ -214,34 +215,34 @@ class ProductTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testProductDelete
|
||||
*
|
||||
* @param int $id Id of product
|
||||
* @return void
|
||||
* @param int $id Id of product
|
||||
* @return void
|
||||
*
|
||||
* @depends testProductOther
|
||||
* @depends testProductOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testProductDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Product($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Product($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->delete($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testProductStatic
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testProductStatic()
|
||||
{
|
||||
|
||||
@@ -81,6 +81,8 @@ class ProjectTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -80,6 +80,8 @@ class PropalTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -92,6 +92,8 @@ class ScriptsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -92,6 +92,8 @@ class SecurityTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
@@ -18,23 +18,22 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/SocieteTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
//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/societe/class/societe.class.php';
|
||||
$langs->load("dict");
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -48,35 +47,35 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return SocieteTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return SocieteTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON != 'mod_codeclient_monkey') { print "\n".__METHOD__." third party ref checker must be setup to 'mod_codeclient_monkey' not to '".$conf->global->SOCIETE_CODECLIENT_ADDON."'.\n"; die(); }
|
||||
|
||||
@@ -84,40 +83,42 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,130 +128,130 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSocieteCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Societe($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new Societe($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testSocieteFetch
|
||||
*
|
||||
* @param int $id Company id
|
||||
* @return Societe $localobject Company
|
||||
*
|
||||
* @param int $id Company id
|
||||
* @return Societe $localobject Company
|
||||
*
|
||||
* @depends testSocieteCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testSocieteFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Societe($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Societe($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->verify();
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertEquals($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testSocieteUpdate
|
||||
*
|
||||
* @param Societe $localobject Company
|
||||
* @return Societe $localobject Company
|
||||
*
|
||||
* @depends testSocieteFetch
|
||||
* @param Societe $localobject Company
|
||||
* @return Societe $localobject Company
|
||||
*
|
||||
* @depends testSocieteFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testSocieteUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject->note_private='New private note after update';
|
||||
$localobject->note_public='New public note after update';
|
||||
$localobject->name='New name';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->status=0;
|
||||
$localobject->phone='New tel';
|
||||
$localobject->fax='New fax';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->url='New url';
|
||||
$localobject->idprof1='new idprof1';
|
||||
$localobject->idprof2='new idprof2';
|
||||
$localobject->idprof3='new idprof3';
|
||||
$localobject->idprof4='new idprof4';
|
||||
$localobject->note_private='New private note after update';
|
||||
$localobject->note_public='New public note after update';
|
||||
$localobject->name='New name';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->status=0;
|
||||
$localobject->phone='New tel';
|
||||
$localobject->fax='New fax';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->url='New url';
|
||||
$localobject->idprof1='new idprof1';
|
||||
$localobject->idprof2='new idprof2';
|
||||
$localobject->idprof3='new idprof3';
|
||||
$localobject->idprof4='new idprof4';
|
||||
|
||||
$result=$localobject->update($localobject->id,$user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->update_note($localobject->note_private,'_private');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note_private error');
|
||||
|
||||
$result=$localobject->update_note_public($localobject->note_public);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note_public error');
|
||||
|
||||
$newobject=new Societe($this->savdb);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
$result=$localobject->update($localobject->id,$user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$this->assertEquals($localobject->note_private, $newobject->note_private);
|
||||
//$this->assertEquals($localobject->note_public, $newobject->note_public);
|
||||
$this->assertEquals($localobject->name, $newobject->name);
|
||||
$this->assertEquals($localobject->address, $newobject->address);
|
||||
$this->assertEquals($localobject->zip, $newobject->zip);
|
||||
$this->assertEquals($localobject->town, $newobject->town);
|
||||
$this->assertEquals($localobject->country_id, $newobject->country_id);
|
||||
$this->assertEquals('BE', $newobject->country_code);
|
||||
$this->assertEquals($localobject->status, $newobject->status);
|
||||
$this->assertEquals($localobject->phone, $newobject->phone);
|
||||
$this->assertEquals($localobject->fax, $newobject->fax);
|
||||
$this->assertEquals($localobject->email, $newobject->email);
|
||||
$this->assertEquals($localobject->url, $newobject->url);
|
||||
$this->assertEquals($localobject->idprof1, $newobject->idprof1);
|
||||
$this->assertEquals($localobject->idprof2, $newobject->idprof2);
|
||||
$this->assertEquals($localobject->idprof3, $newobject->idprof3);
|
||||
$this->assertEquals($localobject->idprof4, $newobject->idprof4);
|
||||
$result=$localobject->update_note($localobject->note_private,'_private');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note_private error');
|
||||
|
||||
return $localobject;
|
||||
$result=$localobject->update_note_public($localobject->note_public);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note_public error');
|
||||
|
||||
$newobject=new Societe($this->savdb);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$this->assertEquals($localobject->note_private, $newobject->note_private);
|
||||
//$this->assertEquals($localobject->note_public, $newobject->note_public);
|
||||
$this->assertEquals($localobject->name, $newobject->name);
|
||||
$this->assertEquals($localobject->address, $newobject->address);
|
||||
$this->assertEquals($localobject->zip, $newobject->zip);
|
||||
$this->assertEquals($localobject->town, $newobject->town);
|
||||
$this->assertEquals($localobject->country_id, $newobject->country_id);
|
||||
$this->assertEquals('BE', $newobject->country_code);
|
||||
$this->assertEquals($localobject->status, $newobject->status);
|
||||
$this->assertEquals($localobject->phone, $newobject->phone);
|
||||
$this->assertEquals($localobject->fax, $newobject->fax);
|
||||
$this->assertEquals($localobject->email, $newobject->email);
|
||||
$this->assertEquals($localobject->url, $newobject->url);
|
||||
$this->assertEquals($localobject->idprof1, $newobject->idprof1);
|
||||
$this->assertEquals($localobject->idprof2, $newobject->idprof2);
|
||||
$this->assertEquals($localobject->idprof3, $newobject->idprof3);
|
||||
$this->assertEquals($localobject->idprof4, $newobject->idprof4);
|
||||
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testIdProfCheck
|
||||
*
|
||||
* @param Societe $localobject Company
|
||||
* @return Societe $localobject Company
|
||||
* @param Societe $localobject Company
|
||||
* @return Societe $localobject Company
|
||||
*
|
||||
* @depends testSocieteUpdate
|
||||
* @depends testSocieteUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testIdProfCheck($localobject)
|
||||
@@ -302,19 +303,19 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testSocieteOther
|
||||
*
|
||||
* @param Societe $localobject Company
|
||||
* @return int $id Id of company
|
||||
* @param Societe $localobject Company
|
||||
* @return int $id Id of company
|
||||
*
|
||||
* @depends testIdProfCheck
|
||||
* @depends testIdProfCheck
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testSocieteOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->set_as_client();
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -347,34 +348,34 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testSocieteDelete
|
||||
*
|
||||
* @param int $id Id of company
|
||||
* @return int
|
||||
* @param int $id Id of company
|
||||
* @return int
|
||||
*
|
||||
* @depends testSocieteOther
|
||||
* @depends testSocieteOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testSocieteDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Societe($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new Societe($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->delete($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testSocieteStatic
|
||||
*
|
||||
* @return void
|
||||
* testSocieteStatic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSocieteStatic()
|
||||
{
|
||||
@@ -394,7 +395,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testSocieteGetFullAddress
|
||||
*
|
||||
* @return int $id Id of company
|
||||
* @return int $id Id of company
|
||||
*/
|
||||
public function testSocieteGetFullAddress()
|
||||
{
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/SqlTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -59,71 +59,73 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class SqlTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return SecurityTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return SecurityTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,38 +135,37 @@ class SqlTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSql()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration');
|
||||
$listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration');
|
||||
|
||||
foreach ($listofsqldir as $dir)
|
||||
{
|
||||
print 'Process dir '.$dir."\n";
|
||||
$filesarray = scandir($dir);
|
||||
foreach($filesarray as $key => $file)
|
||||
{
|
||||
if (! preg_match('/\.sql$/',$file)) continue;
|
||||
foreach ($listofsqldir as $dir) {
|
||||
print 'Process dir '.$dir."\n";
|
||||
$filesarray = scandir($dir);
|
||||
foreach($filesarray as $key => $file) {
|
||||
if (! preg_match('/\.sql$/',$file))
|
||||
continue;
|
||||
|
||||
print 'Check sql file '.$file."\n";
|
||||
$filecontent=file_get_contents($dir.'/'.$file);
|
||||
print 'Check sql file '.$file."\n";
|
||||
$filecontent=file_get_contents($dir.'/'.$file);
|
||||
|
||||
$result=strpos($filecontent,'`');
|
||||
print __METHOD__." Result for checking we don't have back quote = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.');
|
||||
$result=strpos($filecontent,'`');
|
||||
print __METHOD__." Result for checking we don't have back quote = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent,'int(');
|
||||
print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found int(x) instead of integer into '.$file.'. Bad.');
|
||||
$result=strpos($filecontent,'int(');
|
||||
print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found int(x) instead of integer into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent,'ON DELETE CASCADE');
|
||||
print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
|
||||
}
|
||||
}
|
||||
$result=strpos($filecontent,'ON DELETE CASCADE');
|
||||
print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -176,28 +177,28 @@ class SqlTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testInitData()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata');
|
||||
foreach($filesarray as $key => $file)
|
||||
{
|
||||
if (! preg_match('/\.sql$/',$file)) continue;
|
||||
$filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata');
|
||||
foreach($filesarray as $key => $file) {
|
||||
if (! preg_match('/\.sql$/',$file))
|
||||
continue;
|
||||
|
||||
print 'Check sql file '.$file."\n";
|
||||
$filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file);
|
||||
print 'Check sql file '.$file."\n";
|
||||
$filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file);
|
||||
|
||||
$result=strpos($filecontent,'@gmail.com');
|
||||
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a bad key into file '.$file);
|
||||
$result=strpos($filecontent,'@gmail.com');
|
||||
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a bad key into file '.$file);
|
||||
|
||||
$result=strpos($filecontent,'eldy@');
|
||||
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a bad key into file '.$file);
|
||||
}
|
||||
$result=strpos($filecontent,'eldy@');
|
||||
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a bad key into file '.$file);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,22 +18,21 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/UserGroupTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
//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/user/class/usergroup.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -47,71 +46,73 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class UserGroupTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return UserGroupTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return UserGroupTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,120 +122,120 @@ class UserGroupTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testUserGroupCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new UserGroup($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new UserGroup($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserGroupFetch
|
||||
*
|
||||
* @param int $id Id of group
|
||||
* @return void
|
||||
* @depends testUserGroupCreate
|
||||
* @param int $id Id of group
|
||||
* @return void
|
||||
* @depends testUserGroupCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserGroupFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new UserGroup($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new UserGroup($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserGroupUpdate
|
||||
*
|
||||
* @param Object $localobject Group
|
||||
* @return void
|
||||
* @depends testUserGroupFetch
|
||||
* @param Object $localobject Group
|
||||
* @return void
|
||||
* @depends testUserGroupFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserGroupUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserGroupAddRight
|
||||
*
|
||||
* @param Object $localobject Object to show
|
||||
* @return void
|
||||
* @depends testUserGroupUpdate
|
||||
* @param Object $localobject Object to show
|
||||
* @return void
|
||||
* @depends testUserGroupUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserGroupAddRight($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->addrights(1,'bookmarks');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$result=$localobject->addrights(1,'bookmarks');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserGroupDelRight
|
||||
*
|
||||
* @param Object $localobject Object
|
||||
* @return void
|
||||
* @depends testUserGroupAddRight
|
||||
* @param Object $localobject Object
|
||||
* @return void
|
||||
* @depends testUserGroupAddRight
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserGroupDelRight($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->delrights(1,'bookmarks');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$result=$localobject->delrights(1,'bookmarks');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserGroupOther
|
||||
*
|
||||
* @param Object $localobject Object
|
||||
* @return void
|
||||
* @param Object $localobject Object
|
||||
* @return void
|
||||
* @depends testUserGroupDelRight
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
@@ -261,26 +262,26 @@ class UserGroupTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testUserGroupDelete
|
||||
*
|
||||
* @param int $id Id of object
|
||||
* @return void
|
||||
* @depends testUserGroupOther
|
||||
* @param int $id Id of object
|
||||
* @return void
|
||||
* @depends testUserGroupOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserGroupDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new UserGroup($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
$localobject=new UserGroup($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/UserTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -29,11 +29,10 @@ global $conf,$user,$langs,$db;
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/user/class/user.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -47,146 +46,148 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class UserTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return UserTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return UserTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserCreate
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function testUserCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new User($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$localobject=new User($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserFetch
|
||||
*
|
||||
* @param int $id Id of user
|
||||
* @return void
|
||||
* @depends testUserCreate
|
||||
* @param int $id Id of user
|
||||
* @return void
|
||||
* @depends testUserCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new User($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject=new User($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserUpdate
|
||||
*
|
||||
* @param Object $localobject User
|
||||
* @return void
|
||||
* @depends testUserFetch
|
||||
* @param Object $localobject User
|
||||
* @return void
|
||||
* @depends testUserFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$this->changeProperties($localobject);
|
||||
$result=$localobject->update($user);
|
||||
$this->changeProperties($localobject);
|
||||
$result=$localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
// Test everything are still same than specimen
|
||||
$newlocalobject=new User($this->savdb);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','ref','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected
|
||||
// Test everything are still same than specimen
|
||||
$newlocalobject=new User($this->savdb);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','ref','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected
|
||||
|
||||
return $localobject;
|
||||
}
|
||||
@@ -194,32 +195,32 @@ class UserTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testUserDisable
|
||||
*
|
||||
* @param Object $localobject User
|
||||
* @return void
|
||||
* @depends testUserUpdate
|
||||
* @param Object $localobject User
|
||||
* @return void
|
||||
* @depends testUserUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserDisable($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
return $localobject;
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testUserOther
|
||||
*
|
||||
* @param Object $localobject User
|
||||
* @return void
|
||||
* @param Object $localobject User
|
||||
* @return void
|
||||
* @depends testUserDisable
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
@@ -246,75 +247,70 @@ class UserTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* testUserDelete
|
||||
*
|
||||
* @param Object $id User
|
||||
* @return void
|
||||
* @depends testUserOther
|
||||
* @param Object $id User
|
||||
* @return void
|
||||
* @depends testUserOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testUserDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new User($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
$localobject=new User($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Edit an object to test updates
|
||||
*
|
||||
* @param mixed $localobject Object Facture
|
||||
* @return void
|
||||
* @param mixed $localobject Object Facture
|
||||
* @return void
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
$localobject->note='New note after update';
|
||||
$localobject->note='New note after update';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare all public properties values of 2 objects
|
||||
*
|
||||
* @param Object $oA Object operand 1
|
||||
* @param Object $oB Object operand 2
|
||||
* @param boolean $ignoretype False will not report diff if type of value differs
|
||||
* @param array $fieldstoignorearray Array of fields to ignore in diff
|
||||
* @return array Array with differences
|
||||
* @param Object $oA Object operand 1
|
||||
* @param Object $oB Object operand 2
|
||||
* @param boolean $ignoretype False will not report diff if type of value differs
|
||||
* @param array $fieldstoignorearray Array of fields to ignore in diff
|
||||
* @return array Array with differences
|
||||
*/
|
||||
public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
$retAr=array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB))
|
||||
{
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
foreach($aKeys as $sKey)
|
||||
{
|
||||
if (in_array($sKey,$fieldstoignorearray)) continue;
|
||||
if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
|
||||
{
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey])
|
||||
{
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retAr;
|
||||
if (get_class($oA) !== get_class($oB)) {
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
} else {
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
foreach($aKeys as $sKey) {
|
||||
if (in_array($sKey,$fieldstoignorearray))
|
||||
continue;
|
||||
if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey]) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retAr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/WebservicesInvoicesTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -31,11 +31,10 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -45,75 +44,77 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,60 +125,57 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWSInvoicesXxx()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
$WS_METHOD = 'getInvoice';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
$WS_METHOD = 'getInvoice';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,24 +18,23 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/WebservicesOrdersTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
//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/core/lib/date.lib.php';
|
||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -49,71 +48,73 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class WebservicesOrdersTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,59 +125,56 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWSOrderGetOrder()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_order.php';
|
||||
$WS_METHOD = 'getOrder';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_order.php';
|
||||
$WS_METHOD = 'getOrder';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$parameters = array('authentication'=>$authentication,'id'=>1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$parameters = array('authentication'=>$authentication,'id'=>1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/WebservicesOtherTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -31,11 +31,10 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -49,71 +48,73 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class WebservicesOtherTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,92 +125,85 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWSOtherGetVersions()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_other.php';
|
||||
$WS_METHOD = 'getVersions';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_other.php';
|
||||
$WS_METHOD = 'getVersions';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! empty($result['faultstring']))
|
||||
{
|
||||
print $result['faultstring']."\n";
|
||||
$result=0;
|
||||
}
|
||||
if (! $result)
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! empty($result['faultstring'])) {
|
||||
print $result['faultstring']."\n";
|
||||
$result=0;
|
||||
}
|
||||
if (! $result) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
// Test method that does not exists
|
||||
$WS_METHOD='methodthatdoesnotexists';
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test method that does not exists
|
||||
$WS_METHOD='methodthatdoesnotexists';
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("SOAP-ENV:Client: Operation 'methodthatdoesnotexists' is not defined in the WSDL for this service", $soapclient->error_str);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("SOAP-ENV:Client: Operation 'methodthatdoesnotexists' is not defined in the WSDL for this service", $soapclient->error_str);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/WebservicesProductsTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -33,11 +33,10 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -51,71 +50,72 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class WebservicesProductsTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -126,198 +126,192 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWSProductsCreateProductOrService()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$datestring=dol_print_date(dol_now(),'dayhourlog');
|
||||
$datestring=dol_print_date(dol_now(),'dayhourlog');
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'createProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'createProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'product'=>array(
|
||||
'ref'=>'NewProductFromWS'.$datestring,
|
||||
'label'=>'New Product From WS '.$datestring,
|
||||
'type'=>1,
|
||||
'description'=>'This is a new product created from WS PHPUnit test case'));
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK')
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array(
|
||||
'authentication'=>$authentication,'product'=>array(
|
||||
'ref'=>'NewProductFromWS'.$datestring,
|
||||
'label'=>'New Product From WS '.$datestring,
|
||||
'type'=>1,
|
||||
'description'=>'This is a new product created from WS PHPUnit test case'
|
||||
)
|
||||
);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return $result['id'];
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSProductsGetProductOrService
|
||||
*
|
||||
* @param int $id Id of product or service
|
||||
* @return int Id of product or service
|
||||
* @param int $id Id of product or service
|
||||
* @return int Id of product or service
|
||||
*
|
||||
* @depends testWSProductsCreateProductOrService
|
||||
*/
|
||||
public function testWSProductsGetProductOrService($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'getProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'getProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>'');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>'');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return $id;
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSProductsDeleteProductOrService
|
||||
*
|
||||
* @param int $id Id of product or service
|
||||
* @return int 0
|
||||
* @param int $id Id of product or service
|
||||
* @return int 0
|
||||
*
|
||||
* @depends testWSProductsGetProductOrService
|
||||
* @depends testWSProductsGetProductOrService
|
||||
*/
|
||||
public function testWSProductsDeleteProductOrService($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'deleteProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'deleteProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'listofid'=>$id);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK')
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'listofid'=>$id);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/WebservicesThirdpartyTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -31,11 +31,10 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -45,75 +44,77 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,60 +125,56 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWSThirdpartygetThirdParty()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
|
||||
$WS_METHOD = 'getThirdParty';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
|
||||
$WS_METHOD = 'getThirdParty';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/WebservicesUserTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
@@ -31,11 +31,10 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -49,71 +48,73 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*/
|
||||
class WebservicesUserTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return DateLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,91 +125,84 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWSUserGetUser()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php';
|
||||
$WS_METHOD = 'getUser';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php';
|
||||
$WS_METHOD = 'getUser';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__."Create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// Set the WebService URL
|
||||
print __METHOD__."Create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'ref'=>'admin');
|
||||
print __METHOD__."Call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! empty($result['faultstring']))
|
||||
{
|
||||
print $result['faultstring']."\n";
|
||||
$result=0;
|
||||
}
|
||||
if (! $result)
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'ref'=>'admin');
|
||||
print __METHOD__."Call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! empty($result['faultstring'])) {
|
||||
print $result['faultstring']."\n";
|
||||
$result=0;
|
||||
}
|
||||
if (! $result) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'ref'=>'refthatdoesnotexists');
|
||||
print __METHOD__."Call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'ref'=>'refthatdoesnotexists');
|
||||
print __METHOD__."Call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('NOT_FOUND',$result['result']['result_code']);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('NOT_FOUND',$result['result']['result_code']);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,22 +18,21 @@
|
||||
|
||||
/**
|
||||
* \file test/phpunit/XCalLibTest.php
|
||||
* \ingroup test
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
//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/core/lib/xcal.lib.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
if (empty($user->id)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
@@ -43,98 +42,100 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class XCalLibTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return FilesLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return FilesLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testQuotedPrintEncodeDecode
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testQuotedPrintEncodeDecode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQuotedPrintEncodeDecode()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$stringtoencode='ABCD=1234;';
|
||||
$result=quotedPrintEncode($stringtoencode);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('ABCD=3D1234;',$result);
|
||||
$stringtoencode='ABCD=1234;';
|
||||
$result=quotedPrintEncode($stringtoencode);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('ABCD=3D1234;',$result);
|
||||
|
||||
$resultback=quotedPrintDecode($result);
|
||||
print __METHOD__." result=".$resultback."\n";
|
||||
$this->assertEquals($stringtoencode,$resultback);
|
||||
$resultback=quotedPrintDecode($result);
|
||||
print __METHOD__." result=".$resultback."\n";
|
||||
$this->assertEquals($stringtoencode,$resultback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user