Merged from branches/2.3

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@80873 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-07-02 07:18:18 +00:00
parent 54f8ece2e7
commit 1b1809f1a2
4 changed files with 34 additions and 3 deletions

View File

@ -325,7 +325,14 @@ class RestfulService_Response extends HTTPResponse {
}
function simpleXML() {
if(!$this->simpleXML) $this->simpleXML = new SimpleXMLElement($this->body);
if(!$this->simpleXML) {
try {
$this->simpleXML = new SimpleXMLElement($this->body);
}
catch(Exception $e) {
user_error("String could not be parsed as XML. " . $e, E_USER_WARNING);
}
}
return $this->simpleXML;
}

View File

@ -279,7 +279,9 @@ class Form extends RequestHandler {
// Otherwise, try a handler method on the form object
} else {
return $this->$funcName($vars, $this, $request);
if($this->hasMethod($funcName)) {
return $this->$funcName($vars, $this, $request);
}
}
}

View File

@ -3,6 +3,7 @@
<head>
<% base_tag %>
<title><% _t('TITLE', 'Image Uploading Iframe') %></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
</head>
<body>

View File

@ -82,6 +82,14 @@ class RestfulServiceTest extends SapphireTest {
$this->assertContains("<request_item name=\"test1a\">second run</request_item>", $responseBody);
}
/**
* @expectedException PHPUnit_Framework_Error
*/
function testIncorrectData() {
$connection = new RestfulService(Director::absoluteBaseURL(), 0);
$test1 = $connection->request('RestfulServiceTest_Controller/invalid?usetestmanifest=1&flush=1');
$test1->xpath("\\fail");
}
}
class RestfulServiceTest_Controller extends Controller {
@ -115,6 +123,19 @@ XML;
return $this->response;
}
public function invalid() {
ContentNegotiator::disable();
BasicAuth::disable();
$out = <<<XML
<?xml version="1.0"?>
<test>
<fail><invalid>
</test>
XML;
header('Content-type: text/xml');
echo $out;
}
}
/**
@ -180,4 +201,4 @@ class RestfulServiceTest_MockRestfulService extends RestfulService {
return $response;
}
}
?>
?>