Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ZurmoMessageSourceUtilTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
42  protected static $testLanguageCode = 'de';
43 
44  protected static $testCategory = 'UtilTest';
45 
46  protected static $testMessageSource = 'messageUtilOne-source';
47 
48  protected static $testMessageNewTranslation = 'messageUtilOne-translation';
49 
50  protected static $testMessageUpdatedTranslation = 'messageUtilOne-updatedTranslation';
51 
52  protected static $testMessagesNew = array(
53  'messageUtil1-source' => 'messageUtil1-translation',
54  'messageUtil2-source' => 'messageUtil2-translation',
55  'messageUtil3-source' => 'messageUtil3-translation',
56  'messageUtil4-source' => 'messageUtil4-translation',
57  'messageUtil5-source' => 'messageUtil5-translation',
58  'messageUtil6-source' => 'messageUtil6-translation'
59  );
60 
61  protected static $testMessagesUpdated = array(
62  'messageUtil1-source' => 'messageUtil1-updatedTranslation',
63  'messageUtil2-source' => 'messageUtil2-updatedTranslation',
64  'messageUtil3-source' => 'messageUtil3-updatedTranslation',
65  'messageUtil4-source' => 'messageUtil4-updatedTranslation',
66  'messageUtil5-source' => 'messageUtil5-updatedTranslation',
67  'messageUtil6-source' => 'messageUtil6-updatedTranslation'
68  );
69 
70  public function testImportOneMessageNew()
71  {
73  self::$testLanguageCode,
74  self::$testCategory,
75  self::$testMessageSource,
76  self::$testMessageNewTranslation
77  );
78  ZurmoMessageSource::clearCache(self::$testCategory, self::$testLanguageCode);
79  $messageSource = new ZurmoMessageSource();
80 
81  $translation = $messageSource->translate(
82  self::$testCategory,
83  self::$testMessageSource,
84  self::$testLanguageCode
85  );
86 
87  $this->assertEquals($translation, self::$testMessageNewTranslation);
88  }
89 
93  public function testImportOneMessageUpdated()
94  {
96  self::$testLanguageCode,
97  self::$testCategory,
98  self::$testMessageSource,
99  self::$testMessageUpdatedTranslation
100  );
101  ZurmoMessageSource::clearCache(self::$testCategory, self::$testLanguageCode);
102  $messageSource = new ZurmoMessageSource();
103 
104  $translation = $messageSource->translate(
105  self::$testCategory,
106  self::$testMessageSource,
107  self::$testLanguageCode
108  );
109 
110  $this->assertEquals($translation, self::$testMessageUpdatedTranslation);
111  }
112 
116  public function testImportMessagesArrayNew()
117  {
119  self::$testLanguageCode,
120  self::$testCategory,
121  self::$testMessagesNew
122  );
123 
124  $messageSource = new ZurmoMessageSource();
125 
126  foreach (self::$testMessagesNew as $source => $compareTranslation)
127  {
128  $translation = $messageSource->translate(
129  self::$testCategory,
130  $source,
131  self::$testLanguageCode
132  );
133  $this->assertEquals($translation, $compareTranslation);
134  }
135  }
136 
141  {
143  self::$testLanguageCode,
144  self::$testCategory,
145  self::$testMessagesUpdated
146  );
147 
148  $messageSource = new ZurmoMessageSource();
149 
150  foreach (self::$testMessagesUpdated as $source => $compareTranslation)
151  {
152  $translation = $messageSource->translate(
153  self::$testCategory,
154  $source,
155  self::$testLanguageCode
156  );
157  $this->assertEquals($translation, $compareTranslation);
158  }
159  }
160 
161  public function testImportPoFile()
162  {
163  $testLanguageCode = 'po';
164 
165  $pathToFiles = Yii::getPathOfAlias('application.tests.unit.files');
166  $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'messages-test.po';
167 
168  ZurmoMessageSourceUtil::importPoFile($testLanguageCode, $filePath);
169 
170  $file = new ZurmoGettextPoFile($filePath);
171  $messages = $file->read($filePath);
172 
173  $messageSource = new ZurmoMessageSource();
174 
175  foreach ($messages as $message)
176  {
177  $translation = $messageSource->translate(
178  $message['msgctxt'],
179  $message['msgid'],
180  $testLanguageCode
181  );
182 
183  $this->assertEquals($translation, $message['msgstr']);
184  }
185  }
186  }
187 ?>
static importPoFile($languageCode, $messageFile)
static importOneMessage($languageCode, $category, $source, $translation)
static importMessagesArray($languageCode, $category, $messages)
Generated on Sat Jul 4 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.