forked from timber/timber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-timber-text-helper.php
34 lines (29 loc) · 1.25 KB
/
test-timber-text-helper.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
<?php
class TestTimberTextHelper extends Timber_UnitTestCase
{
protected $gettysburg = 'Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.';
public function testStartsWith()
{
$maybe_starts_with = str_starts_with($this->gettysburg, 'Four score');
$this->assertTrue($maybe_starts_with);
}
public function testDontStartWith()
{
$maybe_starts_with = str_starts_with($this->gettysburg, "Can't get enough of that SugarCrisp");
$this->assertFalse($maybe_starts_with);
}
public function testTruncateEastAsian()
{
$chars = "寒くなってきましたね。14日には北海道でも記録的に遅い初雪が降ったそ";
$str = '{{ "' . $chars . '"|truncate( 5, true ) }}';
$result = Timber::compile_string($str);
$this->assertEquals(wp_trim_words($chars, 5), $result);
}
public function testTruncaseEnglish()
{
$chars = $this->gettysburg;
$str = '{{ "' . $chars . '"|truncate( 5, true ) }}';
$result = Timber::compile_string($str);
$this->assertEquals(wp_trim_words($this->gettysburg, 5), $result);
}
}