/** * 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(); }
/** * 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()); } }