LimitCharacters()} */ function testLimitCharacters() { $cases = array( 'The little brown fox jumped over the lazy cow.' => 'The little brown fox...', '

This is some text in a paragraph.

' => '

This is some text...' ); foreach($cases as $originalValue => $expectedValue) { $textObj = new Text('Test'); $textObj->setValue($originalValue); $this->assertEquals($expectedValue, $textObj->LimitCharacters()); } } /** * Test {@link Text->LimitWordCount()} */ function testLimitWordCount() { $cases = array( /* Standard words limited, ellipsis added if truncated */ 'The little brown fox jumped over the lazy cow.' => 'The little brown...', ' This text has white space around the ends ' => 'This text has...', /* 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...', '

Two words

' => 'Two words' ); 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( '

Stuff & stuff

' => 'Stuff &...', "Stuff\nBlah Blah Blah" => "Stuff
Blah Blah...", "Stuff "Stuff<Blah Blah", "Stuff>Blah Blah" => "Stuff>Blah Blah" ); foreach($cases as $originalValue => $expectedValue) { $textObj = new Text('Test'); $textObj->setValue($originalValue); $this->assertEquals($expectedValue, $textObj->LimitWordCountXML(3)); } } /** * Test {@link Text->LimitSentences()} */ function testLimitSentences() { $cases = array( '' => '', 'First sentence.' => 'First sentence.', 'First sentence. Second sentence' => 'First sentence. Second sentence.', '

First sentence.

' => 'First sentence.', '

First sentence. Second sentence. Third sentence

' => 'First sentence. Second sentence.', '

First sentence. Second sentence. Third sentence

' => 'First sentence. Second sentence.', '

First sentence. Second sentence. Third sentence

' => 'First sentence. Second sentence.' ); foreach($cases as $originalValue => $expectedValue) { $textObj = new Text('Test'); $textObj->setValue($originalValue); $this->assertEquals($expectedValue, $textObj->LimitSentences(2)); } } /** * Test {@link Text->BigSummary()} */ function testBigSummary() { $cases = array( 'This text has multiple sentences. Big Summary uses this to split sentences up.' => 'This text has multiple...', 'This text does not have multiple sentences' => 'This text does not...', 'Very short' => 'Very short', '' => '' ); foreach($cases as $originalValue => $expectedValue) { $textObj = DBField::create('Text', $originalValue); $this->assertEquals($expectedValue, $textObj->BigSummary(4)); } } } ?>