public function testBoundWithNullValue() { $this->autocomplete->setBound(1, 2, 3, 4); $this->autocomplete->setBound(null); $this->assertNull($this->autocomplete->getBound()); }
/** * @expectedException Ivory\GoogleMap\Exception\HelperException * @expectedExceptionMessage The place autocomplete bound must have coordinates. */ public function testRenderJavascriptsWithInvalidBound() { $autocomplete = new Autocomplete(); $autocomplete->setBound(1, 2, 3, 4); $autocomplete->getBound()->setSouthWest(null); $autocomplete->getBound()->setNorthEast(null); $this->autocompleteHelper->renderJavascripts($autocomplete); }
/** * Renders the autocomplete. * * @param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete. * * @return string The JS output. */ public function renderAutocomplete(Autocomplete $autocomplete) { $this->jsonBuilder->reset(); if ($autocomplete->hasTypes()) { $this->jsonBuilder->setValue('[types]', $autocomplete->getTypes()); } if ($autocomplete->hasBound()) { $this->jsonBuilder->setValue('[bounds]', $autocomplete->getBound()->getJavascriptVariable(), false); } if ($autocomplete->hasComponentRestrictions()) { $this->jsonBuilder->setValue('[componentRestrictions]', $autocomplete->getComponentRestrictions()); } if (!$this->jsonBuilder->hasValues()) { $this->jsonBuilder->setJsonEncodeOptions(JSON_FORCE_OBJECT); } return sprintf('%s = new google.maps.places.Autocomplete(document.getElementById(\'%s\'), %s);' . PHP_EOL, $autocomplete->getJavascriptVariable(), $autocomplete->getInputId(), $this->jsonBuilder->build()); }