/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/test/test_ext_soap.h"
#include "hphp/runtime/ext/ext_output.h"
///////////////////////////////////////////////////////////////////////////////
bool TestExtSoap::RunTests(const std::string &which) {
bool ret = true;
DECLARE_TEST_FUNCTIONS("function hello() {"
" return 'Hello World';"
"}"
"function add($a, $b) {"
" return (int)$a + (int)$b;"
"}"
"function sub($a, $b) {"
" return (int)$a - (int)$b;"
"}"
"function sum($a) {"
" $sum = 0;"
" foreach ($a as $v) {"
" $sum += (int)$v;"
" }"
" return $sum;"
"}"
"function fault() {"
" return new SoapFault('MyFault', 'My fault string');"
"}");
RUN_TEST(test_SoapServerSanity);
RUN_TEST(test_SoapServerFunctionAll);
RUN_TEST(test_SoapServerFunctionParam);
RUN_TEST(test_SoapServerArrayParam);
RUN_TEST(test_SoapServerWSDL);
RUN_TEST(test_SoapServerFault);
m_server.reset();
return ret;
}
bool TestExtSoap::preTest() {
m_server = p_SoapServer(NEWOBJ(c_SoapServer)());
m_server->t___construct(uninit_null(), CREATE_MAP1("uri", "http://testuri.org"));
return true;
}
///////////////////////////////////////////////////////////////////////////////
// helpers
bool TestExtSoap::verify_response(CStrRef request, CStrRef expected) {
f_ob_start();
m_server->t_handle(request);
String res = f_ob_get_contents();
f_ob_end_clean();
VS(res, expected);
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool TestExtSoap::test_SoapServerSanity() {
m_server->t_addfunction("hello");
VSOAP("",
"Hello World"
"");
return Count(true);
}
bool TestExtSoap::test_SoapServerFunctionAll() {
m_server->t_addfunction(k_SOAP_FUNCTIONS_ALL);
VSOAP(""
"Hello World"
"",
"11"
"");
return Count(true);
}
bool TestExtSoap::test_SoapServerFunctionParam() {
Array funcs = CREATE_VECTOR2("Sub", "Add");
m_server->t_addfunction(funcs);
VS(m_server->t_getfunctions(), funcs);
VSOAP(""
"22"
"33"
"",
"55"
"");
return Count(true);
}
bool TestExtSoap::test_SoapServerArrayParam() {
m_server->t_addfunction("Sum");
VSOAP(""
""
" 3"
" 5"
""
"",
"8"
"");
return Count(true);
}
bool TestExtSoap::test_SoapServerWSDL() {
m_server = p_SoapServer(NEWOBJ(c_SoapServer)());
m_server->t___construct("test/slow/ext_soap/1809.wsdl",
CREATE_MAP1("uri", "http://testuri.org"));
m_server->t_addfunction("Add");
VSOAPNS(""
"22"
"33"
"",
"55"
"",
"");
return Count(true);
}
bool TestExtSoap::test_SoapServerFault() {
m_server->t_addfunction("Fault");
VSOAPEX("",
"\n"
"MyFault"
"My fault string"
"\n");
return Count(true);
}