From eeb8fb09ba842a370fb6f2b71c7b9f2bba9b0eb2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Mon, 17 May 2010 12:48:55 +0000 Subject: [PATCH] Fix: Change status of order to cancel --- htdocs/commande/class/commande.class.php | 27 +++++++++++------------- test/CommandeTest.php | 21 +++++++++++++++++- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7280227abdc..63643f75502 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -551,23 +551,20 @@ class Commande extends CommonObject $result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice); if ($result < 0) { $error++; } } - - if (! $error) - { - $this->statut=-1; - $this->db->commit(); - return $result; - } - else - { - $this->error=$mouvP->error; - $this->db->rollback(); - return $result; - } } - $this->db->commit(); - return 1; + if (! $error) + { + $this->statut=-1; + $this->db->commit(); + return 1; + } + else + { + $this->error=$mouvP->error; + $this->db->rollback(); + return -1; + } } else { diff --git a/test/CommandeTest.php b/test/CommandeTest.php index c43d550ce74..4c0b6a48577 100644 --- a/test/CommandeTest.php +++ b/test/CommandeTest.php @@ -183,13 +183,32 @@ class CommandeTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; } /** * @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; + + $result=$localobject->cancel($user); + + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $localobject->id; + } + + /** + * @depends testCommandeCancel + * The depends says test is run only if previous is ok + */ public function testCommandeDelete($id) { global $conf,$user,$langs,$db; -- GitLab