Fixed up a conditional, added a new Distance test.
This commit is contained in:
parent
2fe3f68fe5
commit
36d86100f9
2 changed files with 6 additions and 1 deletions
|
@ -39,7 +39,7 @@ class Distance
|
||||||
{
|
{
|
||||||
$pieces = explode('to', strtolower($method));
|
$pieces = explode('to', strtolower($method));
|
||||||
|
|
||||||
if (count($pieces) == 2)
|
if (count($pieces) == 2 && $pieces[1])
|
||||||
{
|
{
|
||||||
return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]);
|
return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,11 @@ class DistanceTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$this->assertEquals(1765745.8326334, Distance::calculateDistance(27.947222, -82.458611, 40.67, -73.94, 'yards'), '', 0.2);
|
$this->assertEquals(1765745.8326334, Distance::calculateDistance(27.947222, -82.458611, 40.67, -73.94, 'yards'), '', 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNotEnoughUnits()
|
||||||
|
{
|
||||||
|
$this->assertFalse(Distance::milesTo(123));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue