CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

StdLib_NeatlyTruncateString--Test.php
Go to the documentation of this file.
1 <?PHP
2
6 class NeatlyTruncateString_Test extends PHPUnit\Framework\TestCase
7 {
8
12 public function testNTS()
13 {
14 $this->assertEquals(
15 "test",
16 StdLib::NeatlyTruncateString("test", 10) );
17
18 $this->assertEquals(
19 "this test...",
20 StdLib::NeatlyTruncateString(
21 "this test test test", 10) );
22
23 $this->assertEquals(
24 "asdfgasdfg...",
25 StdLib::NeatlyTruncateString(
26 "asdfgasdfgasdfgasdfg", 10) );
27
28 $this->assertEquals(
29 "test te...",
30 StdLib::NeatlyTruncateString(
31 "test test test", 7, TRUE));
32
33 $this->assertEquals(
34 "<b>test</b>",
35 StdLib::NeatlyTruncateString(
36 "<b>test</b>", 10));
37
38 $this->assertEquals(
39 "<b>test test...</b>",
40 StdLib::NeatlyTruncateString(
41 "<b>test test test test test</b>", 10));
42
43 $this->assertEquals(
44 "<b>test...</b>",
45 StdLib::NeatlyTruncateString(
46 "<b>test asdfgasdfgasdfgadsfg</b>", 10));
47
48 $this->assertEquals(
49 "<b>test <i>test</i>...</b>",
50 StdLib::NeatlyTruncateString(
51 "<b>test <i>test</i> test</b> test", 10));
52
53 $this->assertEquals(
54 "<b>test <i>asdfg</i>...</b>",
55 StdLib::NeatlyTruncateString(
56 "<b>test <i>asdfg</i>asdfg</b>", 10));
57
58 $this->assertEquals(
59 "<b>test&nbsp;test&nbsp;...</b>",
60 StdLib::NeatlyTruncateString(
61 "<b>test&nbsp;test&nbsp;test&nbsp;test&nbsp;</b>", 10));
62
63 $this->assertEquals(
64 "<a href='http://www.example.com/'>test</a> <b>test</b>...",
65 StdLib::NeatlyTruncateString(
66 "<a href='http://www.example.com/'>test</a> <b>test</b> test test", 10));
67
68 $this->assertEquals(
69 "<b>abc < abc...</b>",
70 StdLib::NeatlyTruncateString(
71 "<b>abc < abc test test</b>", 10));
72
73 $this->assertEquals(
74 "<b>abc & abc ...</b>",
75 StdLib::NeatlyTruncateString(
76 "<b>abc & abc & abc & abc</b>", 10));
77
78 $this->assertEquals(
79 "<b>&testasdfg...</b>",
80 StdLib::NeatlyTruncateString(
81 "<b>&testasdfg asdfgasdfg</b>", 10));
82 }
83 }
NeatlyTruncateString_Test
Test cases for NeatlyTruncateString in StdLib.
Definition: StdLib_NeatlyTruncateString--Test.php:6
PHP
PHP
Definition: RSSClient--Test.php:12
NeatlyTruncateString_Test\testNTS
testNTS()
Test NeatlyTruncateString.
Definition: StdLib_NeatlyTruncateString--Test.php:12
StdLib\NeatlyTruncateString
static NeatlyTruncateString($String, $MaxLength, $BreakAnywhere=FALSE)
Attempt to truncate a string as neatly as possible with respect to word breaks, punctuation, and HTML tags.
Definition: StdLib.php:239