public function testHttpAuthenticationUrl() { $this->configuration->makeHttpAuthenticationType(); $expectedAction = 'Test.ff'; $this->parameters['format'] = 'json'; $expectedPath = '/' . $this->configuration->getContext() . '/' . $expectedAction; $expectedParameters = array('channel' => 'de', 'format' => 'json'); $this->assertUrlEquals($expectedPath, $expectedParameters, $this->urlBuilder->getAuthenticationUrl($expectedAction, $this->parameters), $this->configuration->getUserName(), $this->configuration->getPassword()); }
public function testGetResponse() { $this->configuration->makeHttpAuthenticationType(); $parameters = $this->request->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $this->request->setAction('TagCloud.ff'); $response = $this->request->getResponse(); $expectedContent = file_get_contents(RESOURCES_DIR . DS . 'responses' . DS . 'TagCloud_do=getTagCloud.json'); $this->assertEquals(0, $response->getConnectionErrorCode()); $this->assertEquals('', $response->getConnectionError()); $this->assertEquals(200, $response->getHttpCode()); $this->assertEquals($expectedContent, $response->getContent()); }
public function testGetWorkingRequest() { $this->factory->setFileLocation(RESOURCES_DIR . DS . 'responses'); $this->configuration->makeHttpAuthenticationType(); $request = $this->factory->getRequest(); $parameters = $request->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $request->setAction('TagCloud.ff'); $response = $request->getResponse(); $expectedContent = file_get_contents(RESOURCES_DIR . DS . 'responses' . DS . 'TagCloud.86b6b33590e092674009abfe3d7fc170.json'); $this->assertEquals(0, $response->getConnectionErrorCode()); $this->assertEquals('', $response->getConnectionError()); $this->assertEquals(200, $response->getHttpCode()); $this->assertEquals($expectedContent, $response->getContent()); }
public function testLoadResponse() { $this->dataProvider->setFileLocation(RESOURCES_DIR . DS . 'responses'); $this->configuration->makeHttpAuthenticationType(); $connectionData = FF::getInstance('Core\\Server\\ConnectionData'); $id = $this->dataProvider->register($connectionData); $parameters = $connectionData->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $connectionData->setAction('TagCloud.ff'); $this->dataProvider->loadResponse($id); $response = $connectionData->getResponse(); $expectedContent = file_get_contents(RESOURCES_DIR . DS . 'responses' . DS . 'TagCloud.86b6b33590e092674009abfe3d7fc170.json'); $this->assertEquals(0, $response->getConnectionErrorCode()); $this->assertEquals('', $response->getConnectionError()); $this->assertEquals(200, $response->getHttpCode()); $this->assertEquals($expectedContent, $response->getContent()); }
public function testGetWorkingRequest() { $this->configuration->makeHttpAuthenticationType(); $requiredOptions = array(CURLOPT_URL => 'http://*****:*****@demoshop.fact-finder.de:80/FACT-Finder/TagCloud.ff?query=bmx&format=json&do=getTagCloud&verbose=true&channel=de'); $responseContent = 'test response'; $info = array(CURLINFO_HTTP_CODE => '200'); $this->curlStub->setResponse($responseContent, $requiredOptions); $this->curlStub->setInformation($info, $requiredOptions); $request = $this->factory->getRequest(); $parameters = $request->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $request->setAction('TagCloud.ff'); $response = $request->getResponse(); $this->assertEquals(0, $response->getConnectionErrorCode()); $this->assertEquals('CURLE_OK', $response->getConnectionError()); $this->assertEquals(200, $response->getHttpCode()); $this->assertEquals($responseContent, $response->getContent()); }
public function testLoadResponse() { $this->configuration->makeHttpAuthenticationType(); $requiredOptions = array(CURLOPT_URL => 'http://*****:*****@demoshop.fact-finder.de:80/FACT-Finder/TagCloud.ff?format=json&do=getTagCloud&verbose=true&channel=de'); $responseContent = 'test response'; $info = array(CURLINFO_HTTP_CODE => '200'); $this->curlStub->setResponse($responseContent, $requiredOptions); $this->curlStub->setInformation($info, $requiredOptions); $connectionData = FF::getInstance('Core\\Server\\ConnectionData'); $id = $this->dataProvider->register($connectionData); $parameters = $connectionData->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $connectionData->setAction('TagCloud.ff'); $this->dataProvider->loadResponse($id); $response = $connectionData->getResponse(); $this->assertEquals(0, $response->getConnectionErrorCode()); $this->assertEquals('CURLE_OK', $response->getConnectionError()); $this->assertEquals(200, $response->getHttpCode()); $this->assertEquals($responseContent, $response->getContent()); }
public function testResetLoaded() { //setup first request $this->configuration->makeHttpAuthenticationType(); $parameters = $this->request->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $this->request->setAction('TagCloud.ff'); $response = $this->request->getResponse(); $expectedContent = file_get_contents(RESOURCES_DIR . DS . 'responses' . DS . 'TagCloud_do=getTagCloud.json'); $this->assertEquals($expectedContent, $response->getContent()); //setup second request without changing parameters $this->request->resetLoaded(); $response2 = $this->request->getResponse(); //should not be reloaded as url/parameters did not change $this->assertSame($response, $response2); //setup third request with changed parameters $this->request->resetLoaded(); $parameters['wordCount'] = '3'; $response2 = $this->request->getResponse(); //should be reloaded as url/parameters did change $this->assertNotSame($response, $response2); }
public function testLoadInSequence() { $this->configuration->makeHttpAuthenticationType(); $requiredOptions1 = array(CURLOPT_URL => 'http://*****:*****@demoshop.fact-finder.de:80/FACT-Finder/TagCloud.ff?format=json&do=getTagCloud&verbose=true&channel=de'); $responseContent1 = 'test response 1'; $info = array(CURLINFO_HTTP_CODE => '200'); $this->curlStub->setResponse($responseContent1, $requiredOptions1); $this->curlStub->setInformation($info, $requiredOptions1); $requiredOptions2 = array(CURLOPT_URL => 'http://*****:*****@demoshop.fact-finder.de:80/FACT-Finder/TagCloud.ff?format=xml&do=getTagCloud&verbose=true&channel=de'); $responseContent2 = 'test response 2'; $info = array(CURLINFO_HTTP_CODE => '200'); $this->curlStub->setResponse($responseContent2, $requiredOptions2); $this->curlStub->setInformation($info, $requiredOptions2); $connectionData1 = FF::getInstance('Core\\Server\\ConnectionData'); $id1 = $this->dataProvider->register($connectionData1); $parameters = $connectionData1->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $connectionData1->setAction('TagCloud.ff'); $connectionData2 = FF::getInstance('Core\\Server\\ConnectionData'); $id2 = $this->dataProvider->register($connectionData2); // This should not load the content for $id2, because it has not yet // been configured. $this->dataProvider->loadResponse($id1); $response1 = $connectionData1->getResponse(); $this->assertEquals(0, $response1->getConnectionErrorCode()); $this->assertEquals('CURLE_OK', $response1->getConnectionError()); $this->assertEquals(200, $response1->getHttpCode()); $this->assertEquals($responseContent1, $response1->getContent()); $this->assertInstanceOf('FACTFinder\\Core\\Server\\NullResponse', $connectionData2->getResponse()); // Now configure second connection $parameters = $connectionData2->getParameters(); $parameters['format'] = 'xml'; $parameters['do'] = 'getTagCloud'; $connectionData2->setAction('TagCloud.ff'); // Calling loadResponse() for $id1 should not load the second // connection, because there is nothing to be done for $id1 itself. $this->dataProvider->loadResponse($id1); $this->assertSame($response1, $connectionData1->getResponse()); $this->assertInstanceOf('FACTFinder\\Core\\Server\\NullResponse', $connectionData2->getResponse()); // This should now load the second response but should NOT reload the // first one. $this->dataProvider->loadResponse($id2); $this->assertSame($response1, $connectionData1->getResponse()); $response2 = $connectionData2->getResponse(); $this->assertEquals(0, $response2->getConnectionErrorCode()); $this->assertEquals('CURLE_OK', $response2->getConnectionError()); $this->assertEquals(200, $response2->getHttpCode()); $this->assertEquals($responseContent2, $response2->getContent()); }
public function testUseRequestsInSequence() { $this->configuration->makeHttpAuthenticationType(); $requiredOptions1 = array(CURLOPT_URL => 'http://*****:*****@demoshop.fact-finder.de:80/FACT-Finder/TagCloud.ff?query=bmx&format=json&do=getTagCloud&verbose=true&channel=de'); $responseContent1 = 'test response 1'; $info = array(CURLINFO_HTTP_CODE => '200'); $this->curlStub->setResponse($responseContent1, $requiredOptions1); $this->curlStub->setInformation($info, $requiredOptions1); $requiredOptions2 = array(CURLOPT_URL => 'http://*****:*****@demoshop.fact-finder.de:80/FACT-Finder/TagCloud.ff?query=bmx&format=xml&do=getTagCloud&verbose=true&channel=de'); $responseContent2 = 'test response 2'; $info = array(CURLINFO_HTTP_CODE => '200'); $this->curlStub->setResponse($responseContent2, $requiredOptions2); $this->curlStub->setInformation($info, $requiredOptions2); $request1 = $this->factory->getRequest(); $parameters = $request1->getParameters(); $parameters['format'] = 'json'; $parameters['do'] = 'getTagCloud'; $request1->setAction('TagCloud.ff'); $request2 = $this->factory->getRequest(); // This should not load the response for $request2, because it has not // yet been configured. $response1 = $request1->getResponse(); $this->assertEquals(0, $response1->getConnectionErrorCode()); $this->assertEquals('CURLE_OK', $response1->getConnectionError()); $this->assertEquals(200, $response1->getHttpCode()); $this->assertEquals($responseContent1, $response1->getContent()); $this->assertInstanceOf('FACTFinder\\Core\\Server\\NullResponse', $request2->getResponse()); // Now configure second connection $parameters = $request2->getParameters(); $parameters['format'] = 'xml'; $parameters['do'] = 'getTagCloud'; $request2->setAction('TagCloud.ff'); // Calling getResponse() for $request should not do anything, because // there is nothing to be done for $id1 itself. $this->assertSame($response1, $request1->getResponse()); // This should not load the second response and should NOT reload the // first one. $response = $request2->getResponse(); $this->assertEquals(0, $response->getConnectionErrorCode()); $this->assertEquals('', $response->getConnectionError()); $this->assertEquals('0', $response->getHttpCode()); $this->assertEquals('', $response->getContent()); $this->assertSame($response1, $request1->getResponse()); }