mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
1d121b7f90
commit
5ccca85e7f
49
tests/fieldtypes/TextTest.php
Normal file
49
tests/fieldtypes/TextTest.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package sapphire
|
||||||
|
* @subpackage tests
|
||||||
|
*/
|
||||||
|
class TextTest extends SapphireTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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...',
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
'<p>Text inside a paragraph tag should also work</p>' => 'Text inside a...',
|
||||||
|
'<p><span>Text nested inside another tag should also work</span></p>' => '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));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user