2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2024-03-01 20:55:41 +01:00
7 changed files with 57 additions and 19 deletions

View File

@@ -61,7 +61,7 @@ class FormContract
* @param int $showRef Show customer and supplier reference on each contract (when found) * @param int $showRef Show customer and supplier reference on each contract (when found)
* @param int $noouput 1=Return the output instead of display * @param int $noouput 1=Return the output instead of display
* @param string $morecss More CSS * @param string $morecss More CSS
* @return int Nbr of contract if OK, <0 if KO * @return int|string If nooutput = 0: Nbr of contract if OK, <0 if KO, If nooutput = 1: The HTML select string
*/ */
public function select_contract($socid = -1, $selected = 0, $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0, $noouput = 0, $morecss = 'minwidth150') public function select_contract($socid = -1, $selected = 0, $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0, $noouput = 0, $morecss = 'minwidth150')
{ {

View File

@@ -474,7 +474,7 @@ class SupplierInvoices extends DolibarrApi
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = $payment_mode_id; $paiement->paiementid = $payment_mode_id;
$paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1); $paiement->paiementcode = (string) dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1);
$paiement->num_payment = $num_payment; $paiement->num_payment = $num_payment;
$paiement->note_public = $comment; $paiement->note_public = $comment;
@@ -704,7 +704,12 @@ class SupplierInvoices extends DolibarrApi
$updateRes = $this->invoice->deleteLine($lineid); $updateRes = $this->invoice->deleteLine($lineid);
if ($updateRes > 0) { if ($updateRes > 0) {
return $this->get($id); return array(
'success' => array(
'code' => 200,
'message' => 'line '.$lineid.' deleted'
)
);
} else { } else {
throw new RestException(405, $this->invoice->error); throw new RestException(405, $this->invoice->error);
} }

View File

@@ -1249,7 +1249,7 @@ class FactureFournisseurRec extends CommonInvoice
* Format string to output with by striking the string if max number of generation was reached * Format string to output with by striking the string if max number of generation was reached
* *
* @param string $ret Default value to output * @param string $ret Default value to output
* @return boolean False by default, True if maximum number of generation is reached * @return string False by default, True if maximum number of generation is reached
*/ */
public function strikeIfMaxNbGenReached($ret) public function strikeIfMaxNbGenReached($ret)
{ {

View File

@@ -311,7 +311,13 @@ if (empty($reshook)) {
// Creation of payment line // Creation of payment line
$paiement = new PaiementFourn($db); $paiement = new PaiementFourn($db);
$paiement->datepaye = $datepaye; $paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array of amounts
$correctedAmounts = [];
foreach ($amounts as $key => $value) {
$correctedAmounts[$key] = (float) $value;
}
$paiement->amounts = $correctedAmounts; // Array of amounts
$paiement->multicurrency_amounts = $multicurrency_amounts; $paiement->multicurrency_amounts = $multicurrency_amounts;
$paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
$paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching

View File

@@ -382,11 +382,11 @@ class Tickets extends DolibarrApi
$this->ticket->$field = $value; $this->ticket->$field = $value;
} }
if ($this->ticket->update(DolibarrApiAccess::$user)) { if ($this->ticket->update(DolibarrApiAccess::$user) > 0) {
return $this->get($id); return $this->get($id);
} else {
throw new RestException(500, $this->ticket->error);
} }
return false;
} }
/** /**

View File

@@ -923,7 +923,7 @@ class Website extends CommonObject
$this->lang = 'en'; $this->lang = 'en';
$this->otherlang = 'fr,es'; $this->otherlang = 'fr,es';
$this->status = 1; $this->status = 1;
$this->fk_default_home = null; $this->fk_default_home = 0;
$this->virtualhost = 'http://myvirtualhost'; $this->virtualhost = 'http://myvirtualhost';
$this->fk_user_creat = $user->id; $this->fk_user_creat = $user->id;
$this->fk_user_modif = $user->id; $this->fk_user_modif = $user->id;

View File

@@ -116,11 +116,7 @@ abstract class CommonClassTest extends TestCase
if ($t instanceof PHPUnit\Framework\Error\Notice) { if ($t instanceof PHPUnit\Framework\Error\Notice) {
$nbLinesToShow = 3; $nbLinesToShow = 3;
} }
$totalLines = count($lines);
$first_line = max(0, $totalLines - $nbLinesToShow);
// Get the last line of the log
$last_lines = array_slice($lines, $first_line, $nbLinesToShow);
$failedTestMethod = $this->getName(false); $failedTestMethod = $this->getName(false);
$className = get_called_class(); $className = get_called_class();
@@ -131,14 +127,25 @@ abstract class CommonClassTest extends TestCase
// Get the test method's data set // Get the test method's data set
$argsText = $this->getDataSetAsString(true); $argsText = $this->getDataSetAsString(true);
// Show log file $totalLines = count($lines);
$first_line = max(0, $totalLines - $nbLinesToShow);
// Get the last line of the log
$last_lines = array_slice($lines, $first_line, $nbLinesToShow);
print PHP_EOL; print PHP_EOL;
print "----- $className::$failedTestMethod failed - $argsText.".PHP_EOL; // Use GitHub Action compatible group output (:warning: arguments not encoded)
print "Show last ".$nbLinesToShow." lines of dolibarr.log file -----".PHP_EOL; print "##[group]$className::$failedTestMethod failed - $argsText.".PHP_EOL;
foreach ($last_lines as $line) { print "## Exception: {$t->getMessage()}".PHP_EOL;
print $line.PHP_EOL;
if ($nbLinesToShow) {
// Show partial log file contents when requested.
print "## Show last ".$nbLinesToShow." lines of dolibarr.log file -----".PHP_EOL;
foreach ($last_lines as $line) {
print $line.PHP_EOL;
}
print "## end of dolibarr.log for $className::$failedTestMethod".PHP_EOL;
} }
print "----- end of dolibarr.log for $className::$failedTestMethod".PHP_EOL; print "##[endgroup]".PHP_EOL;
parent::onNotSuccessfulTest($t); parent::onNotSuccessfulTest($t);
} }
@@ -359,4 +366,24 @@ abstract class CommonClassTest extends TestCase
$this->assertDirectoryDoesNotExist($directory, $message); $this->assertDirectoryDoesNotExist($directory, $message);
} }
} }
/**
* Assert that a file does not exist without triggering deprecation
*
* @param string $file The file to test
* @param string $message The message to show if the directory exists
*
* @return void
*/
protected function assertFileNotExistsCompat($file, $message = '')
{
$phpunitVersion = \PHPUnit\Runner\Version::id();
// Check if PHPUnit version is less than 9.0.0
if (version_compare($phpunitVersion, '9.0.0', '<')) {
$this->assertFileNotExists($file, $message);
} else {
$this->assertFileDoesNotExist($file, $message);
}
}
} }