/** * Checks the location getter & setter */ public function testLocation() { self::$directionsWaypoint->setLocation('address'); $this->assertTrue(self::$directionsWaypoint->hasLocation()); $this->assertEquals(self::$directionsWaypoint->getLocation(), 'address'); $locationTest = new Coordinate(2.1, 1.1, true); self::$directionsWaypoint->setLocation($locationTest); $this->assertEquals(self::$directionsWaypoint->getLocation()->getLatitude(), 2.1); $this->assertEquals(self::$directionsWaypoint->getLocation()->getLongitude(), 1.1); $this->assertTrue(self::$directionsWaypoint->getLocation()->isNoWrap()); self::$directionsWaypoint->setLocation(1.1, 2.1, false); $this->assertEquals(self::$directionsWaypoint->getLocation()->getLatitude(), 1.1); $this->assertEquals(self::$directionsWaypoint->getLocation()->getLongitude(), 2.1); $this->assertFalse(self::$directionsWaypoint->getLocation()->isNoWrap()); $this->setExpectedException('InvalidArgumentException'); self::$directionsWaypoint->setLocation(true); }
/** * Adds a waypoint to the directions request * * Available prototypes: * - public function addWaypoint(Ivory\GoogleMapBundle\Model\Services\Directions\DirectionsWaypoint $waypoint) * - public function addWaypoint(string $location) * - public function addWaypoint(double $latitude, double $longitude, boolean $noWrap) * - public function addWaypoint(Ivory\GoogleMapBundle\Model\Base\Coordinate $location) */ public function addWaypoint() { $args = func_get_args(); if (isset($args[0]) && $args[0] instanceof DirectionsWaypoint) { $this->waypoints[] = $args[0]; } else { if (isset($args[0]) && is_numeric($args[0]) && isset($args[1]) && is_numeric($args[1])) { $waypoint = new DirectionsWaypoint(); $waypoint->setLocation($args[0], $args[1]); if (isset($args[2]) && is_bool($args[2])) { $waypoint->getLocation()->setNoWrap($args[2]); } $this->waypoints[] = $waypoint; } else { if (isset($args[0]) && (is_string($args[0]) || $args[0] instanceof Coordinate)) { $waypoint = new DirectionsWaypoint(); $waypoint->setLocation($args[0]); $this->waypoints[] = $waypoint; } else { throw new \InvalidArgumentException(sprintf('%s' . PHP_EOL . '%s' . PHP_EOL . '%s' . PHP_EOL . '%s' . PHP_EOL . '%s' . PHP_EOL . '%s', 'The origin setter arguments are invalid.', 'The available prototypes are :', ' - public function addWaypoint(Ivory\\GoogleMapBundle\\Model\\Services\\Directions\\DirectionsWaypoint $waypoint)', ' - public function addWaypoint(string $location)', ' - public function addWaypoint(double $latitude, double $longitude, boolean $noWrap)', ' - public function addWaypoint(Ivory\\GoogleMapBundle\\Model\\Base\\Coordinate $location)')); } } } }