MockTranslateTest
extends TestCase
in package
implements
HeadlessInterface
uses
LocaleTestTrait
Tags
Table of Contents
Interfaces
- HeadlessInterface
- Interface HeadlessInterface
Constants
- EXAMPLE_LOCALE = 'fr_FR'
- TARGET_NAME = '*'
Properties
- $cleanL10n : object|null
Methods
- disableMultilingual() : void
- enableMultilingual() : void
- Enable multilingual.
- getExamples() : array<string|int, mixed>
- setUp() : void
- setUpHeadless() : mixed
- The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
- tearDownAfterClass() : void
- testTranslate() : void
- useMultilingual() : CRM_Utils_AutoClean
- Temporarily use multilingual.
- getDefaultSystemLocale() : string
- Get the default system locale.
- setTranslation() : void
- Store a translation
- setTranslations() : void
Constants
EXAMPLE_LOCALE
public
mixed
EXAMPLE_LOCALE
= 'fr_FR'
TARGET_NAME
public
mixed
TARGET_NAME
= '*'
Properties
$cleanL10n
protected
static object|null
$cleanL10n
= NULL
Autoclean object. When dereferenced, it will cleanup the l10n settings.
Methods
disableMultilingual()
public
disableMultilingual() : void
enableMultilingual()
Enable multilingual.
public
enableMultilingual([array<string|int, mixed>|null $addLocales = null ]) : void
Parameters
- $addLocales : array<string|int, mixed>|null = null
-
A list of new locales to setup. A locale is initialized by copying from an existing locale.
Ex: Copy from en_US to fr_CA ['en_US' => 'fr_CA'] Ex: Copy from en_US to fr_CA and de_DE ['en_US' => ['fr_CA', 'de_DE]]
getExamples()
public
getExamples() : array<string|int, mixed>
Return values
array<string|int, mixed>setUp()
public
setUp() : void
setUpHeadless()
The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
public
setUpHeadless() : mixed
It should perform any necessary steps required for putting the database in a consistent baseline -- such as loading schema and extensions.
The utility \Civi\Test::headless() provides a number of helper functions
for managing this setup, and it includes optimizations to avoid redundant
setup work.
tearDownAfterClass()
public
static tearDownAfterClass() : void
testTranslate()
public
testTranslate(string $name) : void
Parameters
- $name : string
-
Name of a sample Afform from
ang/translate/.
Tags
useMultilingual()
Temporarily use multilingual.
public
useMultilingual(array<string|int, mixed> $addLocales) : CRM_Utils_AutoClean
Parameters
- $addLocales : array<string|int, mixed>
-
A list of new locales to setup. A locale is initialized by copying from an existing locale.
Ex: Copy from en_US to fr_CA ['en_US' => 'fr_CA'] Ex: Copy from en_US to fr_CA and de_DE ['en_US' => ['fr_CA', 'de_DE]]
Return values
CRM_Utils_AutoClean —A reference to the temporary configuration. Once removed, the system will revert to single language.
getDefaultSystemLocale()
Get the default system locale.
protected
getDefaultSystemLocale() : string
Return values
stringsetTranslation()
Store a translation
protected
setTranslation(string $original, string $language, string $translated) : void
TODO: This helper feels like it would be useful elsewhere...
Parameters
- $original : string
-
Ex: 'Hello world'
- $language : string
-
Ex: 'fr_FR'
- $translated : string
-
Ex: 'Bonjour, tout le monde'
Tags
setTranslations()
protected
setTranslations(string $language, array<string|int, mixed> $applyTranslations) : void
Parameters
- $language : string
-
Ex: 'fr_FR'
- $applyTranslations : array<string|int, mixed>
-
Ex: ['Hello' => 'Bonjour', 'Later dawg' => 'Plus tard mon gars']