3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Tests for parsing translatable strings in HTML content.
16 class CRM_Core_Resources_StringsTest
extends CiviUnitTestCase
{
19 * Get strings from files.
21 public function testGet() {
22 $basedir = $this->createExamples();
23 $strings = new CRM_Core_Resources_Strings(
24 new CRM_Utils_Cache_Arraycache(NULL)
27 ['Hello from Javascript'],
28 $strings->get('example', "$basedir/hello.js", "text/javascript")
32 $strings->get('example', "$basedir/hello.html", "text/html")
38 * Path to the example dir.
40 public function createExamples() {
41 $basedir = rtrim($this->createTempDir('ext-'), '/');
42 file_put_contents("$basedir/hello.js", "alert(ts('Hello from Javascript'));");
43 file_put_contents("$basedir/hello.html", "<div>{{ts('Hello from HTML')}}</div>");