Commit 9f37e133 by Qiang Xue

Fixed test break.

parent 2a6bc68c
...@@ -116,10 +116,8 @@ class MessageSource extends Component ...@@ -116,10 +116,8 @@ class MessageSource extends Component
$this->trigger(self::EVENT_MISSING_TRANSLATION, $event); $this->trigger(self::EVENT_MISSING_TRANSLATION, $event);
if ($event->translatedMessage !== null) { if ($event->translatedMessage !== null) {
return $this->_messages[$key][$message] = $event->translatedMessage; return $this->_messages[$key][$message] = $event->translatedMessage;
} else {
return $this->_messages[$key][$message] = false;
} }
} }
return false; return $this->_messages[$key][$message] = false;
} }
} }
...@@ -116,13 +116,14 @@ class I18NTest extends TestCase ...@@ -116,13 +116,14 @@ class I18NTest extends TestCase
Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION); Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION);
Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function($event) { Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function($event) {
if ($event->message == 'Missing translation message.') { if ($event->message == 'New missing translation message.') {
$event->translatedMessage = 'TRANSLATION MISSING HERE!'; $event->translatedMessage = 'TRANSLATION MISSING HERE!';
} }
}); });
$this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE'));
$this->assertEquals('Another missing translation message.', $this->i18n->translate('test', 'Another missing translation message.', [], 'de-DE')); $this->assertEquals('Another missing translation message.', $this->i18n->translate('test', 'Another missing translation message.', [], 'de-DE'));
$this->assertEquals('TRANSLATION MISSING HERE!', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE'));
$this->assertEquals('TRANSLATION MISSING HERE!', $this->i18n->translate('test', 'New missing translation message.', [], 'de-DE'));
$this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE'));
Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION); Event::off(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION);
} }
......
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