Commit 6b65ef58 by Alexander Makarov

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
...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment