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 in...', 'This text contains & in it' => 'This text contains &...' ); foreach($cases as $originalValue => $expectedValue) { $textObj = new HTMLText('Test'); $textObj->setValue($originalValue); $this->assertEquals($expectedValue, $textObj->LimitCharacters()); } } function testSummaryBasics() { $cases = array( 'Should take paragraph
' => 'Should take paragraph', 'Should strip tags, but leave text
' => 'Should strip tags, but leave text', 'Unclosed tags
should not phase it
Second paragraph
should not cause errors or appear in output
' => 'Second paragraph', 'Second paragraph
should not cause errors or appear in output
' => 'Second paragraph', 'Second paragraph
should not cause errors or appear in output
' => 'Second paragraph', 'example text words hello
' => 'example text words hello', ); foreach($cases as $originalValue => $expectedValue) { $textObj = new HTMLText('Test'); $textObj->setValue($originalValue); $this->assertEquals($expectedValue, $textObj->Summary()); } } function testSummaryLimits() { $cases = array( 'A long paragraph should be cut off if limit is set
' => 'A long paragraph should be...', 'No matter how many tags are in it
' => 'No matter how many tags...', 'A sentence is. nicer than hard limits
' => 'A sentence is.', 'But not. If it\'s too short
' => 'But not. If it\'s too...' ); foreach($cases as $originalValue => $expectedValue) { $textObj = new HTMLText('Test'); $textObj->setValue($originalValue); $this->assertEquals($expectedValue, $textObj->Summary(5, 3, '...')); } } function testSummaryEndings() { $cases = array( '...', ' -> more', '' ); $orig = 'Cut it off, cut it off
'; $match = 'Cut it off, cut'; foreach($cases as $add) { $textObj = new HTMLText(); $textObj->setValue($orig); $this->assertEquals($match.$add, $textObj->Summary(4, 0, $add)); } } function testSummaryFlexTooBigShouldNotCauseError() { $orig = 'Cut it off, cut it off
'; $match = 'Cut it off, cut'; $textObj = new HTMLText(); $textObj->setValue($orig); $this->assertEquals($match, $textObj->Summary(4, 10, '')); } function testSummaryInvalidHTML() { $cases = array( 'It\'s got atag, but
This doesn\'t make < > Sentence with {$many}words. Second sentence.