ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
TextTest.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12require_once __DIR__.'/../../../../lib/Twig/Extensions/Extension/Text.php';
13
15{
17 private $env;
18
19 public function setUp()
20 {
21 $this->env = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
22 $this->env
23 ->expects($this->any())
24 ->method('getCharset')
25 ->will($this->returnValue('utf-8'))
26 ;
27 }
28
32 public function testTruncate($input, $length, $preserve, $separator, $expectedOutput)
33 {
34 $output = twig_truncate_filter($this->env, $input, $length, $preserve, $separator);
35 $this->assertEquals($expectedOutput, $output);
36 }
37
38 public function getTruncateTestData()
39 {
40 return array(
41 array('This is a very long sentence.', 2, false, '...', 'Th...'),
42 array('This is a very long sentence.', 6, false, '...', 'This i...'),
43 array('This is a very long sentence.', 2, true, '...', 'This...'),
44 array('This is a very long sentence.', 2, true, '[...]', 'This[...]'),
45 array('This is a very long sentence.', 23, false, '...', 'This is a very long sen...'),
46 array('This is a very long sentence.', 23, true, '...', 'This is a very long sentence.'),
47 );
48 }
49}
An exception for terminatinating execution or to throw for unit testing.
testTruncate($input, $length, $preserve, $separator, $expectedOutput)
@dataProvider getTruncateTestData
Definition: TextTest.php:32
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output