Zend Framework Rest Server II - Return of the Characters

LOL .. again ... now it parses deep array structures, but does not enter the content into a CDATA Area ... So far a & seems to be a impossible char forteh rest Server ..
it isnt for the JSON Server so i patched the thing a little bit ;) I guess the guys at Zend are a bit of brain only workers ..... could be that i missed reading some tutorial or so .. but works anyway.

Changed: U   library/Zend/Rest/Server.php
A   ws/json_server.php
Diff: Modified: library/Zend/Rest/Server.php ===================================================================
--- library/Zend/Rest/Server.php    2007-03-12 12:06:30 UTC (rev 107)
+++ library/Zend/Rest/Server.php    2007-03-12 13:41:19 UTC (rev 108)
@@ -304,12 +304,13 @@
             }
 
             if (is_array($value) || is_object($value)) {
-                $element = $dom->createElement($key);
+                $element = $dom->createElement($key);
                 $this->_structValue($value, $dom, $element);
             } else {
-                $element = $dom->createElement($key, $value);
+                $element = $dom->createElement($key);
+                $data = $dom->createCDATASection($value);
+                $element->appendChild($data);
             }
-               
             $parent->appendChild($element);
         }
     }
Related Entries:
Zend Framework Rest Server
PHP Unit Test Systems at GSOC
beating dead smarty horses
doxygen for eclipse
everthing new
 Permalink

Zend Framework Rest Server

silly, but the zend rest server does not serialize nested arrays ... so i came up with a little fix (for the .7.0 incubator):

--- library/Zend/Rest/Server.php 2007-03-07 11:18:03 UTC (rev 39)
+++ library/Zend/Rest/Server.php 2007-03-07 12:23:40 UTC (rev 40)
@@ -199,7 +199,7 @@
}

$method = $function->getName();
-
+
if ($class) {
$xml = "<$class generator='zend' version='1.0'>";
$xml .= "<$method>";
@@ -222,7 +222,15 @@
if (ctype_digit((string) $key)) {
$key = 'key_' . $key;
}
- $xml .= "<$key>$value</$key>";
+ if (is_array($value))
+ {
+ $xml .= "<$key>" . $this->_to_xml($value). "</$key>";
+ }
+ else
+ {
+ $xml .= "<$key>$value</$key>";
+ }
+
}

if (!$has_status) {
@@ -236,6 +244,21 @@
return $xml;
}

+
+ function _to_xml($data)
+ {
+ $xml = '';
+ foreach ($data as $key => $value) {
+ if (is_array($value))
+ {
+ $xml .= _to_xml($value);
+ continue;
+ }
+ $xml .= '<' . $key . '>' . $value . '</' . $key . '>';
+ }
+ return $xml;
+ }
+
/**
* Handle a single value
*
Related Entries:
Zend Framework Rest Server II - Return of the Characters
PHP Unit Test Systems at GSOC
beating dead smarty horses
doxygen for eclipse
everthing new
 Permalink

phpunit is dead (for me)

Rant: I killed the experimental usage if PHPUnit and will rewrite ALL my tests to Simpletest (again).
Why?
I seem way to stupid to follow the guides for test grouping and was not able to get it running. I am very sorry, after some multiple thousand tests in PHP, Python and some in Java it must be possible to use the test runner and all its aspects w.o. getting a degree in informatics. One point may be using a framework with proper error messages:

Catchable fatal error: Argument 1 passed to PHPUnit_Framework_TestSuite::addTest() must implement interface PHPUnit_Framework_Test, string given, called in /home/mruser/public_html/xe2zend/tests/Tpdb/AllTests.php on line 26 and defined in /usr/share/php/PHPUnit/Framework/TestSuite.php on line 234

The test runs out of the box but does not when grouped, the manual has nothing to tell me neither has google ;)

Since Simpletest actually dies w.o. any error message when checking for Exceptions actually, there seems nothing left than cheating a bit with simpletest and use Marcus Bakers trick to test on Exceptions ;) (Thats why i wanted to change to PHPUnit)

function test...() {
    try {
        // throw here.
    } catch (Exception $e) {
    }
    $this->fail('This should have thrown');
}

OMFG ... thank good its friday (and i have to go to work 2morrow) G*


 Permalink
1-3/3