diff --git a/src/ORM/FieldType/DBText.php b/src/ORM/FieldType/DBText.php index 80fb23d55..c7218f436 100644 --- a/src/ORM/FieldType/DBText.php +++ b/src/ORM/FieldType/DBText.php @@ -128,7 +128,7 @@ class DBText extends DBString // If no $elipsis string is provided, use the default one. if ($add === false) { - $add = $this->defaultEllipsis(); + $add = $this->defaultEllipsis(); } // Split on sentences (don't remove period) @@ -199,11 +199,11 @@ class DBText extends DBString } if ($prefix === false) { - $prefix = $this->getDefaultValue() . ' '; + $prefix = $this->defaultEllipsis() . ' '; } if ($suffix === false) { - $prefix = $this->getDefaultValue(); + $suffix = $this->defaultEllipsis(); } // Get raw text value, but XML encode it (as we'll be merging with HTML tags soon) @@ -270,5 +270,4 @@ class DBText extends DBString { return new TextField($this->name, $title); } - } diff --git a/tests/php/ORM/DBFieldTest.php b/tests/php/ORM/DBFieldTest.php index fda6e235e..d4be748dd 100644 --- a/tests/php/ORM/DBFieldTest.php +++ b/tests/php/ORM/DBFieldTest.php @@ -301,7 +301,7 @@ class DBFieldTest extends SapphireTest foreach ($allFields as $stringField) { $stringField = DBString::create_field($stringField, $value); for ($i = 1; $i < mb_strlen($value); $i++) { - $expected = mb_substr($value, 0, $i) . '...'; + $expected = mb_substr($value, 0, $i) . '…'; $this->assertEquals($expected, $stringField->LimitCharacters($i)); } } @@ -311,10 +311,10 @@ class DBFieldTest extends SapphireTest $stringObj = DBString::create_field($stringField, $value); // Converted to plain text - $this->assertEquals('üåäö&ÜÅÄ...', $stringObj->LimitCharacters(8)); + $this->assertEquals('üåäö&ÜÅÄ…', $stringObj->LimitCharacters(8)); // But which will be safely cast in templates - $this->assertEquals('üåäö&ÜÅÄ...', $stringObj->obj('LimitCharacters', [8])->forTemplate()); + $this->assertEquals('üåäö&ÜÅÄ…', $stringObj->obj('LimitCharacters', [8])->forTemplate()); } $this->assertEquals('ÅÄÖ', DBText::create_field('Text', 'åäö')->UpperCase()); diff --git a/tests/php/ORM/DBHTMLTextTest.php b/tests/php/ORM/DBHTMLTextTest.php index 56d92f8c4..3a54c5b0c 100644 --- a/tests/php/ORM/DBHTMLTextTest.php +++ b/tests/php/ORM/DBHTMLTextTest.php @@ -49,9 +49,9 @@ class DBHTMLTextTest extends SapphireTest { // HTML characters are stripped safely return [ - ['The little brown fox jumped over the lazy cow.', 'The little brown fox...'], + ['The little brown fox jumped over the lazy cow.', 'The little brown fox…'], ['
Short & Sweet
', 'Short & Sweet'], - ['This text contains & in it', 'This text contains &...'], + ['This text contains & in it', 'This text contains &…'], ]; } @@ -77,7 +77,7 @@ class DBHTMLTextTest extends SapphireTest // HTML is converted safely to plain text return [ // Standard words limited, ellipsis added if truncated - ['Lorem ipsum dolor sit amet
', 24, 'Lorem ipsum dolor sit...'], + ['Lorem ipsum dolor sit amet
', 24, 'Lorem ipsum dolor sit…'], // Complete words less than the character limit don't get truncated, ellipsis not added ['Lorem ipsum
', 24, 'Lorem ipsum'], @@ -88,10 +88,10 @@ class DBHTMLTextTest extends SapphireTest ['Nice & Easy', 24, 'Nice & Easy'], // HTML is safely converted to plain text - ['Lorem ipsum dolor sit amet
', 24, 'Lorem ipsum dolor sit...'], - ['Lorem ipsum dolor sit amet
', 24, 'Lorem ipsum dolor sit...'], + ['Lorem ipsum dolor sit amet
', 24, 'Lorem ipsum dolor sit…'], + ['Lorem ipsum dolor sit amet
', 24, 'Lorem ipsum dolor sit…'], ['Lorem ipsum
', 24, 'Lorem ipsum'], - ['Lorem & ipsum dolor sit amet', 24, 'Lorem & ipsum dolor sit...'] + ['Lorem & ipsum dolor sit amet', 24, 'Lorem & ipsum dolor sit…'] ]; } @@ -151,12 +151,12 @@ class DBHTMLTextTest extends SapphireTest [ 'A long paragraph should be cut off if limit is set
', 5, - 'A long paragraph should be...', + 'A long paragraph should be…', ], [ 'No matter how many tags are in it
', 5, - 'No matter how many tags...', + 'No matter how many tags…', ], [ 'A sentence is. nicer than hard limits
', @@ -299,7 +299,7 @@ class DBHTMLTextTest extends SapphireTest 'This is some text. It is a test', 20, 'test', - '... text. It is a test' + '… text. It is a test' ], [ // Retains case of original string @@ -307,13 +307,13 @@ class DBHTMLTextTest extends SapphireTest 50, 'some test', 'This is some test text.' - . ' Test test what if you have...' + . ' Test test what if you have…' ], [ 'Here is some text & HTML included', 20, 'html', - '... text & HTML inc...' + '… text & HTML inc…' ], [ 'A dog ate a cat while looking at a Foobar', @@ -343,16 +343,16 @@ class DBHTMLTextTest extends SapphireTestwith about more stuff after the line break
', 35, 'test', - '... really, this is a test sentence...' + '… really, this is a test sentence…' ], [ 'This is a lot of text before this but really, this is a test sentence
with about more stuff after the line break
', 50, 'with', - '... sentence