|
19 | 19 | namespace Cake\TwigView\Test\TestCase\Twig\Extension; |
20 | 20 |
|
21 | 21 | use Cake\TwigView\Twig\Extension\StringsExtension; |
| 22 | +use Cake\Utility\Text; |
22 | 23 |
|
23 | 24 | class StringsExtensionTest extends AbstractExtensionTest |
24 | 25 | { |
@@ -98,23 +99,29 @@ public function testFilterTail() |
98 | 99 | $input = 'Bob is 65 years old.'; |
99 | 100 | $callable = $this->getFilter('tail')->getCallable(); |
100 | 101 | $result = call_user_func_array($callable, [$input, 7]); |
101 | | - $this->assertSame('...old.', $result); |
| 102 | + // Cake >= 5.1 '…s old.' |
| 103 | + // Cake < 5.1 '...old.' |
| 104 | + $this->assertSame(Text::tail($input, 7), $result); |
102 | 105 | } |
103 | 106 |
|
104 | 107 | public function testFilterTruncate() |
105 | 108 | { |
106 | 109 | $input = 'Bob is 65 years old.'; |
107 | 110 | $callable = $this->getFilter('truncate')->getCallable(); |
108 | 111 | $result = call_user_func_array($callable, [$input, 7]); |
109 | | - $this->assertSame('Bob ...', $result); |
| 112 | + // Cake >= 5.1 'Bob is…' |
| 113 | + // Cake < 5.1 'Bob ...' |
| 114 | + $this->assertSame(Text::truncate($input, 7), $result); |
110 | 115 | } |
111 | 116 |
|
112 | 117 | public function testFilterExcerpt() |
113 | 118 | { |
114 | 119 | $input = 'Bob is 65 years old.'; |
115 | 120 | $callable = $this->getFilter('excerpt')->getCallable(); |
116 | 121 | $result = call_user_func_array($callable, [$input, '65', 4]); |
117 | | - $this->assertSame('... is 65 yea...', $result); |
| 122 | + // Cake >= 5.1 '… is 65 yea…' |
| 123 | + // Cake < 5.1 '... is 65 yea...' |
| 124 | + $this->assertSame(Text::excerpt($input, '65', 4), $result); |
118 | 125 | } |
119 | 126 |
|
120 | 127 | public function testFilterToList() |
|
0 commit comments