BUGFIX #5243 Undefined Convert functions in ViewableData replaced with working versions. Thanks benediktb!

MINOR Updated ViewableDataTest to verify ViewableData changes (from r101638)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112013 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-13 00:56:04 +00:00
parent f073c9b60c
commit 4414b8a747
2 changed files with 27 additions and 5 deletions

View File

@ -441,7 +441,6 @@ class ViewableData extends Object implements IteratorAggregate {
*/
public function XML_val($field, $arguments = null, $cache = false) {
$result = $this->obj($field, $arguments, false, $cache);
return is_object($result) ? $result->forTemplate() : $result;
}
@ -453,24 +452,24 @@ class ViewableData extends Object implements IteratorAggregate {
}
/**
* Returnt he value of a field in an SQL-safe format.
* Return the value of a field in an SQL-safe format.
*/
public function SQL_val($field, $arguments = null, $cache = true) {
return Convert::xml2sql($this->XML_val($field, $arguments, $cache));
return Convert::raw2sql($this->RAW_val($field, $arguments, $cache));
}
/**
* Return the value of a field in a JavaScript-save format.
*/
public function JS_val($field, $arguments = null, $cache = true) {
return Convert::xml2js($this->XML_val($field, $arguments, $cache));
return Convert::raw2js($this->RAW_val($field, $arguments, $cache));
}
/**
* Return the value of a field escaped suitable to be inserted into an XML node attribute.
*/
public function ATT_val($field, $arguments = null, $cache = true) {
return Convert::xml2att($this->XML_val($field, $arguments, $cache));
return Convert::raw2att($this->RAW_val($field, $arguments, $cache));
}
/**#@-*/

View File

@ -56,6 +56,29 @@ class ViewableDataTest extends SapphireTest {
$this->assertEquals('casted', $newViewableData->XML_val('alwaysCasted'));
}
public function testRAWVal() {
$data = new ViewableDataTest_Castable();
$data->test = 'This & This';
$this->assertEquals($data->RAW_val('test'), 'This & This');
}
public function testSQLVal() {
$data = new ViewableDataTest_Castable();
$this->assertEquals($data->SQL_val('test'), 'test');
}
public function testJSVal() {
$data = new ViewableDataTest_Castable();
$data->test = '"this is a test"';
$this->assertEquals($data->JS_val('test'), '\"this is a test\"');
}
public function testATTVal() {
$data = new ViewableDataTest_Castable();
$data->test = '"this is a test"';
$this->assertEquals($data->ATT_val('test'), '"this is a test"');
}
}
/**#@+