Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
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
PSDI Army
yii2
Commits
6b65ef58
Commit
6b65ef58
authored
Oct 17, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added intl check to tests, better error reporting, credited Aura.Intl for the…
Added intl check to tests, better error reporting, credited Aura.Intl for the most complex test pattern
parent
71e2dcc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
MessageFormatterTest.php
tests/unit/framework/i18n/MessageFormatterTest.php
+14
-5
No files found.
tests/unit/framework/i18n/MessageFormatterTest.php
View file @
6b65ef58
...
@@ -22,6 +22,13 @@ class MessageFormatterTest extends TestCase
...
@@ -22,6 +22,13 @@ class MessageFormatterTest extends TestCase
const
SUBJECT
=
'сабж'
;
const
SUBJECT
=
'сабж'
;
const
SUBJECT_VALUE
=
'Answer to the Ultimate Question of Life, the Universe, and Everything'
;
const
SUBJECT_VALUE
=
'Answer to the Ultimate Question of Life, the Universe, and Everything'
;
protected
function
setUp
()
{
if
(
!
extension_loaded
(
"intl"
))
{
$this
->
markTestSkipped
(
"intl not installed. Skipping."
);
}
}
public
function
patterns
()
public
function
patterns
()
{
{
return
array
(
return
array
(
...
@@ -34,6 +41,7 @@ class MessageFormatterTest extends TestCase
...
@@ -34,6 +41,7 @@ class MessageFormatterTest extends TestCase
)
)
),
),
// This one was provided by Aura.Intl. Thanks!
array
(
<<<_MSG_
array
(
<<<_MSG_
{gender_of_host, select,
{gender_of_host, select,
female {{num_guests, plural, offset:1
female {{num_guests, plural, offset:1
...
@@ -117,7 +125,7 @@ _MSG_
...
@@ -117,7 +125,7 @@ _MSG_
public
function
testNamedArgumentsStatic
(
$pattern
,
$expected
,
$args
)
public
function
testNamedArgumentsStatic
(
$pattern
,
$expected
,
$args
)
{
{
$result
=
MessageFormatter
::
formatMessage
(
'en_US'
,
$pattern
,
$args
);
$result
=
MessageFormatter
::
formatMessage
(
'en_US'
,
$pattern
,
$args
);
$this
->
assertEquals
(
$expected
,
$result
);
$this
->
assertEquals
(
$expected
,
$result
,
intl_get_error_message
()
);
}
}
/**
/**
...
@@ -127,7 +135,7 @@ _MSG_
...
@@ -127,7 +135,7 @@ _MSG_
{
{
$formatter
=
new
MessageFormatter
(
'en_US'
,
$pattern
);
$formatter
=
new
MessageFormatter
(
'en_US'
,
$pattern
);
$result
=
$formatter
->
format
(
$args
);
$result
=
$formatter
->
format
(
$args
);
$this
->
assertEquals
(
$expected
,
$result
);
$this
->
assertEquals
(
$expected
,
$result
,
$formatter
->
getErrorMessage
()
);
}
}
public
function
testInsufficientArguments
()
public
function
testInsufficientArguments
()
...
@@ -138,7 +146,7 @@ _MSG_
...
@@ -138,7 +146,7 @@ _MSG_
self
::
N
=>
self
::
N_VALUE
,
self
::
N
=>
self
::
N_VALUE
,
));
));
$this
->
assertEquals
(
$expected
,
$result
);
$this
->
assertEquals
(
$expected
,
$result
,
intl_get_error_message
()
);
}
}
/**
/**
...
@@ -160,10 +168,10 @@ _MSG_
...
@@ -160,10 +168,10 @@ _MSG_
{
{
$pattern
=
'{'
.
self
::
SUBJECT
.
'} is '
.
self
::
N
;
$pattern
=
'{'
.
self
::
SUBJECT
.
'} is '
.
self
::
N
;
$result
=
MessageFormatter
::
formatMessage
(
'en_US'
,
$pattern
,
array
());
$result
=
MessageFormatter
::
formatMessage
(
'en_US'
,
$pattern
,
array
());
$this
->
assertEquals
(
$pattern
,
$result
);
$this
->
assertEquals
(
$pattern
,
$result
,
intl_get_error_message
()
);
$formatter
=
new
MessageFormatter
(
'en_US'
,
$pattern
);
$formatter
=
new
MessageFormatter
(
'en_US'
,
$pattern
);
$result
=
$formatter
->
format
(
array
());
$result
=
$formatter
->
format
(
array
());
$this
->
assertEquals
(
$pattern
,
$result
);
$this
->
assertEquals
(
$pattern
,
$result
,
$formatter
->
getErrorMessage
()
);
}
}
}
}
\ No newline at end of file
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