Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
1e33e41a
Commit
1e33e41a
authored
14 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Add more phpunit tests
parent
ec99db2f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/fourn/class/fournisseur.commande.class.php
+27
-11
27 additions, 11 deletions
htdocs/fourn/class/fournisseur.commande.class.php
test/phpunit/CommandeFournisseurTest.php
+4
-3
4 additions, 3 deletions
test/phpunit/CommandeFournisseurTest.php
with
31 additions
and
14 deletions
htdocs/fourn/class/fournisseur.commande.class.php
+
27
−
11
View file @
1e33e41a
...
...
@@ -53,6 +53,18 @@ class CommandeFournisseur extends Commande
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
// -> 6=Canceled -> (reopen) 2=Approved
// -> 9=Refused -> (reopen) 1=Validated
var
$socid
;
var
$fourn_id
;
var
$date
;
var
$date_commande
;
var
$total_ht
;
var
$total_tva
;
var
$total_ttc
;
var
$source
;
var
$note
;
var
$note_public
;
var
$model_pdf
;
var
$fk_project
;
/** \brief Constructeur
...
...
@@ -79,10 +91,10 @@ class CommandeFournisseur extends Commande
/**
*
\brief
Get object and lines from database
*
\
param id Id of order to load
*
\
param ref Ref of object
*
\
return int >0 if OK, <0 if KO
* Get object and lines from database
*
@
param id Id of order to load
*
@
param ref Ref of object
*
@
return int >0 if OK, <0 if KO
*/
function
fetch
(
$id
,
$ref
=
''
)
{
...
...
@@ -103,6 +115,7 @@ class CommandeFournisseur extends Commande
if
(
$resql
)
{
$obj
=
$this
->
db
->
fetch_object
(
$resql
);
if
(
!
$obj
)
return
-
1
;
$this
->
id
=
$obj
->
rowid
;
$this
->
ref
=
$obj
->
ref
;
...
...
@@ -142,7 +155,7 @@ class CommandeFournisseur extends Commande
$sql
.
=
" ORDER BY l.rowid"
;
//print $sql;
dol_syslog
(
"CommandeFournisseur::fetch sql="
.
$sql
,
LOG_DEBUG
);
dol_syslog
(
"CommandeFournisseur::fetch
get lines
sql="
.
$sql
,
LOG_DEBUG
);
$result
=
$this
->
db
->
query
(
$sql
);
if
(
$result
)
{
...
...
@@ -700,9 +713,9 @@ class CommandeFournisseur extends Commande
}
/**
*
\brief
Create order with draft status
*
\
param user User making creation
*
\
return int <0 if KO,
>0
if OK
* Create order with draft status
*
@
param user User making creation
*
@
return int <0 if KO,
Id of supplier order
if OK
*/
function
create
(
$user
)
{
...
...
@@ -710,6 +723,8 @@ class CommandeFournisseur extends Commande
$this
->
db
->
begin
();
$now
=
dol_now
();
/* On positionne en mode brouillon la commande */
$this
->
brouillon
=
1
;
...
...
@@ -727,7 +742,7 @@ class CommandeFournisseur extends Commande
$sql
.
=
"''"
;
$sql
.
=
", "
.
$conf
->
entity
;
$sql
.
=
", "
.
$this
->
socid
;
$sql
.
=
", "
.
$this
->
db
->
idate
(
mktime
()
);
$sql
.
=
", "
.
$this
->
db
->
idate
(
$now
);
$sql
.
=
", "
.
$user
->
id
;
$sql
.
=
", 0"
;
$sql
.
=
", 0"
;
...
...
@@ -756,7 +771,7 @@ class CommandeFournisseur extends Commande
// Fin appel triggers
$this
->
db
->
commit
();
return
1
;
return
$this
->
id
;
}
else
{
...
...
@@ -1431,7 +1446,7 @@ class CommandeFournisseur extends Commande
$sql
=
"SELECT rowid"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"product"
;
$sql
.
=
"
AND
entity = "
.
$conf
->
entity
;
$sql
.
=
"
WHERE
entity = "
.
$conf
->
entity
;
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
$resql
)
...
...
@@ -1452,6 +1467,7 @@ class CommandeFournisseur extends Commande
$this
->
specimen
=
1
;
$this
->
socid
=
1
;
$this
->
date
=
time
();
$this
->
date_commande
=
time
();
$this
->
date_lim_reglement
=
$this
->
date
+
3600
*
24
*
30
;
$this
->
cond_reglement_code
=
'RECEP'
;
$this
->
mode_reglement_code
=
'CHQ'
;
...
...
This diff is collapsed.
Click to expand it.
test/phpunit/CommandeFournisseurTest.php
+
4
−
3
View file @
1e33e41a
...
...
@@ -39,11 +39,12 @@ if (empty($user->id))
$conf
->
global
->
MAIN_DISABLE_ALL_MAILS
=
1
;
/**
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @covers CommandeFournisseur
* @covers
OrderLin
eFournisseur
* @covers
Command
eFournisseur
Ligne
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class
CommandeFournisseurTest
extends
PHPUnit_Framework_TestCase
...
...
@@ -123,8 +124,8 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
$localobject
->
initAsSpecimen
();
$result
=
$localobject
->
create
(
$user
);
$this
->
assertLessThan
(
$result
,
0
);
print
__METHOD__
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertLessThan
(
$result
,
0
);
return
$result
;
}
...
...
@@ -143,8 +144,8 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
$localobject
=
new
CommandeFournisseur
(
$this
->
savdb
);
$result
=
$localobject
->
fetch
(
$id
);
$this
->
assertLessThan
(
$result
,
0
);
print
__METHOD__
.
" id="
.
$id
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertLessThan
(
$result
,
0
);
return
$localobject
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment