Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
10a4bcaa
Commit
10a4bcaa
authored
Feb 01, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix number format unit tests
parent
c9ce348a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
AppFormatTest.php
qa-tests/AppFormatTest.php
+14
-14
No files found.
qa-tests/AppFormatTest.php
View file @
10a4bcaa
...
@@ -10,11 +10,11 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
...
@@ -10,11 +10,11 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
public
function
test__qa_format_number
()
public
function
test__qa_format_number
()
{
{
// set options/lang cache to bypass database
// set options/lang cache to bypass database
global
$qa_options_cache
,
$qa_phrases_
custom
;
global
$qa_options_cache
,
$qa_phrases_
full
;
$qa_options_cache
[
'show_compact_numbers'
]
=
'0'
;
$qa_options_cache
[
'show_compact_numbers'
]
=
'0'
;
$qa_phrases_
custom
[
'main'
][
'_decimal_point'
]
=
'.'
;
$qa_phrases_
full
[
'main'
][
'_decimal_point'
]
=
'.'
;
$qa_phrases_
custom
[
'main'
][
'_thousands_separator'
]
=
','
;
$qa_phrases_
full
[
'main'
][
'_thousands_separator'
]
=
','
;
$this
->
assertSame
(
'5.5'
,
qa_format_number
(
5.452
,
1
));
$this
->
assertSame
(
'5.5'
,
qa_format_number
(
5.452
,
1
));
$this
->
assertSame
(
'5'
,
qa_format_number
(
5.452
,
0
));
$this
->
assertSame
(
'5'
,
qa_format_number
(
5.452
,
0
));
...
@@ -30,8 +30,8 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
...
@@ -30,8 +30,8 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
$this
->
assertSame
(
'123,456,789'
,
qa_format_number
(
123456789
,
0
,
true
));
$this
->
assertSame
(
'123,456,789'
,
qa_format_number
(
123456789
,
0
,
true
));
// change separators
// change separators
$qa_phrases_
custom
[
'main'
][
'_decimal_point'
]
=
','
;
$qa_phrases_
full
[
'main'
][
'_decimal_point'
]
=
','
;
$qa_phrases_
custom
[
'main'
][
'_thousands_separator'
]
=
'.'
;
$qa_phrases_
full
[
'main'
][
'_thousands_separator'
]
=
'.'
;
$this
->
assertSame
(
'5,5'
,
qa_format_number
(
5.452
,
1
));
$this
->
assertSame
(
'5,5'
,
qa_format_number
(
5.452
,
1
));
$this
->
assertSame
(
'5'
,
qa_format_number
(
5.452
,
0
));
$this
->
assertSame
(
'5'
,
qa_format_number
(
5.452
,
0
));
...
@@ -45,13 +45,13 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
...
@@ -45,13 +45,13 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
public
function
test__qa_format_number__compact
()
public
function
test__qa_format_number__compact
()
{
{
// set options/lang cache to bypass database
// set options/lang cache to bypass database
global
$qa_options_cache
,
$qa_phrases_
custom
;
global
$qa_options_cache
,
$qa_phrases_
full
;
$qa_options_cache
[
'show_compact_numbers'
]
=
'1'
;
$qa_options_cache
[
'show_compact_numbers'
]
=
'1'
;
$qa_phrases_
custom
[
'main'
][
'_decimal_point'
]
=
'.'
;
$qa_phrases_
full
[
'main'
][
'_decimal_point'
]
=
'.'
;
$qa_phrases_
custom
[
'main'
][
'_thousands_separator'
]
=
','
;
$qa_phrases_
full
[
'main'
][
'_thousands_separator'
]
=
','
;
$qa_phrases_
custom
[
'main'
][
'_thousands_suffix'
]
=
'k'
;
$qa_phrases_
full
[
'main'
][
'_thousands_suffix'
]
=
'k'
;
$qa_phrases_
custom
[
'main'
][
'_millions_suffix'
]
=
'm'
;
$qa_phrases_
full
[
'main'
][
'_millions_suffix'
]
=
'm'
;
// $decimal parameter ignored when 'show_compact_numbers' is true
// $decimal parameter ignored when 'show_compact_numbers' is true
$this
->
assertSame
(
'5.5'
,
qa_format_number
(
5.452
,
0
,
true
));
$this
->
assertSame
(
'5.5'
,
qa_format_number
(
5.452
,
0
,
true
));
...
@@ -75,10 +75,10 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
...
@@ -75,10 +75,10 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
$this
->
assertSame
(
'123,456,789'
,
qa_format_number
(
123456789
,
0
,
false
));
$this
->
assertSame
(
'123,456,789'
,
qa_format_number
(
123456789
,
0
,
false
));
// change separators and compact suffixes
// change separators and compact suffixes
$qa_phrases_
custom
[
'main'
][
'_decimal_point'
]
=
','
;
$qa_phrases_
full
[
'main'
][
'_decimal_point'
]
=
','
;
$qa_phrases_
custom
[
'main'
][
'_thousands_separator'
]
=
'.'
;
$qa_phrases_
full
[
'main'
][
'_thousands_separator'
]
=
'.'
;
$qa_phrases_
custom
[
'main'
][
'_thousands_suffix'
]
=
'th'
;
$qa_phrases_
full
[
'main'
][
'_thousands_suffix'
]
=
'th'
;
$qa_phrases_
custom
[
'main'
][
'_millions_suffix'
]
=
'mi'
;
$qa_phrases_
full
[
'main'
][
'_millions_suffix'
]
=
'mi'
;
$this
->
assertSame
(
'9,1th'
,
qa_format_number
(
9123
,
0
,
true
));
$this
->
assertSame
(
'9,1th'
,
qa_format_number
(
9123
,
0
,
true
));
$this
->
assertSame
(
'123mi'
,
qa_format_number
(
123456789
,
0
,
true
));
$this
->
assertSame
(
'123mi'
,
qa_format_number
(
123456789
,
0
,
true
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment