/** * @depends testProtocol * @depends testDomain * @depends testGraphVersion * @depends testPath * @depends testQueryParams */ public function testUrl() { $client = $this->createClientMock(); $client->method('getDefaultGraphBaseDomain')->willReturn(Client::DEFAULT_GRAPH_BASE_DOMAIN); $request = new Request($client); $request->setGraphVersion('2.2'); $request->setPath('/node/edge'); $url = $request->getUrl(); $this->assertEquals(parse_url($url, PHP_URL_SCHEME) . '://', $request->getProtocol()); $this->assertEquals(parse_url($url, PHP_URL_HOST), $request->getDomain()); $this->assertEquals(parse_url($url, PHP_URL_PATH), sprintf("/v%s%s", $request->getGraphVersion(), $request->getPath())); $this->assertNull(parse_url($url, PHP_URL_QUERY)); // With query $request->setQueryParams(new Parameters(array('sdk' => 'PHP'))); $url = $request->getUrl(); $parsed_query = Util::parseUrlQuery(parse_url($url, PHP_URL_QUERY)); $this->assertEquals($parsed_query, $request->getQueryParams()->getArrayCopy()); }
/** * @param string $url * @return RequestInterface */ protected function createRequestFromUrl($url) { $components = parse_url($url); $request = $this->getLastResponse()->getRequest()->createClone(); $request->setDomain($components['host']); $query = isset($components['query']) ? Util::parseUrlQuery($components['query']) : array(); $request->getQueryParams()->enhance($query); return $request; }