From 9a70541084e769eeb55ba27e80449d0868981df3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Apr 2012 18:41:38 +0200 Subject: [PATCH] Fix: Missing migration field Fix: Date must be quoted --- .../class/fournisseur.commande.class.php | 16 +++---- .../install/mysql/migration/3.2.0-3.3.0.sql | 6 ++- test/phpunit/CommandeFournisseurTest.php | 48 ++++++++++++++----- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 17fd7390023..7a4383013cd 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -329,10 +329,10 @@ class CommandeFournisseur extends Commande } $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET ref='".$num."'"; - $sql.= ", fk_statut = 1"; - $sql.= ", date_valid=".$this->db->idate(mktime()); - $sql.= ", fk_user_valid = ".$user->id; + $sql.= " SET ref='".$num."',"; + $sql.= " fk_statut = 1,"; + $sql.= " date_valid='".$this->db->idate(dol_now())."',"; + $sql.= " fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND fk_statut = 0"; @@ -668,10 +668,10 @@ class CommandeFournisseur extends Commande $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET ref='".$num."'"; - $sql.= ", fk_statut = 2"; - $sql.= ", date_approve=".$this->db->idate(mktime()); - $sql.= ", fk_user_approve = ".$user->id; + $sql.= " SET ref='".$this->db->escape($num)."',"; + $sql.= " fk_statut = 2,"; + $sql.= " date_approve='".$this->db->idate(dol_now())."',"; + $sql.= " fk_user_approve = ".$user->id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND fk_statut = 1"; diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 78b44c24683..398fc8eb926 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -24,4 +24,8 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 274, 27, '5.5','0','VAT reduced rate (France hors DOM-TOM)',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 275, 27, '0','0','VAT Rate 0 ou non applicable',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 276, 27, '2.1','0','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 277, 27, '7','0','VAT reduced rate',1); \ No newline at end of file +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 277, 27, '7','0','VAT reduced rate',1); + + +ALTER TABLE llx_commande_fournisseur CHANGE COLUMN date_cloture date_approve datetime; +ALTER TABLE llx_commande_fournisseur CHANGE COLUMN fk_user_cloture fk_user_approve integer; diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 1cc9e6f6678..eb5e2028ada 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -117,7 +117,7 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase /** * testCommandeFournisseurCreate - * + * * @return void */ public function testCommandeFournisseurCreate() @@ -139,10 +139,10 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase /** * testCommandeFournisseurFetch - * + * * @param int $id Id of supplier order * @return void - * + * * @depends testCommandeFournisseurCreate * The depends says test is run only if previous is ok */ @@ -161,13 +161,13 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase $this->assertLessThan($result, 0); return $localobject; } - + /** * testCommandeFournisseurValid - * + * * @param Object $localobject Supplier order * @return void - * + * * @depends testCommandeFournisseurFetch * The depends says test is run only if previous is ok */ @@ -186,12 +186,36 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase return $localobject; } + /** + * testCommandeFournisseurApprove + * + * @param Object $localobject Supplier order + * @return void + * + * @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; + + $result=$localobject->approve($user); + + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $localobject; + } + /** * testCommandeFournisseurCancel - * + * * @param Object $localobject Supplier order * @return void - * + * * @depends testCommandeFournisseurValid * The depends says test is run only if previous is ok */ @@ -212,10 +236,10 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase /** * testCommandeFournisseurOther - * + * * @param Object $localobject Supplier order * @return void - * + * * @depends testCommandeFournisseurCancel * The depends says test is run only if previous is ok */ @@ -242,10 +266,10 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase /** * testCommandeFournisseurDelete - * + * * @param int $id Id of order * @return void - * + * * @depends testCommandeFournisseurOther * The depends says test is run only if previous is ok */