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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
066bcbb4
Commit
066bcbb4
authored
12 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Qual: Add dol_format_address PHPUnit tests
parent
8ea48b28
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/core/lib/functions.lib.php
+2
-2
2 additions, 2 deletions
htdocs/core/lib/functions.lib.php
htdocs/societe/class/societe.class.php
+4
-0
4 additions, 0 deletions
htdocs/societe/class/societe.class.php
test/phpunit/FunctionsTest.php
+29
-0
29 additions, 0 deletions
test/phpunit/FunctionsTest.php
with
35 additions
and
2 deletions
htdocs/core/lib/functions.lib.php
+
2
−
2
View file @
066bcbb4
...
@@ -696,7 +696,7 @@ function dol_format_address($object)
...
@@ -696,7 +696,7 @@ function dol_format_address($object)
$ret
.
=
(
$ret
?
"
\n
"
:
''
)
.
$object
->
town
;
$ret
.
=
(
$ret
?
"
\n
"
:
''
)
.
$object
->
town
;
if
(
$object
->
state
&&
in_array
(
$object
->
country_code
,
$countriesusingstate
))
if
(
$object
->
state
&&
in_array
(
$object
->
country_code
,
$countriesusingstate
))
{
{
$ret
.
=
", "
.
$object
->
departement
;
$ret
.
=
", "
.
$object
->
state
;
}
}
if
(
$object
->
zip
)
$ret
.
=
', '
.
$object
->
zip
;
if
(
$object
->
zip
)
$ret
.
=
', '
.
$object
->
zip
;
}
}
...
@@ -705,7 +705,7 @@ function dol_format_address($object)
...
@@ -705,7 +705,7 @@ function dol_format_address($object)
$ret
.
=
(
$ret
?
"
\n
"
:
''
)
.
$object
->
town
;
$ret
.
=
(
$ret
?
"
\n
"
:
''
)
.
$object
->
town
;
if
(
$object
->
state
&&
in_array
(
$object
->
country_code
,
$countriesusingstate
))
if
(
$object
->
state
&&
in_array
(
$object
->
country_code
,
$countriesusingstate
))
{
{
$ret
.
=
", "
.
$object
->
departement
;
$ret
.
=
", "
.
$object
->
state
;
}
}
if
(
$object
->
zip
)
$ret
.
=
(
$ret
?
"
\n
"
:
''
)
.
$object
->
zip
;
if
(
$object
->
zip
)
$ret
.
=
(
$ret
?
"
\n
"
:
''
)
.
$object
->
zip
;
}
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/societe/class/societe.class.php
+
4
−
0
View file @
066bcbb4
...
@@ -2537,8 +2537,12 @@ class Societe extends CommonObject
...
@@ -2537,8 +2537,12 @@ class Societe extends CommonObject
$this
->
name
=
'THIRDPARTY SPECIMEN '
.
dol_print_date
(
$now
,
'dayhourlog'
);
$this
->
name
=
'THIRDPARTY SPECIMEN '
.
dol_print_date
(
$now
,
'dayhourlog'
);
$this
->
nom
=
$this
->
name
;
// For backward compatibility
$this
->
nom
=
$this
->
name
;
// For backward compatibility
$this
->
specimen
=
1
;
$this
->
specimen
=
1
;
$this
->
address
=
'21 jump street'
;
$this
->
zip
=
'99999'
;
$this
->
zip
=
'99999'
;
$this
->
town
=
'MyTown'
;
$this
->
town
=
'MyTown'
;
$this
->
state_id
=
1
;
$this
->
state_code
=
'AA'
;
$this
->
state
=
'MyState'
;
$this
->
country_id
=
1
;
$this
->
country_id
=
1
;
$this
->
country_code
=
'FR'
;
$this
->
country_code
=
'FR'
;
...
...
This diff is collapsed.
Click to expand it.
test/phpunit/FunctionsTest.php
+
29
−
0
View file @
066bcbb4
...
@@ -388,6 +388,35 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
...
@@ -388,6 +388,35 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
}
}
/**
* testDolFormatAddress
*
* @return void
*/
public
function
testDolFormatAddress
()
{
global
$conf
,
$user
,
$langs
,
$db
;
$conf
=
$this
->
savconf
;
$user
=
$this
->
savuser
;
$langs
=
$this
->
savlangs
;
$db
=
$this
->
savdb
;
$object
=
new
Societe
(
$db
);
$object
->
initAsSpecimen
();
$object
->
country_code
=
'FR'
;
$address
=
dol_format_address
(
$object
);
$this
->
assertEquals
(
"21 jump street
\n
99999 MyTown"
,
$address
);
$object
->
country_code
=
'GB'
;
$address
=
dol_format_address
(
$object
);
$this
->
assertEquals
(
"21 jump street
\n
MyTown, MyState
\n
99999"
,
$address
);
$object
->
country_code
=
'US'
;
$address
=
dol_format_address
(
$object
);
$this
->
assertEquals
(
"21 jump street
\n
MyTown, MyState, 99999"
,
$address
);
}
/**
/**
* testImgPicto
* testImgPicto
*
*
...
...
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