forked from timber/timber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-timber-gettext.php
63 lines (56 loc) · 1.97 KB
/
test-timber-gettext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
class TestTimberGettext extends Timber_UnitTestCase
{
public function test__()
{
$context = Timber::context();
$str = Timber::compile_string("{{ __('my_boo') }}", $context);
$this->assertEquals(__('my_boo'), trim($str));
}
public function testTranslate()
{
$context = Timber::context();
$str = Timber::compile_string("{{ translate('my_boo') }}", $context);
$this->assertEquals(translate('my_boo'), trim($str));
}
public function test_e()
{
$context = Timber::context();
$str = Timber::compile_string("{{ _e('my_boo') }}", $context);
ob_start();
_e('my_boo');
$_e = ob_get_clean();
$this->assertEquals($_e, trim($str));
}
public function test_n()
{
$context = Timber::context();
$str = Timber::compile_string("{{ _n('foo', 'foos', 1 ) }}", $context);
$this->assertEquals(_n('foo', 'foos', 1), trim($str));
$str = Timber::compile_string("{{ _n('foo', 'foos', 2 ) }}", $context);
$this->assertEquals(_n('foo', 'foos', 2), trim($str));
}
public function test_x()
{
$context = Timber::context();
$str = Timber::compile_string("{{ _x('boo', 'my') }}", $context);
$this->assertEquals(_x('boo', 'my'), trim($str));
}
public function test_ex()
{
$context = Timber::context();
$str = Timber::compile_string("{{ _ex('boo', 'my') }}", $context);
ob_start();
_ex('boo', 'my');
$_ex = ob_get_clean();
$this->assertEquals($_ex, trim($str));
}
public function test_nx()
{
$context = Timber::context();
$str = Timber::compile_string("{{ _nx('boo', 'boos', 1, 'my' ) }}", $context);
$this->assertEquals(_nx('boo', 'boos', 1, 'my'), trim($str));
$str = Timber::compile_string("{{ _nx('boo', 'boos', 2, 'my' ) }}", $context);
$this->assertEquals(_nx('boo', 'boos', 2, 'my'), trim($str));
}
}