Working on unit tests.
This commit is contained in:
parent
fcc46d6bfd
commit
926a19c5b3
2 changed files with 65 additions and 49 deletions
|
@ -4,8 +4,8 @@ namespace joshtronic;
|
|||
|
||||
class GooglePlaces
|
||||
{
|
||||
public $client = '';
|
||||
private $key = '';
|
||||
private $client = '';
|
||||
private $base_url = 'https://maps.googleapis.com/maps/api/place';
|
||||
private $method = null;
|
||||
private $response = null;
|
||||
|
@ -104,10 +104,7 @@ class GooglePlaces
|
|||
|
||||
if (!in_array($value, array('json', 'xml')))
|
||||
{
|
||||
throw new \Exception('
|
||||
Invalid output, please specify either
|
||||
"json" or "xml".
|
||||
');
|
||||
throw new \Exception('Invalid output, please specify either "json" or "xml".');
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -117,10 +114,7 @@ class GooglePlaces
|
|||
|
||||
if (!in_array($value, array('prominence', 'distance')))
|
||||
{
|
||||
throw new \Exception('
|
||||
Invalid rank by value, please specify
|
||||
either "prominence" or "distance".
|
||||
');
|
||||
throw new \Exception('Invalid rank by value, please specify either "prominence" or "distance".');
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -153,10 +147,7 @@ class GooglePlaces
|
|||
case 'nearbysearch':
|
||||
if (!isset($parameters['location']))
|
||||
{
|
||||
throw new \Exception('
|
||||
You must specify a location before calling
|
||||
nearbysearch().
|
||||
');
|
||||
throw new \Exception('You must specify a location before calling nearbysearch().');
|
||||
}
|
||||
elseif (isset($parameters['rankby']))
|
||||
{
|
||||
|
@ -167,10 +158,7 @@ class GooglePlaces
|
|||
&& !isset($parameters['name'])
|
||||
&& !isset($parameters['types']))
|
||||
{
|
||||
throw new \Exception('
|
||||
You much specify at least one of the
|
||||
following: keyword, name, types.
|
||||
');
|
||||
throw new \Exception('You much specify at least one of the following: keyword, name, types.');
|
||||
}
|
||||
|
||||
if (isset($parameters['radius']))
|
||||
|
@ -182,9 +170,7 @@ class GooglePlaces
|
|||
case 'prominence':
|
||||
if (!isset($parameters['radius']))
|
||||
{
|
||||
throw new \Exception('
|
||||
You must specify a radius.
|
||||
');
|
||||
throw new \Exception('You must specify a radius.');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -195,10 +181,7 @@ class GooglePlaces
|
|||
case 'radarsearch':
|
||||
if (!isset($parameters['location']))
|
||||
{
|
||||
throw new \Exception('
|
||||
You must specify a location before calling
|
||||
nearbysearch().
|
||||
');
|
||||
throw new \Exception('You must specify a location before calling radarsearch().');
|
||||
}
|
||||
elseif (!isset($parameters['radius']))
|
||||
{
|
||||
|
@ -208,10 +191,7 @@ class GooglePlaces
|
|||
&& empty($parameters['name'])
|
||||
&& empty($parameters['types']))
|
||||
{
|
||||
throw new \Exception('
|
||||
A Radar Search request must include at least one
|
||||
of keyword, name, or types.
|
||||
');
|
||||
throw new \Exception('A Radar Search request must include at least one of keyword, name, or types.');
|
||||
}
|
||||
|
||||
if (isset($parameters['rankby']))
|
||||
|
@ -225,10 +205,7 @@ class GooglePlaces
|
|||
if (!(isset($parameters['reference'])
|
||||
^ isset($parameters['placeid'])))
|
||||
{
|
||||
throw new \Exception('
|
||||
You must specify either a placeid or a reference
|
||||
(but not both) before calling details().
|
||||
');
|
||||
throw new \Exception('You must specify either a placeid or a reference (but not both) before calling details().');
|
||||
}
|
||||
|
||||
if (isset($parameters['rankby']))
|
||||
|
@ -268,8 +245,6 @@ class GooglePlaces
|
|||
$querystring .= $variable . '=' . $value;
|
||||
}
|
||||
|
||||
var_dump($this->client);
|
||||
|
||||
$response = $this->client->get($url . '?' . $querystring);
|
||||
|
||||
if ($this->output == 'json')
|
||||
|
@ -316,11 +291,7 @@ class GooglePlaces
|
|||
|| $this->subradius < 200
|
||||
|| ($this->radius / $this->subradius) % 2)
|
||||
{
|
||||
throw new \Exception('
|
||||
Subradius should divide evenly into radius. Also, subradius
|
||||
should be 200 meters or so. (ex: 2000/200 = 10x10 grid. NOT
|
||||
2000/33 = 60.6x60.6 grid. NOT 2000/16 = 125x125 grid)
|
||||
');
|
||||
throw new \Exception('Subradius should divide evenly into radius. Also, subradius should be 200 meters or so. (ex: 2000/200 = 10x10 grid. NOT 2000/33 = 60.6x60.6 grid. NOT 2000/16 = 125x125 grid)');
|
||||
}
|
||||
|
||||
$center = explode(',', $this->location);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue