From 5ccca85e7f1c19087d312c9608df076173d28016 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 12 Feb 2009 09:24:33 +0000 Subject: [PATCH] MINOR Added TextTest - was missing after merge from branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@71792 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/fieldtypes/TextTest.php | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/fieldtypes/TextTest.php diff --git a/tests/fieldtypes/TextTest.php b/tests/fieldtypes/TextTest.php new file mode 100644 index 000000000..73f91c4e0 --- /dev/null +++ b/tests/fieldtypes/TextTest.php @@ -0,0 +1,49 @@ +LimitWordCount()} + */ + function testLimitWordCount() { + $cases = array( + /* Standard words limited, ellipsis added if truncated */ + 'The little brown fox jumped over the lazy cow.' => 'The little brown...', + + /* Words less than the limt word count don't get truncated, ellipsis not added */ + 'Two words' => 'Two words', // Two words shouldn't have an ellipsis + 'One' => 'One', // Neither should one word + '' => '', // No words produces nothing! + + /* HTML tags get stripped out, leaving the raw text */ + '

Text inside a paragraph tag should also work

' => 'Text inside a...', + '

Text nested inside another tag should also work

' => 'Text nested inside...' + ); + + foreach($cases as $originalValue => $expectedValue) { + $textObj = new Text('Test'); + $textObj->setValue($originalValue); + $this->assertEquals($expectedValue, $textObj->LimitWordCount(3)); + } + } + + /** + * Test {@link Text->LimitWordCountXML()} + */ + /*function testLimitWordCountXML() { + $cases = array( + // @todo add cases to test by + ); + + foreach($cases as $originalValue => $expectedValue) { + $textObj = new Text('Test'); + $textObj->setValue($originalValue); + $this->assertEquals($expectedValue, $textObj->LimitWordCountXML(3)); + } + }*/ + +} +?> \ No newline at end of file