mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Casting return values on text helper methods in StringField, Text, Varchar
This commit is contained in:
parent
c2c0e1b4b6
commit
e1e5546ab6
@ -9,6 +9,12 @@
|
|||||||
abstract class StringField extends DBField {
|
abstract class StringField extends DBField {
|
||||||
protected $nullifyEmpty = true;
|
protected $nullifyEmpty = true;
|
||||||
|
|
||||||
|
static $casting = array(
|
||||||
|
"LimitCharacters" => "Text",
|
||||||
|
"Lower" => "Text",
|
||||||
|
"Upper" => "Text",
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a string type field with a set of optional parameters
|
* Construct a string type field with a set of optional parameters
|
||||||
* @param $name string The name of the field
|
* @param $name string The name of the field
|
||||||
|
@ -17,8 +17,20 @@
|
|||||||
* @subpackage model
|
* @subpackage model
|
||||||
*/
|
*/
|
||||||
class Text extends StringField {
|
class Text extends StringField {
|
||||||
|
|
||||||
static $casting = array(
|
static $casting = array(
|
||||||
"AbsoluteLinks" => "HTMLText",
|
"AbsoluteLinks" => "Text",
|
||||||
|
"BigSummary" => "Text",
|
||||||
|
"ContextSummary" => "Text",
|
||||||
|
"FirstParagraph" => "Text",
|
||||||
|
"FirstSentence" => "Text",
|
||||||
|
"LimitCharacters" => "Text",
|
||||||
|
"LimitSentences" => "Text",
|
||||||
|
"Summary" => "Text",
|
||||||
|
'EscapeXML' => 'Text',
|
||||||
|
'LimitWordCount' => 'Text',
|
||||||
|
'LimitWordCountXML' => 'HTMLText',
|
||||||
|
'NoHTML' => 'Text',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
* @subpackage model
|
* @subpackage model
|
||||||
*/
|
*/
|
||||||
class Varchar extends StringField {
|
class Varchar extends StringField {
|
||||||
|
|
||||||
|
static $casting = array(
|
||||||
|
"Initial" => "Text",
|
||||||
|
"URL" => "Text",
|
||||||
|
);
|
||||||
|
|
||||||
protected $size;
|
protected $size;
|
||||||
|
|
||||||
|
@ -106,5 +106,33 @@ class HTMLTextTest extends SapphireTest {
|
|||||||
$this->assertEquals($match, $textObj->FirstSentence());
|
$this->assertEquals($match, $textObj->FirstSentence());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRAW() {
|
||||||
|
$data = DBField::create('HTMLText', 'This & This');
|
||||||
|
$this->assertEquals($data->RAW(), 'This & This');
|
||||||
|
|
||||||
|
$data = DBField::create('HTMLText', 'This & This');
|
||||||
|
$this->assertEquals($data->RAW(), 'This & This');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testXML() {
|
||||||
|
$data = DBField::create('HTMLText', 'This & This');
|
||||||
|
$this->assertEquals($data->XML(), 'This & This');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHTML() {
|
||||||
|
$data = DBField::create('HTMLText', 'This & This');
|
||||||
|
$this->assertEquals($data->HTML(), 'This & This');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testJS() {
|
||||||
|
$data = DBField::create('HTMLText', '"this is a test"');
|
||||||
|
$this->assertEquals($data->JS(), '\"this is a test\"');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testATT() {
|
||||||
|
$data = DBField::create('HTMLText', '"this is a test"');
|
||||||
|
$this->assertEquals($data->ATT(), '"this is a test"');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -142,6 +142,30 @@ class TextTest extends SapphireTest {
|
|||||||
'A dog <span class="highlight">ate</span> a cat while looking at a Foobar',
|
'A dog <span class="highlight">ate</span> a cat while looking at a Foobar',
|
||||||
$textObj->ContextSummary(100, $testKeyword3a)
|
$textObj->ContextSummary(100, $testKeyword3a)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRAW() {
|
||||||
|
$data = DBField::create('Text', 'This & This');
|
||||||
|
$this->assertEquals($data->RAW(), 'This & This');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testXML() {
|
||||||
|
$data = DBField::create('Text', 'This & This');
|
||||||
|
$this->assertEquals($data->XML(), 'This & This');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHTML() {
|
||||||
|
$data = DBField::create('Text', 'This & This');
|
||||||
|
$this->assertEquals($data->HTML(), 'This & This');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testJS() {
|
||||||
|
$data = DBField::create('Text', '"this is a test"');
|
||||||
|
$this->assertEquals($data->JS(), '\"this is a test\"');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testATT() {
|
||||||
|
$data = DBField::create('Text', '"this is a test"');
|
||||||
|
$this->assertEquals($data->ATT(), '"this is a test"');
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user