public function testGetPageResult() { $url = '/foo'; $attributes = ['something' => '1']; $requestMatcher = Argument::that(function ($request) use($url, $attributes) { return $request instanceof RequestInterface && 'page' === $request->getService() && $url === $request->getParams()['url'] && $attributes === $request->getAttributes(); }); $httpRequestBuilder = $this->prophesize(HttpRequestBuilderInterface::class); $transport = $this->prophesize(TransportInterface::class); $resultBuilderEngine = $this->prophesize(ResultBuilderEngineInterface::class); $result = $this->prophesize(ResultInterface::class); $httpRequest = $this->prophesize(HttpRequestInterface::class); $httpResponse = $this->prophesize(HttpResponseInterface::class); $httpRequestBuilder->build($requestMatcher)->willReturn($httpRequest); $transport->execute($httpRequest)->willReturn($httpResponse); $resultBuilderEngine->build($requestMatcher, $httpResponse)->willReturn($result); $api = new Api($httpRequestBuilder->reveal(), $transport->reveal(), $resultBuilderEngine->reveal()); $actualResult = $api->getPageResult($url, $attributes); $this->assertEquals($result->reveal(), $actualResult); }
public function testGetPagesWithRealTransport() { $this->markTestSkipped("Ask OneHydra for sample endpoint?"); $isUat = false; $authToken = 'foo'; $httpRequestBuilder = new HttpRequestBuilder($isUat, $authToken); $guzzleClient = new Client(); $transport = new GuzzleTransport($guzzleClient); $resultBuilderEngine = new ResultBuilderEngine(); $resultBuilderEngine->addBuilder(new PageResultBuilder()); $resultBuilderEngine->addBuilder(new PagesResultBuilder()); $api = new Api($httpRequestBuilder, $transport, $resultBuilderEngine); $pagesResult = $api->getPagesResult(); $pageResult = $api->getPageResult($pagesResult->getPageUrls()[0]); }