Browse Source

Added intl check to tests, better error reporting, credited Aura.Intl for the most complex test pattern

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
6b65ef5882
  1. 18
      tests/unit/framework/i18n/MessageFormatterTest.php

18
tests/unit/framework/i18n/MessageFormatterTest.php

@ -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
) )
), ),
// 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_
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_
{ {
$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_
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_
{ {
$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());
} }
} }
Loading…
Cancel
Save