本文整理匯總了PHP中Dispatcher::getHost方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::getHost方法的具體用法?PHP Dispatcher::getHost怎麽用?PHP Dispatcher::getHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::getHost方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Dispatcher
/**
* If RequestURI is proper URI and does not contain QueryParam then it will return proper o/p
*/
function testServiceDispatchingUriRawUrlWithoutQueryParam()
{
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_METHOD] = ODataConstants::HTTP_METHOD_GET;
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_PROTOCOL] = ODataConstants::HTTPREQUEST_HEADER_PROTOCOL_HTTP;
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_HOST] = "localhost:8086";
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_URI] = "/NorthWind.svc/Customers";
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_QUERY_STRING] = null;
try {
$exceptionThrown = false;
$dispatcher = new Dispatcher();
//Service dispatched
$dispatcher->dispatch();
$contents = ob_get_contents();
ob_end_clean();
$this->assertContains("<feed xml:base=\"http://localhost:8086/NorthWind.svc", $contents);
$this->assertContains("<id>http://localhost:8086/NorthWind.svc/Customers</id>", $contents);
$absoluteUri = $dispatcher->getHost()->getAbsoluteRequestUriAsString();
$this->assertEquals("http://localhost:8086/NorthWind.svc/Customers", $absoluteUri);
$rawUrl = $dispatcher->getHost()->getWebOperationContext()->IncomingRequest()->getRawUrl();
$this->assertEquals("http://localhost:8086/NorthWind.svc/Customers", $rawUrl);
} catch (\Exception $exception) {
if (ob_get_length()) {
ob_end_clean();
}
$exceptionThrown = true;
$this->fail('Without Query Params - An unexpected exception has been thrown:' . $exception->getMessage());
}
if (!$exceptionThrown) {
$this->assertTrue(TRUE);
}
$dispatcher->getHost()->getWebOperationContext()->resetWebContextInternal();
}
示例2: testInlineCountNone
/**
* Tests inlinecount
*/
function testInlineCountNone()
{
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_METHOD] = ODataConstants::HTTP_METHOD_GET;
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_PROTOCOL] = ODataConstants::HTTPREQUEST_HEADER_PROTOCOL_HTTP;
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_HOST] = "localhost:8086";
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_URI] = "/NorthWind.svc/Customers";
$_SERVER[ODataConstants::HTTPREQUEST_HEADER_QUERY_STRING] = '$inlinecount=none';
try {
$dispatcher = new Dispatcher();
$dispatcher->dispatch();
$my_str = ob_get_contents();
ob_end_clean();
$dispatcher->getHost()->getWebOperationContext()->resetWebContextInternal();
$this->assertStringStartsWith('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n" . '<feed', $my_str);
$this->assertStringEndsWith('</feed>' . "\n", $my_str);
} catch (\Exception $exception) {
// Should call ob_end_clean
ob_end_clean();
$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
}
}