Skip to content
Browse files

API CHANGE: Remove ArrayData::forTemplate(), because it has little us…

…efulness corrupts ViewableData customisation.
  • Loading branch information...
1 parent dc439ed commit edf6cd6d8394662649fab8da0d6f70ff0c5d26e6 @beerbohmdo beerbohmdo committed with sminnee
Showing with 15 additions and 18 deletions.
  1. +0 −5 tests/core/ArrayDataTest.php
  2. +15 −6 tests/view/ViewableDataTest.php
  3. +0 −7 view/ArrayData.php
View
5 tests/core/ArrayDataTest.php
@@ -62,11 +62,6 @@ function testRefusesToWrapAnIndexedArray() {
// $arrayData = new ArrayData($array);
}
- function testForTemplateWorks() {
- $arrayData = new ArrayData(array('b' => 'bunny'));
- $this->assertEquals("array (\n 'b' => 'bunny',\n)", $arrayData->forTemplate());
- }
-
function testSetField() {
$arrayData = new ArrayData(array());
View
21 tests/view/ViewableDataTest.php
@@ -55,22 +55,28 @@ public function testArrayCustomise() {
$this->assertEquals('test', $viewableData->XML_val('test'));
$this->assertEquals('casted', $viewableData->XML_val('alwaysCasted'));
-
+
$this->assertEquals('overwritten', $newViewableData->XML_val('test'));
$this->assertEquals('overwritten', $newViewableData->XML_val('alwaysCasted'));
+
+ $this->assertEquals('castable', $viewableData->forTemplate());
+ $this->assertEquals('castable', $newViewableData->forTemplate());
}
-
+
public function testObjectCustomise() {
$viewableData = new ViewableDataTest_Castable();
$newViewableData = $viewableData->customise(new ViewableDataTest_RequiresCasting());
-
+
$this->assertEquals('test', $viewableData->XML_val('test'));
$this->assertEquals('casted', $viewableData->XML_val('alwaysCasted'));
-
+
$this->assertEquals('overwritten', $newViewableData->XML_val('test'));
$this->assertEquals('casted', $newViewableData->XML_val('alwaysCasted'));
+
+ $this->assertEquals('castable', $viewableData->forTemplate());
+ $this->assertEquals('casted', $newViewableData->forTemplate());
}
-
+
public function testRAWVal() {
$data = new ViewableDataTest_Castable();
$data->test = 'This & This';
@@ -161,7 +167,10 @@ public function unsafeXML() {
public function castedUnsafeXML() {
return $this->unsafeXML();
}
-
+
+ public function forTemplate() {
+ return 'castable';
+ }
}
class ViewableDataTest_RequiresCasting extends ViewableData {
View
7 view/ArrayData.php
@@ -102,13 +102,6 @@ public static function array_to_object($arr = null) {
}
/**
- * This is pretty crude, but it helps diagnose error situations
- */
- function forTemplate() {
- return var_export($this->array, true);
- }
-
- /**
* @deprecated 3.0 Use {@link ArrayData::toMap()}.
*/
public function getArray() {

0 comments on commit edf6cd6

Please sign in to comment.
Something went wrong with that request. Please try again.