public function testLoadMessagesFromDb()
 {
     $messageSource = new ZurmoMessageSource();
     foreach (self::$testMessages as $source => $compareTranslation) {
         $translation = $messageSource->translate(self::$testCategory, $source, self::$testLanguageCode);
         $this->assertEquals($translation, $compareTranslation);
     }
 }
 /**
  * Loads all messages with context from PO file and imports them to the database
  *
  * @param String $languageCode The language code
  * @param String $messageFile Path to the PO file to import.
  * @return Boolean Status of the import
  * @throws NotSupportedException
  */
 public static function importPoFile($languageCode, $messageFile)
 {
     assert('is_string($languageCode) && !empty($languageCode)');
     if (!is_string($languageCode) || empty($languageCode)) {
         throw new NotSupportedException();
     }
     $file = new ZurmoGettextPoFile($messageFile);
     $messages = $file->read();
     $categories = array();
     foreach ($messages as $message) {
         if (!in_array($message['msgctxt'], $categories)) {
             $categories[] = $message['msgctxt'];
         }
         self::importOneMessage($languageCode, $message['msgctxt'], $message['msgid'], $message['msgstr']);
     }
     foreach ($categories as $category) {
         ZurmoMessageSource::clearCache($category, $languageCode);
     }
     return true;
 }
 public function testImportPoFile()
 {
     $testLanguageCode = 'po';
     $pathToFiles = Yii::getPathOfAlias('application.tests.unit.files');
     $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'messages-test.po';
     ZurmoMessageSourceUtil::importPoFile($testLanguageCode, $filePath);
     $file = new ZurmoGettextPoFile($filePath);
     $messages = $file->read($filePath);
     $messageSource = new ZurmoMessageSource();
     foreach ($messages as $message) {
         $translation = $messageSource->translate($message['msgctxt'], $message['msgid'], $testLanguageCode);
         $this->assertEquals($translation, $message['msgstr']);
     }
 }