Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX #5243 Undefined Convert functions in ViewableData replaced wit…

…h 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
  • Loading branch information...
commit 4414b8a747a0c6f12e404b513bb471e76074b17b 1 parent f073c9b
@sminnee sminnee authored
Showing with 27 additions and 5 deletions.
  1. +4 −5 core/ViewableData.php
  2. +23 −0 tests/ViewableDataTest.php
View
9 core/ViewableData.php
@@ -441,7 +441,6 @@ public function hasValue($field, $arguments = null, $cache = true) {
*/
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 @@ public function RAW_val($field, $arguments = null, $cache = true) {
}
/**
- * 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
23 tests/ViewableDataTest.php
@@ -56,6 +56,29 @@ public function testObjectCustomise() {
$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"');
+ }
+
}
/**#@+
Please sign in to comment.
Something went wrong with that request. Please try again.