public function testFetchProfileDetailsByBusinessData() { $mockBatch = $this->getMockBuilder('Silktide\\BrightLocalApi\\Batch')->disableOriginalConstructor()->getMock(); $data = ['business-names' => "A business", 'country' => "GBR", 'city' => 'Derby']; $mockBatchId = "12345"; $mockBatch->expects($this->atLeastOnce())->method('getBatchId')->willReturn($mockBatchId); $this->api->expects($this->atLeastOnce())->method('post')->with('/v4/ld/fetch-profile-details-by-business-data', array_merge($data, ['batch-id' => $mockBatchId])); $this->client->fetchProfileDetailsByBusinessData($mockBatch, $data); }
/** * Test get */ public function testGet() { $responseData = ['success' => true]; $this->mockHandler->append(new Response(200, [], json_encode($responseData))); // Make the call $endpoint = '/v4/blah'; $params = ['some-param' => 'some-value']; $actualResponse = $this->api->get($endpoint, $params); $this->checkResponse('GET', $endpoint, $params, $responseData, $actualResponse, true); }
public function testGetResultsFromBatch() { $sampleResult = '{ "success": true, "status": "Finished", "results": { "LdFetchProfileUrl": [ { "results": [ { "url": "https://plus.google.com/117512971192208385977/about?hl=en&rfmt=s" } ], "status": "Completed", "job-id": 318 } ], "LdFetchProfileDetails": [ { "results": [ { "business_name": "Hub Plumbing & Mechanical", "street_address": null, "postcode": null, "region": null, "locality": null, "address": "Greenwich Village New York, NY", "contact_telephone": "+1 917-634-8888", "description_present": true, "num_photos": 2, "star_rating": "4.7", "num_reviews": 10, "claimed": true, "website_url": "http://www.hubplumbingnyc.com/", "cid": "117512971192208385977", "categories": "Plumber", "check_in": null } ], "status": "Completed", "job-id": 318 } ] }, "statuses": { "Completed": 2 } }'; $sampleResultAsData = json_decode($sampleResult, true); $this->api->expects($this->atLeastOnce())->method('get')->with('/v4/batch', ['batch-id' => $this->demoBatchId])->willReturn($sampleResultAsData); $this->batch->setBatchId($this->demoBatchId); $result = $this->batch->getResults(); $this->assertEquals($sampleResultAsData, $result, "Result data not returned correctly."); }