* $_POST = array( * 'action'=>'DoGetData' * 'params'=> [ * ... * ] * ) * */ if (!empty($_POST['action'])) { $result = $qas->call($_POST); } elseif (!empty($_POST['Moniker'])) { // Lets step-in, refine results or get full adress details- invokes DoRefine action if (!empty($_POST['getDetails'])) { // get full address details $result = $qas->getAddressDetails($_POST['Moniker']); } else { // step-in / refine results $result = $qas->refine($_POST['Moniker']); } } elseif (!empty($_POST)) { // Lets do initial request - invokes DoSearch action $test = $utils->sanitizeInputArray($_POST); $result = $qas->search($utils->formatSearchQuery($test)); } if (is_a($result, 'SoapFault')) { //If SoapFault was returned from server echo $utils->soapError($result, true); } else { // If everything is ok, return JSON string echo $qas->getJson(); }
public function testFormatSearchQuery() { $_POST = ['Flat' => 4, 'House Name' => 'Some House', 'Street' => 'Some Street ', 'Town' => 'Some Town', 'Postcode' => 'III PPP ', 'County' => 'Some County']; $this->assertEquals("4, Some House, Some Street, Some Town, III PPP, Some County", $this->utils->formatSearchQuery($_POST)); $this->assertEquals("some address", $this->utils->formatSearchQuery("some address")); }